output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the necessary number of candies in total. * * *
s456383760
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
print("".join(map(lambda x: x[0], input().split())).upper())
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s837737353
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int(input()) c = 0 for i in range(n+1) c +=i print(c)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s691272538
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
print("3")
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s007632751
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print((N*(N+1)//2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s967809212
Accepted
p04029
The input is given from Standard Input in the following format: N
f = lambda x: x * (x + 1) // 2 print(f(int(input())))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s802475707
Accepted
p04029
The input is given from Standard Input in the following format: N
val1 = int(input()) print(int(val1 * (val1 + 1) / 2))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s317146339
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
print(sum([i for i in range(int(input()))]))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s813721987
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print(sum([i for i in range(1, N+1)])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s764675278
Accepted
p04029
The input is given from Standard Input in the following format: N
# /usr/bin/python3 # -*- coding: utf-8 -*- from queue import Queue from queue import LifoQueue as Stack from math import sqrt, floor, ceil, log2 from fractions import gcd from itertools import permutations, combinations from operator import itemgetter from functools import cmp_to_key __MOD__ = (10**9) + 7 yn = "YNeos" judge = False cnt = 0 ans = None def lcm(a, b): return (a * b) // gcd(a, b) def intinput(): return int(input()) def mulinputs(): return map(int, input().split()) def lineinputs(func=intinput): datas = [] while True: try: datas.append(func()) except EOFError: break return datas class ModInt: def __init__(self, x): self.__x = x % __MOD__ def __add__(self, other): if type(other) == int: other = self.__class__(other) return int(self.__class__((self.__x + other.__x) % __MOD__)) elif type(other) == ModInt: return self.__class__((self.__x + other.__x) % __MOD__) else: raise Exception("Not Int or Not ModInt") def __sub__(self, other): if type(other) == int: other = self.__class__(other) return int(self.__class__((self.__x - other.__x) % __MOD__)) elif type(other) == ModInt: return self.__class__((self.__x - other.__x) % __MOD__) else: raise Exception("Not Int or Not ModInt") def __mul__(self, other): if type(other) == int: other = self.__class__(other) return int(self.__class__((self.__x * other.__x) % __MOD__)) elif type(other) == ModInt: return self.__class__((self.__x * other.__x) % __MOD__) else: raise Exception("Not Int or Not ModInt") def __truediv__(self, other): if type(other) == int: other = self.__class__(other) return int(self.__class__((self.__x * other.__modinv()) % __MOD__)) elif type(other) == ModInt: return self.__class__((self.__x * other.__modinv()) % __MOD__) else: raise Exception("Not Int or Not ModInt") def __pow__(self, other): if type(other) == int: other = self.__class__(other) return int(self.__class__(pow(self.__x, other.__x, __MOD__))) elif type(other) == ModInt: return self.__class__(pow(self.__x, other.__x, __MOD__)) else: raise Exception("Not Int or Not ModInt") def __modinv(self, m=__MOD__): a = self.__x if a == 0: raise ZeroDivisionError() if gcd(a, m) != 1: raise Exception("%sの逆数は求まりません。" % a) b, u, v = m, 1, 0 while b != 0: t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, u u %= m if u < 0: u += m return u def __int__(self): return self.__x if __name__ == "__main__": N = intinput() # 出力 print(N * (1 + N) // 2) # EOF
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s325052962
Accepted
p04029
The input is given from Standard Input in the following format: N
# 043_a N = int(input()) if 1 <= N & N <= 100: result = 0 for i in range(N): count = N - i result += count if count == 1: print(result)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s394592404
Accepted
p04029
The input is given from Standard Input in the following format: N
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x) - 1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float("INF") # A def A(): a = II() ans = 0 for i in range(a + 1): ans += i print(ans) return # B def B(): return # C def C(): return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": A()
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s443214995
Accepted
p04029
The input is given from Standard Input in the following format: N
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10**9) INF = float("inf") mod = 10**9 + 7 N = INT() print(N * (N + 1) // 2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s770880604
Runtime Error
p04029
The input is given from Standard Input in the following format: N
import sympy as sym A = sym.sequence(N*(N+1)/2,(n, 1, 100)) print([int(N) for in A])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s285913251
Runtime Error
p04029
The input is given from Standard Input in the following format: N
import sympy as sym (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z') A = sym.sequence(N*(N+1)/2,(n, 1, 100)) print([int(N) for in A])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s280702683
Runtime Error
p04029
The input is given from Standard Input in the following format: N
count = int(input()) result = 0 for i in range(count+1): print(i) result += i print(result
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s328270822
Runtime Error
p04029
The input is given from Standard Input in the following format: N
a = list(input()) b = [] for i in a: if a.count(i) >= len(a) / 2: b = [j for j, x in enumerate(a) if x == i] else: pass if not b: print(-1, 1) else: print(b[0], b[1])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s066323923
Runtime Error
p04029
The input is given from Standard Input in the following format: N
import sympy as sym A = sym.sequence(N*(N+1)/2,(n, 1, 100)) print([int(N) for in A]) print(A[3])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s157548262
Runtime Error
p04029
The input is given from Standard Input in the following format: N
#include <algorithm> #include <iostream> //入出力 #include <stdio.h> #include <map> #include <set> #include <string> #include <math.h> //算術演算子 #include <vector> #include <cstdlib> #include <queue> #include <stack> #include <list> #include <iomanip> //小数点以下を表示させる(setprecision()) // #include <bits/stdc++.h> using namespace std; typedef long long ll; //64bit型 #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define debug(x) cerr << x << " " \ << "(L:" << __LINE__ << ")" << '\n' #define PRINT(V) \ { \ for (int i = 0; i < V.size(); i++) \ { \ cout << V[i] << " "; \ } \ cout << endl; \ } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() //input->compute->output { int N, K; cin >> N; cout << N * (N +1) / 2 << endl; return 0; }
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s053047532
Runtime Error
p04029
The input is given from Standard Input in the following format: N
#!/usr/bin/python # -*- coding: UTF-8 -*- import sys def get_ints(): return map(int, sys.stdin.readline().strip().split()) def _main(): input() an = list(get_ints()) t = 0 old = 1000000000 while 1: ans = sq(t, an) g = sq(t + 1, an) - ans t -= g / abs(g) if old > ans: old = ans else: break print(int(old)) def sq(t, an): ans = 0 for ai in an: ans += pow(ai - t, 2) return ans if __name__ == "__main__": _main()
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s161349362
Runtime Error
p04029
The input is given from Standard Input in the following format: N
s = input() temp = 0 tem = 0 tot = 0 if len(s) > 10**3: for i in range(len(s)): tem = 1 temp = 1 flag = 0 for j in range(i + 1, len(s)): if s[j] == s[i]: temp += 1 tem += 1 if temp > (tem // 2): print(i + 1, j + 1) flag = 1 tot = 1 break if flag: break if tot == 0: print("-1 -1") else: for i in range(len(s) - 2): if s[i] == s[i + 1]: print(i + 1, i + 2) flag = 1 break elif s[i] == s[i + 2]: print(i + 1, i + 3) flag = 1 break if flag == 0: print("-1 -1")
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s878680944
Runtime Error
p04029
The input is given from Standard Input in the following format: N
import sympy as sym (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z') N = int(input()) A = sym.sequence((N*(N+1))/2,(n, 1, 100)) print([int(N) for in A])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s782655476
Runtime Error
p04029
The input is given from Standard Input in the following format: N
A = 0 S = input() fot n in range(1,int(S)+1): A = A + n print(A)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s259448951
Runtime Error
p04029
The input is given from Standard Input in the following format: N
print(sum(range(1, input() + 1)))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s788868739
Runtime Error
p04029
The input is given from Standard Input in the following format: N
A = 0 S = input() fot n in range(1,int(S)+1): A = A + n
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s875454529
Runtime Error
p04029
The input is given from Standard Input in the following format: N
A = 0 S = input() fot n in tange(1,int(S)+1): A = A + n
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s996019790
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n=int(input()) sum=0 for i in range(1:n+1): sum+=i print(sum)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s319533284
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int(input()) ans = 0 for i in range(1, n+1) ans += i print(ans)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s997318134
Runtime Error
p04029
The input is given from Standard Input in the following format: N
def candies(): n = int(input()) a = n * (n + 1) / 2 print(a)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s717744403
Runtime Error
p04029
The input is given from Standard Input in the following format: N
x = input() candies = 0 for y in x: candies += y + 1 print(candies)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s056344201
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int(input()) res= 0 if i in range(n) res += i+1 print(res)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s424953207
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int(input() s = 0 for i in range(N+1): s += i print(s)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s269490667
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print(N*(N+1))//2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s804174920
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int(input()) print((n*(n+1)/2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s438189331
Runtime Error
p04029
The input is given from Standard Input in the following format: N
n = int (input()) print (n*(n+1)/2))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s576378728
Accepted
p04029
The input is given from Standard Input in the following format: N
print(sum([(i + 1) for i in range(int(input()))]))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s771958743
Accepted
p04029
The input is given from Standard Input in the following format: N
W = int(input()) print(sum(list(range(1, W + 1))))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s613149221
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
num = input("N") print(int(num) * (int(num) + 1) / 2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s390799343
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) int S = N*(N+1)/2 print(S)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s452125619
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
print((lambda x: x * ~-x / 2)(int(input())))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s841434625
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print(int(N * (N+1) / 2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s624741308
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
print((lambda x: int(x) * (int(x) + 1) / 2)(input()))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s864080340
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
n = int(input()) x = 1 + n y = n / 2 z = x * y print(z)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s138610384
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print(int((1 + N) * N / 2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s047670131
Runtime Error
p04029
The input is given from Standard Input in the following format: N
print(int((N=int(input())) * (N+1) /2))
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s602265058
Runtime Error
p04029
The input is given from Standard Input in the following format: N
N = int(input()) print(int(N * (N + 1) / 2)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s318730386
Accepted
p04029
The input is given from Standard Input in the following format: N
kosu = [0] * 100 kosu[0] = 1 for i in range(99): kosu[i + 1] = kosu[i] + i + 2 print(kosu[int(input()) - 1])
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s552134393
Wrong Answer
p04029
The input is given from Standard Input in the following format: N
def candy_number(): children = input("N") num = int(children) * (int(children) + 1) / 2 print("N") print(num)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s749777703
Runtime Error
p04029
The input is given from Standard Input in the following format: N
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int ans = 0; for(int i = 0;i <= N; i++) { ans += i; } System.out.println(ans); } }
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s090121597
Runtime Error
p04029
The input is given from Standard Input in the following format: N
#include <bits/stdc++.h> using namespace std; using ll =long long; #define SORT(a) sort((a).begin(),(a).end()) #define rSORT(a) reverse((a).begin(),(a).end()) #define For(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define rep(i, n) For(i, 0, n) #define debug(x) cerr << #x << " = " << (x) << endl; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } void coY() {cout <<"Yes"<<endl;} void coN(){cout <<"No"<<endl;} const ll INF = 1LL << 60; //Write From this Line const int mod = 1e9+7; int main() { int n ; cin >> n ; int ans = 0 ; ans = ( n * (n+1) / 2 ); cout << ans << endl; }
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s011566641
Runtime Error
p04029
The input is given from Standard Input in the following format: N
function Main(input) { const n = parseInt(input); var ans = 0 for (var i = 1; i <= n ; i++) { ans += i } console.log(ans); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s283176452
Runtime Error
p04029
The input is given from Standard Input in the following format: N
def candies(): n = int(input()) a = (n * (n + 1)) / 2 print(a) candies()
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the necessary number of candies in total. * * *
s463554533
Runtime Error
p04029
The input is given from Standard Input in the following format: N
count = 0 for i range(int(input()) + 1): if i == 0: continue count += i print(count)
Statement There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
[{"input": "3", "output": "6\n \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n \n\nOnly one child. The answer is 1 in this case."}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s219210152
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) As = list(map(int, input().split())) print(*reversed(As))
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s591662273
Runtime Error
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) a_list = list(map(int,input().split)) reversed_a_list = a_list.reverse() a = ' '.join(reversed_a_list) print(a)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s896068767
Runtime Error
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
e = [input() for _ in [0] * int(input())] for s in "SHCD": for r in range(1, 14): if f"{s} {r}" not in e: print(s, r)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s584530579
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) num = input().split() renum = "" for i in num: n -= 1 renum += num[n] if int(n) != 0: renum += " " print(renum)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s517442904
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
def resolve(): _ = int(input()) nums = list(map(int, input().split())) nums.reverse() # destructive method counter = 1 for num in nums: if counter == len(nums): print(num) break else: print(num, end=" ") counter += 1 resolve()
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s009419253
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
first_line = input() length = int(first_line) second_line = input() numbers_str = second_line.split() result_list = numbers_str[::-1] result = " ".join(result_list) print(result)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s247636670
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
count = input() numbers = list(map(int, input().split())) # リストを逆順に並び替え、新しいリストに入れる re_numbers = list(reversed(numbers)) print(*re_numbers)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s613385395
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) L = list(map(int, input().split())) L.reverse() print(*L)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s557237438
Wrong Answer
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) num = [int(i) for i in input().split()] for i in range(round(len(num) / 2)): num[i], num[len(num) - i - 1] = num[len(num) - i - 1], num[i] print(num)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s252285068
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) a = input() lst = a.split() lst_n = [int(i) for i in lst] lst_n.reverse() print(*lst_n)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s081572316
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
def reverse_array(array): array = array[::-1] for i in range(len(array)): if i == len(array) - 1: print(str(array[i]), end="") else: print(str(array[i]) + " ", end="") print("\n", end="") if __name__ == "__main__": number = int(input()) seq = input().split(" ") array = [int(a) for a in seq] reverse_array(array)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s770788054
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
(lambda _, s: print(*reversed(s.split())))(input(), input())
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s028612320
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
a = [] for i in range(0, 2): l = list(map(int, input().split())) a.append(l) d = a[1][::-1] print(" ".join(map(str, d)))
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s753028888
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) A = list(map(str, input().split())) A = reversed(A) A = " ".join(A) print(A)
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s316999733
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
unused = input() values = [x for x in input().split()] print(" ".join(values[::-1]))
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the reversed sequence in a line. Print a single space character between adjacent elements (Note that your program should not put a space character after the last element).
s212650697
Accepted
p02407
The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence.
n = int(input()) ss = input().split(" ") s = "" ss.reverse() for i in ss: s += i + " " print(s[: len(s) - 1])
Reversing Numbers Write a program which reads a sequence and prints it in the reverse order.
[{"input": "5\n 1 2 3 4 5", "output": "5 4 3 2 1"}, {"input": "8\n 3 3 4 4 5 8 7 9", "output": "9 7 8 5 4 4 3 3"}]
Print the maximum possible number of operations in a line. * * *
s153335897
Accepted
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
import networkx as nx n, m = map(int, input().split()) board = [input() for _ in range(n)] k = 0 for i in range(n): for j in range(m): if board[i][j] == "o": k += 1 INF = 10**9 g = nx.DiGraph() g.add_node(0, demand=k) for i in range(n): for j in range(m): if board[i][j] == "#": continue if board[i][j] == "o": g.add_node((i, j), demand=-1) g.add_edge((i, j), 0, capacity=1, weight=0) elif board[i][j] == ".": g.add_node((i, j), demand=0) g.add_edge((i, j), 0, capacity=1, weight=0) if i + 1 < n and board[i + 1][j] != "#": g.add_edge((i, j), (i + 1, j), weight=-1, capacity=INF) if j + 1 < m and board[i][j + 1] != "#": g.add_edge((i, j), (i, j + 1), weight=-1, capacity=INF) flow = nx.min_cost_flow(g) result = sum(v * g[k1][k2]["weight"] for k1, dc in flow.items() for k2, v in dc.items()) print(-result)
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
Print the maximum possible number of operations in a line. * * *
s537202768
Runtime Error
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
import networkx as nx n, m = map(int, input().split()) S = [list(input()) for _ in range(n)] G = nx.DiGraph() start = (n, m) cnt = 0 goal = (n, m + 1) for i in range(n): for j in range(n): if S[i][j] != "#": if S[i][j] == "o": cnt += 1 G.add_edge(start, (i, j), capacity=1) if i + 1 < n: if S[i + 1][j] != "#": G.add_edge((i, j), (i + 1, j), weight=-1) if j + 1 < m: if S[i][j + 1] != "#": G.add_edge((i, j), (i, j + 1), weight=-1) G.add_edge((i, j), goal, capacity=1) # G.add_node(start, demand=cnt) # G.add_node(goal, demand=-cnt) mincostflow = nx.max_flow_min_cost(G, start, goal) ans = nx.cost_of_flow(G, mincostflow) print(abs(ans))
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
Print the maximum possible number of operations in a line. * * *
s289697623
Accepted
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline from heapq import heappush, heappop class Mincostflow: def __init__(self, N): self.N = N self.adj = [[] for _ in range(N + 1)] self.inf = 1 << 60 def add_edge(self, fr, to, cap, cost): # [to, cap, cost, rev] forward = [to, cap, cost, None] backward = forward[3] = [fr, 0, -cost, forward] self.adj[fr].append(forward) self.adj[to].append(backward) def flow(self, s, t, f): N = self.N adj = self.adj inf = self.inf res = 0 H = [0] * (N + 1) prev_v = [0] * (N + 1) prev_e = [None] * (N + 1) dist0 = [inf] * (N + 1) dist = [inf] * (N + 1) while f: dist[:] = dist0 dist[s] = 0 pq = [(0, s)] while pq: d, v = heappop(pq) if d > dist[v]: continue r0 = dist[v] + H[v] for e in adj[v]: u, cap, cost, _ = e if cap > 0 and r0 + cost - H[u] < dist[u]: dist[u] = r = r0 + cost - H[u] heappush(pq, (r, u)) prev_v[u] = v prev_e[u] = e # flow f doesn't exist if dist[t] == inf: return None for i in range(1, N + 1): H[i] += dist[i] g = f v = t while v != s: g = min(g, prev_e[v][1]) v = prev_v[v] f -= g res += g * H[t] v = t while v != s: e = prev_e[v] e[1] -= g e[-1][1] += g v = prev_v[v] return res H, W = map(int, input().split()) grid = [] for _ in range(H): grid.append(input().rstrip("\n")) s = H * W + 1 t = H * W + 2 mcf = Mincostflow(H * W + 2) cnt = 0 no_move = 0 for h in range(H): for w in range(W): if grid[h][w] == "#": continue else: if grid[h][w] == "o": cnt += 1 no_move += H + W - h - w mcf.add_edge(s, h * W + w + 1, 1, 0) if h + 1 < H: if grid[h + 1][w] != "#": mcf.add_edge(h * W + w + 1, (h + 1) * W + w + 1, 100, 0) if w + 1 < W: if grid[h][w + 1] != "#": mcf.add_edge(h * W + w + 1, h * W + w + 2, 100, 0) mcf.add_edge(h * W + w + 1, t, 1, H + W - h - w) print(no_move - mcf.flow(s, t, cnt)) if __name__ == "__main__": main()
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
Print the maximum possible number of operations in a line. * * *
s610239326
Wrong Answer
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
import sys import networkx as nx import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W = map(int, readline().split()) S = np.frombuffer(read(), "S1").reshape(H, -1)[:, :W].astype("U1") INF = 1 << 32 total_o = (S == "o").sum() G = nx.DiGraph() sink = "sink" G.add_node(sink, demand=total_o) for i in range(H): for j in range(W): if S[i, j] == "#": continue if S[i, j] == "o": G.add_node((i, j), demand=-1) G.add_edge((i, j), sink, capacity=1, weight=0) elif S[i, j] == ".": G.add_node((i, j), demand=0) G.add_edge((i, j), sink, capacity=1, weight=0) if i + 1 < H and S[i + 1, j] != "#": G.add_edge((i, j), (i + 1, j), capacity=INF, weight=-1) if j + 1 < W and S[i, j + 1] != "#": G.add_edge((i, j), (i, j + 1), capacity=INF, weight=-1)
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
Print the maximum possible number of operations in a line. * * *
s951524513
Runtime Error
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
import networkx as nx import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) def solve(): INF = float("inf") def max2(x, y): return x if x >= y else y N, M = map(int, input().split()) Sss = ["#" * (M + 2)] + ["#" + input() + "#" for _ in range(N)] + ["#" * (M + 2)] poss = [] for i in range(1, N + 1): for j in range(1, M + 1): if Sss[i][j] == "o": poss.append((i, j)) numA = len(poss) def f(x, y): anss = [] dp = [-INF] * (M + 2) for i in range(1, N + 1): dp2 = [-INF] * (M + 2) for j in range(1, M + 1): if Sss[i][j] == "#": continue if i == x and j == y: dp2[j] = 0 else: dp2[j] = max2(dp[j], dp2[j - 1]) + 1 dp = dp2 anss.append(dp[1:-1]) return anss # for x, y in poss: # f(x, y) # print() s, t = N * M + numA, N * M + numA + 1 G = nx.DiGraph() G.add_node(s, demand=-numA) G.add_node(t, demand=numA) for i in range(N): for j in range(M): k = i * M + j G.add_node(k) G.add_edge(k, t, weight=0, capacity=1) KK = 10**6 for iPos, (x, y) in enumerate(poss, start=N * M): G.add_node(iPos) G.add_edge(s, iPos, weight=0, capacity=1) dp = f(x, y) for i in range(N): for j in range(M): if dp[i][j] != -INF: k = i * M + j wt = KK - dp[i][j] G.add_edge(iPos, k, weight=wt, capacity=1) C = nx.min_cost_flow_cost(G) ans = KK * numA - C print(ans) solve()
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
Print the maximum possible number of operations in a line. * * *
s507909651
Wrong Answer
p02542
Input is given from Standard Input in the following format: N M S_1 S_2 \vdots S_N
from collections import deque import numpy as np N, M = map(int, input().split()) S = [list(input()) for _ in range(N)] moves = [(1, 0), (0, 1)] starts = [] for i in range(N): for j in range(M): if S[i][j] == "o": starts.append((i, j)) answer = 0 for start in starts: visited = np.full((N, M), -1) start_y, start_x = start q = deque() q.append((start_y, start_x)) visited[start_y, start_x] = 0 while q: y, x = q.popleft() for dy, dx in moves: moved_y = y + dy moved_x = x + dx if moved_y < 0 or N - 1 < moved_y or moved_x < 0 or M - 1 < moved_x: continue if S[moved_y][moved_x] == "#" or S[moved_y][moved_x] == "o": continue if visited[moved_y, moved_x] != -1: continue visited[moved_y, moved_x] = visited[y, x] + 1 q.append((moved_y, moved_x)) answer += np.max(visited) print(answer)
Statement There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
[{"input": "3 3\n o..\n ...\n o.#", "output": "4\n \n\nYosupo can perform operations 4 times as follows:\n\n \n \n o.. .o. ..o ... ...\n ... -> ... -> ... -> ..o -> ..o\n o.# o.# o.# o.# .o#\n \n\n* * *"}, {"input": "9 10\n .#....o#..\n .#..#..##o\n .....#o.##\n .###.#o..o\n #.#...##.#\n ..#..#.###\n #o.....#..\n ....###..o\n o.......o#", "output": "24"}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s279772647
Accepted
p02811
Input is given from Standard Input in the following format: K X
k, n = map(int, input().split()) print("Yes" if k * 500 >= n else "No")
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s717314225
Wrong Answer
p02811
Input is given from Standard Input in the following format: K X
s, t = input().split() print(t + s)
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s807980177
Runtime Error
p02811
Input is given from Standard Input in the following format: K X
import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) def lcm_base(x, y): return (x * y) // fractions.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr N, M = map(int, input().split()) A = list(map(int, input().split())) # if gcd(*A) % 2 != 0: # print(0) # exit(0) # sisu_2 = factorization(A[0])[0][1] sisu_2 = min([factorization(A[i])[0][1] for i in range(min(1000, N))]) # lcm_a = lcm(*A) # lcm_a_half = lcm_a // 2 lcm_a = lcm(*A) // 2 """ l = [] sisu_a0 = 0 for i in range(N): sisu = 0 while A[i]%2==0: A[i] //= 2 sisu += 1 if sisu_a0==0: sisu_a0 = sisu else: if sisu_a0!=sisu: print(0) exit() """ if (lcm_a % (2**sisu_2) == 0) or lcm_a > M: # factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M: # if lcm_a > M: print(0) exit(0) else: print(int((M - lcm_a) // (lcm_a * 2) + 1))
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s047687648
Accepted
p02811
Input is given from Standard Input in the following format: K X
has, need = [int(x) for x in input().split()] print(["No", "Yes"][has * 500 >= need])
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s583544037
Accepted
p02811
Input is given from Standard Input in the following format: K X
m = input().split(" ") print("Yes" if ((int(m[0]) * 500) >= int(m[1])) else "No")
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s107347538
Wrong Answer
p02811
Input is given from Standard Input in the following format: K X
# Code for A - 500 Yen Coins # Use input() to fetch data from STDIN print("Hello world")
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s206966193
Runtime Error
p02811
Input is given from Standard Input in the following format: K X
k, x = int(input()), int(input()) print("yes") if k * 500 >= x else ("no")
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
If the coins add up to X yen or more, print `Yes`; otherwise, print `No`. * * *
s281210106
Wrong Answer
p02811
Input is given from Standard Input in the following format: K X
print( (lambda x: "Yes" if x[1] // 500 >= x[0] else "No")(list(map(int, input().split()))) )
Statement Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.
[{"input": "2 900", "output": "Yes\n \n\nTwo 500-yen coins add up to 1000 yen, which is not less than X = 900 yen.\n\n* * *"}, {"input": "1 501", "output": "No\n \n\nOne 500-yen coin is worth 500 yen, which is less than X = 501 yen.\n\n* * *"}, {"input": "4 2000", "output": "Yes\n \n\nFour 500-yen coins add up to 2000 yen, which is not less than X = 2000 yen."}]
Print the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K. * * *
s161162397
Runtime Error
p03703
Input is given from Standard Input in the following format: N K a_1 a_2 : a_N
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10**9 + 7 INF = float("inf") def getlist(): return list(map(int, input().split())) class SegmentTree(object): # N:処理する区間の長さ def __init__(self, N): self.N = N self.N0 = 2 ** (N - 1).bit_length() self.initVal = 0 self.data = [self.initVal] * (2 * self.N0) # 区間クエリの種類 def calc(self, a, b): return a + b # k番目の値にxを加算 def add(self, k, x): k += self.N0 - 1 self.data[k] += x while k > 0: k = (k - 1) // 2 self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2]) # 区間[l, r]の演算値 def query(self, l, r): L = l + self.N0 R = r + self.N0 + 1 m = self.initVal while L < R: if R & 1: R -= 1 m = self.calc(m, self.data[R - 1]) if L & 1: m = self.calc(m, self.data[L - 1]) L += 1 L >>= 1 R >>= 1 return m # 処理内容 def main(): N, K = getlist() A = [] for i in range(N): a = int(input()) A.append(a) # K引く for i in range(N): A[i] -= K # 累積和 B = [0] for i in range(N): B.append(B[-1] + A[i]) # 座圧 C = list(set(B)) C.sort() D = defaultdict(int) for i in range(len(C)): D[C[i]] = i # 座標変換 for i in range(N + 1): B[i] = D[B[i]] # セグ木 ans = 0 Seg = SegmentTree(N) for i in range(N + 1): b = B[i] val = Seg.query(0, b) ans += val Seg.add(b, 1) print(ans) if __name__ == "__main__": main()
Statement You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
[{"input": "3 6\n 7\n 5\n 7", "output": "5\n \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n * {a_1} = {7}\n * {a_1, a_2} = {7, 5}\n * {a_1, a_2, a_3} = {7, 5, 7}\n * {a_2} = {5}\n * {a_2, a_3} = {5, 7}\n * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n 1", "output": "0\n \n\n* * *"}, {"input": "7 26\n 10\n 20\n 30\n 40\n 30\n 20\n 10", "output": "13"}]
Print the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K. * * *
s175756958
Runtime Error
p03703
Input is given from Standard Input in the following format: N K a_1 a_2 : a_N
import bisect from itertools import accumulate # python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def brute(): N, K = map(int, input().split()) L = [int(input()) for _ in range(N)] ans = 0 for i in range(N): for j in range(i, N): if sum(L[i:j+1])/(j+1-i) >= K: ans += 1 print(ans) def solve(): N, K = map(int, input().split()) L = [int(input()) for _ in range(N)] L_acc = [0]+list(accumulate(L)) for i in range(N+1): L_acc[i] -= (i)*K L_sort = list(sorted(set(L_acc))) L_comp = [-1]*(N+1) for i in range(N+1): key = L_acc[i] ind = bisect.bisect_left(L_sort, key) L_comp[i] = ind # BIT bit = [0]*(N+1) def sum_bit(i): s = 0 while i > 0: s += bit[i] i -= i & (-i) return s def add(i, x): while i <= N: bit[i] += x i += i & (-i) ans = 0 for i, l in enumerate(L_comp): if l == 0: ans += N-i continue ans += sum_bit(l) add(l, 1) print(ans) solve() ans = 0 for i, l in enumerate(L_comp): if l == 0: ans += N-i continue ans += sum_bit(l) add(l, 1) print(ans) solve()
Statement You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
[{"input": "3 6\n 7\n 5\n 7", "output": "5\n \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n * {a_1} = {7}\n * {a_1, a_2} = {7, 5}\n * {a_1, a_2, a_3} = {7, 5, 7}\n * {a_2} = {5}\n * {a_2, a_3} = {5, 7}\n * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n 1", "output": "0\n \n\n* * *"}, {"input": "7 26\n 10\n 20\n 30\n 40\n 30\n 20\n 10", "output": "13"}]
Print the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K. * * *
s610410861
Accepted
p03703
Input is given from Standard Input in the following format: N K a_1 a_2 : a_N
import sys input = sys.stdin.buffer.readline import bisect def main(): N, K = map(int, input().split()) cum = [0] for _ in range(N): cum.append(cum[-1] + int(input()) - K) s_cum = sorted(cum) def invNumCount(A): l = len(A) res = 0 BIT = [0] * (l + 1) def BIT_query(idx): res_sum = 0 while idx > 0: res_sum += BIT[idx] idx -= idx & (-idx) return res_sum def BIT_update(idx, x): while idx <= l: BIT[idx] += x idx += idx & (-idx) return Ai = [None] * l for i, e in enumerate(A): Ai[e] = i for i, e in enumerate(Ai): res += i - BIT_query(e + 1) BIT_update(e + 1, 1) return res d = {} pos = [None] * (N + 1) for i, num in enumerate(cum): ind = bisect.bisect_left(s_cum, num) if num not in d: d[num] = 1 else: ind += d[num] d[num] += 1 pos[i] = N - ind print(invNumCount(pos)) if __name__ == "__main__": main()
Statement You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
[{"input": "3 6\n 7\n 5\n 7", "output": "5\n \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n * {a_1} = {7}\n * {a_1, a_2} = {7, 5}\n * {a_1, a_2, a_3} = {7, 5, 7}\n * {a_2} = {5}\n * {a_2, a_3} = {5, 7}\n * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n 1", "output": "0\n \n\n* * *"}, {"input": "7 26\n 10\n 20\n 30\n 40\n 30\n 20\n 10", "output": "13"}]
Print the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K. * * *
s368982795
Accepted
p03703
Input is given from Standard Input in the following format: N K a_1 a_2 : a_N
# Treap # 平衡二分木 乱数を用いてできるだけ平衡を保つらしい # priorityには乱数を入れること # d = 0: right rotation # d = 1: left rotation def rotate(nd, d): c = nd[d] if d: e = c[1] nd[1] = c[0] c[0] = nd else: e = c[0] nd[0] = c[1] c[1] = nd r = c[4] = nd[4] nd[4] = r - (e[4] if e else 0) - 1 return c # insert a node with key = val and priority = pri root = None def insert(val, pri): global root st = [] dr = [] x = root while x: st.append(x) if x[2] == val: return d = x[2] < val dr.append(d) x = x[d] # [<left>, <right>, <key>, <priority>, <count>] nd = [None, None, val, pri, 1] while st: x = st.pop() d = dr.pop() x[d] = nd x[4] += 1 if x[3] >= nd[3]: break rotate(x, d) else: root = nd for x in st: x[4] += 1 def __delete(nd): st = [] dr = [] while nd[0] or nd[1]: l = nd[0] r = nd[1] d = (l[3] <= r[3]) if l and r else (l is None) st.append(rotate(nd, d)) dr.append(d ^ 1) nd = x = None while st: nd = x x = st.pop() d = dr.pop() x[d] = nd x[4] -= 1 return x def delete(val): global root x = root st = [] y = None while x: if val == x[2]: break y = x d = x[2] < val st.append(y) x = x[d] else: return if y: y[d] = __delete(x) for x in st: x[4] -= 1 else: root = __delete(x) def find(val): global root x = root while x: if val == x[2]: return 1 x = x[x[2] < val] return 0 import random def small(val): global root x = root ans = 0 while x: if x[2] > val: x = x[0] elif x[2] < val: if x[0]: ans += x[0][4] + 1 else: ans += 1 x = x[1] return ans import random, sys input = sys.stdin.readline N, K = map(int, input().split()) A = [] for i in range(0, N): a = int(input()) - K A.append(a) for i in range(1, N): A[i] += A[i - 1] A = [0] + A A = [(A[i], i) for i in range(0, N + 1)] A.sort() A = [A[i][1] for i in range(0, N + 1)] ans = 0 for i in range(0, N + 1): ans += small(A[i]) insert(A[i], random.randint(0, 100000)) print(ans)
Statement You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
[{"input": "3 6\n 7\n 5\n 7", "output": "5\n \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n * {a_1} = {7}\n * {a_1, a_2} = {7, 5}\n * {a_1, a_2, a_3} = {7, 5, 7}\n * {a_2} = {5}\n * {a_2, a_3} = {5, 7}\n * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n 1", "output": "0\n \n\n* * *"}, {"input": "7 26\n 10\n 20\n 30\n 40\n 30\n 20\n 10", "output": "13"}]
Print the number of the non-empty contiguous subsequences with an arithmetic mean that is greater than or equal to K. * * *
s078241744
Accepted
p03703
Input is given from Standard Input in the following format: N K a_1 a_2 : a_N
from itertools import accumulate def init(As): numPow2 = 2 ** (len(As) - 1).bit_length() data = [0] * (numPow2 + 1) return data, numPow2 def addValue(iA, A): iA += 1 while iA <= numPow2: data[iA] += A iA += iA & -iA def getSum(iA): iA += 1 ans = 0 while iA > 0: ans += data[iA] iA -= iA & -iA return ans N, K = map(int, input().split()) As = [int(input()) for _ in range(N)] Bs = list(accumulate([0] + [A - K for A in As])) iBs = list(range(N + 1)) iBs.sort(key=lambda iB: Bs[iB]) data, numPow2 = init([0] * (N + 1)) ans = 0 for iB in iBs: addValue(iB, 1) ans += getSum(iB - 1) print(ans)
Statement You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
[{"input": "3 6\n 7\n 5\n 7", "output": "5\n \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n * {a_1} = {7}\n * {a_1, a_2} = {7, 5}\n * {a_1, a_2, a_3} = {7, 5, 7}\n * {a_2} = {5}\n * {a_2, a_3} = {5, 7}\n * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n 1", "output": "0\n \n\n* * *"}, {"input": "7 26\n 10\n 20\n 30\n 40\n 30\n 20\n 10", "output": "13"}]
Print the K-th lexicographically smallest substring of K. * * *
s398252060
Accepted
p03353
Input is given from Standard Input in the following format: s K
S = input() K = int(input()) alpha = set() for i in S: alpha.add(i) for i in range(len(S) - 1): alpha.add(S[i : i + 2]) for i in range(len(S) - 2): alpha.add(S[i : i + 3]) for i in range(len(S) - 3): alpha.add(S[i : i + 4]) for i in range(len(S) - 4): alpha.add(S[i : i + 5]) alpha = list(alpha) alpha.sort() print(alpha[K - 1])
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s486444999
Accepted
p03353
Input is given from Standard Input in the following format: s K
s = list(input()) k1 = int(input()) l1 = set() for i in range(len(s)): l1.add(s[i]) a1 = [] for i in range(len(l1)): a1.append(l1.pop()) a1.sort() for i in range(len(a1)): str = a1[i] l2 = set() for j in range(len(s)): if s[j] == str: l2.add(s[j]) str2 = s[j] for k in range(j + 1, min(len(s), j + 7)): str2 += s[k] l2.add(str2) if len(l2) >= k1: l3 = sorted(l2) ans = l3[k1 - 1] break else: k1 -= len(l2) print(ans)
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s844103524
Accepted
p03353
Input is given from Standard Input in the following format: s K
import sys import math results = set() s = sys.stdin.readline().strip() K = int(sys.stdin.readline().strip()) chars = set(list(s)) for c in sorted(list(chars)): t = s ss = set() while True: i = t.find(c) if i == -1: break ss.add(t[i:]) t = t[i + 1 :] for sa in sorted(list(ss)): for j in range(1, len(sa) + 1): results.add(sa[:j]) if len(results) == K: print(sa[:j]) quit()
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s458176134
Accepted
p03353
Input is given from Standard Input in the following format: s K
S = input() K = int(input()) val = "" A = set() for i, s in enumerate(S): val = "" for j in range(i, min(i + 5, len(S))): val += S[j] A.add(val) A_sort = sorted(list(A)) print(A_sort[K - 1])
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s742280009
Accepted
p03353
Input is given from Standard Input in the following format: s K
from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque, OrderedDict from copy import deepcopy from fractions import gcd from functools import lru_cache, reduce from math import ceil, floor from sys import setrecursionlimit import heapq import itertools import operator inf = float("inf") # globals S = "" K = 0 def set_inputs(): global S, K S = get_str() K = get_int() return def main(): setrecursionlimit(100000) set_inputs() # ----------MAIN---------- d = defaultdict(list) for i, s in enumerate(S): d[s].append(i) cnt = 0 for s in sorted(d.keys()): substrings = set(s) for i in d[s]: for ss in [S[i : i + k] for k in range(2, K + 1)]: substrings.add(ss) if cnt + len(substrings) >= K: print(list(sorted(substrings))[K - 1 - cnt]) return cnt += len(substrings) return def get_int(): return int(input()) def get_float(): return float(input()) def get_str(): return input().strip() def get_li(): return [int(i) for i in input().split()] def get_lf(): return [float(f) for f in input().split()] def get_lc(): return list(input().strip()) def get_data(n, types): if len(types) == 1: return [types[0](input()) for _ in range(n)] return zip(*([t(x) for t, x in zip(types, input().split())] for _ in range(n))) if __name__ == "__main__": main()
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s485837024
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
if __name__ == '__main__': s = input() K = int(input()) subs = [] for i in range(len(s)): for j in range(K): try: subs.append(s[i:i+j+1]) except: break subs = set(subs) print(sorted(list(subs))[K-1])
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s098432371
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
S = input() K = int(input()) target = [] def func(split_range): for i in range(0,len(S)-split_range+1): #print(S[0:0]) #print(S[0:1]) #print(S[i:i+split_range]) #print(S[i:i+split_range]) target.append(S[i:i+split_range]) for i in range(1,len(S)+1): #print(i) func(i) #print(target) print(sorted(set(target))[K-1]
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s737161773
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
str = input() lt = [] l = len(str) for s in range(l): for t in range(s:l): lt.append(slice[t:s]) ls = list(set(lt)) print(ls[3])
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s105326058
Wrong Answer
p03353
Input is given from Standard Input in the following format: s K
s = input() k = int(input()) d = [] n = len(s)
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s086734263
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
s = input() k = int(input()) sub = [] num = len(s) for i in range(num): for j in range(i, num): sub.append(s[i:j+1]) sub = list(set(sub)) sub.sort() print(sub
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s640983063
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
s = input() k = int(input()) st = set() for i in range(len(s)): for j in range(min(k, len(s)-i)) st.add(s[i:i+j]) for _ in range(k-1): m = min(st) st = [x for x in st if x != m] print(min(st))
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s402765281
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
s = input() n = input() ans = set([]) test = list(s) for i in range(len(test)): s = test[i] ans.add(s) for j in range(i+1, min(i+5, len(test)): s = s + test[j] ans.add(s) ans = list(ans) ans.sort() print(ans) print(ans[int(n)-1])
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]
Print the K-th lexicographically smallest substring of K. * * *
s155288409
Runtime Error
p03353
Input is given from Standard Input in the following format: s K
s = input() k = int(input()) st = set() for i in range(len(s)): for j in range(min(k, len(s)-i+1)) st.add(s[i:i+j]) for _ in range(k-1): m = min(st) st = [x for x in st if x != m] print(min(st))
Statement You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
[{"input": "aba\n 4", "output": "b\n \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n 5", "output": "andat\n \n\n* * *"}, {"input": "z\n 1", "output": "z"}]