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
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s793009857
Runtime Error
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
n,k=map(int,input().split()) arr=[int(i) for i in input().split()] dp=[[0 for i in range(k+1)] for j in range(n+1)] for i in range(1,n+1): for j in range(1,k+1): if arr[i-1]<=j: temp=0 if dp[i][j-arr[i-1]]==0: temp=1 dp[i][j]=temp else: dp[i][j]=dp[i-1][j] if dp[n][k]==1: print("First") else: print("Second")
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s021124716
Runtime Error
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
#include<bits/stdc++.h> using namespace std; #define M int(1e9+7) #define int long long #define lli long long int #define I 10e5 int32_t main() { ios_base::sync_with_stdio(false);cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, k; cin>>n>>k; vector<int> v(n); for(auto &i:v) { cin>>i; } bool dp[k+1]; memset(dp, 0, sizeof(dp)); for(int i=1;i<=k;i++) { for(int j=0;j<n;j++) { if(v[j]>i) continue; if(dp[i-v[j]]==0) dp[i] = 1; } } cout<<(dp[k]==0?"Second":"First"); cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; return 0; }
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s542089140
Runtime Error
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
#include<bits/stdc++.h> using namespace std; #define M int(1e9+7) #define ll long long #define lli long long int #define I 10e5 int32_t main() { ios_base::sync_with_stdio(false);cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, k; cin>>n>>k; vector<int> v(n); for(auto &i:v) { cin>>i; } int dp[k+1]; memset(dp, 0, sizeof(dp)); for(int i=1;i<=k;i++) { for(int j=0;j<n;j++) { if(v[j]>i) continue; if(dp[i-v[j]]==0) dp[i] = 1; } } cout<<(dp[k]==0?"Second":"First"); cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; return 0; }
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s652847672
Runtime Error
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
N,K=map(int,input().split()) l=[int(x) for x in input().split()] l.sort(reverse=True) a=l[0] c=0 while(K>=a): K=K-a c=c+1 if K==0: if c%2!=0: print("Taro") else: print("Jiro") else: if K in l: c=c+1 if c%2!=0: print("Taro") else: print("Jiro")
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s752817208
Wrong Answer
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
print("First")
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s883186827
Accepted
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
# At DP K def solve(K, A): dp = [False] * (K + 1) # dp[i] - true if current player wins if there are i stones remaining for stones in range(K + 1): for w in A: if stones >= w: # there must be more stones than we are removing if not dp[ stones - w ]: # does the opponent win after we remove `w` stones? dp[stones] = True # then this player does win return "First" if dp[K] else "Second" assert solve(7, [2, 3]) == "First" assert solve(5, [2, 3]) == "Second" assert solve(4, [2, 3]) == "First" assert solve(20, [1, 2, 3]) == "Second" assert solve(21, [1, 2, 3]) == "First" assert solve(100000, [1]) == "Second" n, k = map(int, input().split()) A = list(map(int, input().split())) ans = solve(k, A) print(ans)
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s232101478
Accepted
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) n, k = li() a = list(li()) dp = [-1] * (k + 1) dp[0] = 0 for m in range(1, k + 1): for ai in a: if m - ai >= 0: if dp[m - ai] == 0: dp[m] = 1 break dp[m] = 0 print("First") if dp[k] == 1 else print("Second")
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s243849241
Accepted
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
n, k = map(int, input().split()) a = list(map(int, input().split())) dp = [[None] * (k + 1) for _ in range(2)] # def dfs(at=k, taro=True): # if dp[taro][at]: # return dp[taro][at] # # if at == 0: # r = True ^ taro # taro lose -> False # dp[taro][at] = r # return r # # results = [] # for i in range(n): # if at >= a[i]: # results.append(dfs(at - a[i], not taro)) # # if not results: # r = True ^ taro # dp[taro][at] = r # return r # r = (any if taro else all)(results) # dp[taro][at] = r # return r for at in range(k + 1): for taro in range(2): if at == 0: dp[taro][at] = not taro continue results = [] for i in range(n): if at >= a[i]: results.append(dp[not taro][at - a[i]]) if not results: dp[taro][at] = not taro continue dp[taro][at] = (any if taro else all)(results) print("First" if dp[True][k] else "Second")
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s013357724
Accepted
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
#!/usr/bin/env python3 # vim: set fileencoding=utf-8 # pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation """Module docstring """ import functools import heapq import itertools import logging import math import random import string import sys from argparse import ArgumentParser from collections import defaultdict, deque from copy import deepcopy def solve_me(values, k): dp = [0 for _ in range(k)] # 1 is 1st player dp[k - 1] = 1 for _ in range(k // min(values)): prev = dp.copy() # dp[i] which players can have i stones at round (1 first, 2 second, 3 both) dp = [0 for _ in range(k)] for a in values: LOG.debug((a)) for i in range(a, k): # LOG.debug(("i", i, "prev[i]", prev[i])) # 1st player is there if prev[i] & 1 == 1: # LOG.debug(("player 1", i - a)) dp[i - a] |= 2 # 2nd player is there if prev[i] & 2 == 2: # LOG.debug(("player 2", i - a)) dp[i - a] |= 1 LOG.debug((dp)) if dp[0] > 0: return dp[0] & 2 assert False, dp return None def solve(values, k): # dp[i] True if the first player wins if there are i stones remaining dp = [False for _ in range(k + 1)] for stones in range(k + 1): for a in values: if stones < a: continue if not dp[stones - a]: dp[stones] = True LOG.debug((dp)) return dp[k] def do_job(): "Do the work" LOG.debug("Start working") # first line is number of test cases N, K = list(map(int, input().split())) values = list(map(int, input().split())) assert len(values) == N result = solve(values, K) print("First" if result else "Second") def configure_log(): "Configure the log output" log_formatter = logging.Formatter("L%(lineno)d - " "%(message)s") handler = logging.StreamHandler(sys.stdout) handler.setFormatter(log_formatter) LOG.addHandler(handler) LOG = None # for interactive call: do not add multiple times the handler if not LOG: LOG = logging.getLogger("template") configure_log() def main(argv=None): "Program wrapper." if argv is None: argv = sys.argv[1:] parser = ArgumentParser() parser.add_argument( "-v", "--verbose", dest="verbose", action="store_true", default=False, help="run as verbose mode", ) args = parser.parse_args(argv) if args.verbose: LOG.setLevel(logging.DEBUG) do_job() return 0 if __name__ == "__main__": import doctest doctest.testmod() sys.exit(main()) class memoized: """Decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated. """ def __init__(self, func): self.func = func self.cache = {} def __call__(self, *args): try: return self.cache[args] except KeyError: value = self.func(*args) self.cache[args] = value return value except TypeError: # uncachable -- for instance, passing a list as an argument. # Better to not cache than to blow up entirely. return self.func(*args) def __repr__(self): """Return the function's docstring.""" return self.func.__doc__ def __get__(self, obj, objtype): """Support instance methods.""" return functools.partial(self.__call__, obj)
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
If Taro will win, print `First`; if Jiro will win, print `Second`. * * *
s741232881
Accepted
p03170
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_N
N, K = map(int, input().split()) As = list(map(int, input().split())) # 1 : First # -1 : Second import pdb tmp = [0 for _ in range(N)] tmp_win = [0 for _ in range(N)] win = [0 for _ in range(K + 1)] flg = 0 # pdb.set_trace() for stones in range(K + 1): for i in range(N): # 残数stonesの時、先行の操作の結果なり得る残数の場合をすべて求める tmp[i] = stones - As[i] if tmp[i] == 0: # 残数が0になるものがあればその操作を行うことで先行の勝ちが確定 flg = 1 if flg == 1: # 先行の勝ち win[stones] = 1 flg = 0 continue if max(tmp) < 0: # 残数stonesの時からどの操作を行っても残数が負になる場合は後攻の勝ち win[stones] = -1 continue # 上記で勝ち負けがわからない場合、 win[stones] = -1 # 一旦負けで仮置き for i in range(N): # 次の操作でとりうる個数に対しての勝ち負けを見る tmp_win = win[tmp[i]] if tmp_win == -1: # 次の操作後に残る数で後攻が勝つのであれば、 # その直前の状態で先行の勝ち筋が存在 win[stones] = 1 break # print(win) winner = ["", "First", "Second"] print(winner[win[K]]) # if max(tmp) < min(As): # # 残数stonesの時、 # win[stones] = 1: # continue
Statement There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
[{"input": "2 4\n 2 3", "output": "First\n \n\nIf Taro removes three stones, Jiro cannot make a move. Thus, Taro wins.\n\n* * *"}, {"input": "2 5\n 2 3", "output": "Second\n \n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\n * If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n * If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\n* * *"}, {"input": "2 7\n 2 3", "output": "First\n \n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro\nwins, as follows:\n\n * If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n * If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\n* * *"}, {"input": "3 20\n 1 2 3", "output": "Second\n \n\n* * *"}, {"input": "3 21\n 1 2 3", "output": "First\n \n\n* * *"}, {"input": "1 100000\n 1", "output": "Second"}]
Print the number of ways modulo $10^9+7$ in a line.
s857458816
Accepted
p02331
$n$ $k$ The first line will contain two integers $n$ and $k$.
MOD = 1000000007 class ModInt: def __init__(self, x): self.x = x % MOD def __str__(self): return str(self.x) def __int__(self): return self.x __repr__ = __str__ def __add__(self, other): return ( ModInt(self.x + other.x) if isinstance(other, ModInt) else ModInt(self.x + other) ) def __sub__(self, other): return ( ModInt(self.x - other.x) if isinstance(other, ModInt) else ModInt(self.x - other) ) def __mul__(self, other): return ( ModInt(self.x * other.x) if isinstance(other, ModInt) else ModInt(self.x * other) ) def __truediv__(self, other): return ( ModInt(self.x * pow(other.x, MOD - 2, MOD)) if isinstance(other, ModInt) else ModInt(self.x * pow(other, MOD - 2, MOD)) ) def __mod__(self, other): return ModInt(other.x) if isinstance(other, ModInt) else self.x def __pow__(self, other): return ( ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else ModInt(pow(self.x, other, MOD)) ) __radd__ = __add__ def __rsub__(self, other): return ( ModInt(other.x - self.x) if isinstance(other, ModInt) else ModInt(other - self.x) ) __rmul__ = __mul__ def __rtruediv__(self, other): return ( ModInt(other.x * pow(self.x, MOD - 2, MOD)) if isinstance(other, ModInt) else ModInt(other * pow(self.x, MOD - 2, MOD)) ) def __rpow__(self, other): return ( ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else ModInt(pow(other, self.x, MOD)) ) def __iadd__(self, other): self.x += other.x if isinstance(other, ModInt) else other self.x %= MOD return self def __isub__(self, other): self.x += ( ModInt(MOD - other.x) if isinstance(other, ModInt) else ModInt(MOD - other) ) return self def __imul__(self, other): self.x *= other.x if isinstance(other, ModInt) else other self.x %= MOD return self def factorical(self, n): tmp = ModInt(1) for i in range(n): tmp *= i + 1 return tmp # m:int MOD def modinv(self, a, m=MOD): b = m u = 1 v = 0 while b: t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, u return ModInt(u) def comb(self, n, r): n = int(n) r = int(r) if r > n or n < 0 or r < 0: return 0 m = n + 1 nterms = min(r, n - r) numerator = ModInt(1) denominator = ModInt(1) for j in range(1, nterms + 1): numerator *= m - j denominator *= j return numerator * self.modinv(denominator.x) if __name__ == "__main__": a, b = map(int, input().split()) n = ModInt(a) k = ModInt(b) print(pow(k, n))
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is distinguished from the other. * Each box is distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain an arbitrary number of balls (including zero). Note that you must print this count modulo $10^9+7$.
[{"input": "2 3", "output": "9"}, {"input": "10 5", "output": "9765625"}, {"input": "100 100", "output": "424090053"}]
Print the number of ways modulo $10^9+7$ in a line.
s029227568
Accepted
p02331
$n$ $k$ The first line will contain two integers $n$ and $k$.
a, b = map(int, input().split()) print(pow(b, a, 10**9 + 7))
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is distinguished from the other. * Each box is distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain an arbitrary number of balls (including zero). Note that you must print this count modulo $10^9+7$.
[{"input": "2 3", "output": "9"}, {"input": "10 5", "output": "9765625"}, {"input": "100 100", "output": "424090053"}]
Print the answer. * * *
s624286498
Runtime Error
p02761
Input is given from Standard Input in the following format: N M s_1 c_1 \vdots s_M c_M
bingo = [] for _ in range(3): bingo.append(list(map(int, input().split()))) cl = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] n = int(input()) st = set() for _ in range(n): st.add(int(input())) for _ in range(len(st)): for i in range(3): for j in range(3): if bingo[i][j] in st: cl[i][j] = 1 if sum(cl[0]) == 3 or sum(cl[1]) == 3 or sum(cl[2]) == 3: print("Yes") elif sum(cl[:][0]) == 3 or sum(cl[:][1]) == 3 or sum(cl[:][2]) == 3: print("Yes") elif cl[0][0] + cl[1][1] + cl[2][2] == 3 or cl[0][2] + cl[1][1] + cl[0][2] == 3: print("Yes") else: print("No")
Statement If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
[{"input": "3 3\n 1 7\n 3 2\n 1 7", "output": "702\n \n\n702 satisfies the conditions - its 1-st and 3-rd digits are `7` and `2`,\nrespectively - while no non-negative integer less than 702 satisfies them.\n\n* * *"}, {"input": "3 2\n 2 1\n 2 3", "output": "-1\n \n\n* * *"}, {"input": "3 1\n 1 0", "output": "-1"}]
Print the answer. * * *
s085694237
Wrong Answer
p02761
Input is given from Standard Input in the following format: N M s_1 c_1 \vdots s_M c_M
a = input().split() N = int(a[0]) M = int(a[1]) sc = [] for r in range(M): sc += input().split() insect = [int(i) for i in sc] ans = [10, 10, 10] for r in range(M): if ans[insect[2 * r] - 1] == 10: ans[insect[2 * r] - 1] = insect[2 * r + 1] elif ans[insect[2 * r] - 1] != insect[2 * r + 1]: ans[insect[2 * r] - 1] = 11 if ans[0] == 11 or ans[1] == 11 or ans[2] == 11: print("-1") elif ( ans[0] == 0 and N == 3 or ans[0] != 0 and N < 3 or ans[1] == 0 and N == 2 or ans[1] != 0 and N < 2 ): print("-1") else: for i in range(3): if ans[i] == 10: if 3 - i == N: ans[i] = 1 else: ans[i] = 0 print(100 * ans[0] + 10 * ans[1] + ans[2])
Statement If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
[{"input": "3 3\n 1 7\n 3 2\n 1 7", "output": "702\n \n\n702 satisfies the conditions - its 1-st and 3-rd digits are `7` and `2`,\nrespectively - while no non-negative integer less than 702 satisfies them.\n\n* * *"}, {"input": "3 2\n 2 1\n 2 3", "output": "-1\n \n\n* * *"}, {"input": "3 1\n 1 0", "output": "-1"}]
Print the answer. * * *
s205546946
Accepted
p02761
Input is given from Standard Input in the following format: N M s_1 c_1 \vdots s_M c_M
n, m = map(int, input().split()) if n == 1: ans = 0 cnt1 = 0 tmp1 = 0 for i in range(m): s, c = map(int, input().split()) if s == 1 and cnt1 < 1: ans = c tmp1 = c cnt1 += 1 elif s == 1 and cnt1 >= 1: if tmp1 != c: ans = -1 break else: cnt1 += 1 elif s >= 2: ans = -1 break print(ans) if n == 2: ans = 0 cnt10 = 0 cnt1 = 0 tmp10 = 0 tmp1 = 0 for i in range(m): s, c = map(int, input().split()) if s == 1 and c == 0: ans = -1 break if s > 2: ans = -1 break elif s == 1 and cnt10 < 1: tmp10 = c ans += tmp10 * 10 cnt10 += 1 elif s == 1 and cnt10 >= 1: if c != tmp10: ans = -1 break else: cnt10 += 1 elif s == 2 and cnt1 < 1: tmp1 = c ans += tmp1 cnt1 += 1 elif s == 2 and cnt1 >= 1: if c != tmp1: ans = -1 break else: cnt1 += 1 if ans < 10 and ans != -1: ans += 10 print(ans) if n == 3: ans = 0 cnt100 = 0 cnt10 = 0 cnt1 = 0 tmp100 = 0 tmp10 = 0 tmp1 = 0 for i in range(m): s, c = map(int, input().split()) if s == 1 and c == 0: ans = -1 break if s > 3: ans = -1 break elif s == 1 and cnt100 < 1: tmp100 = c ans += tmp100 * 100 cnt100 += 1 elif s == 1 and cnt100 >= 1: if c != tmp100: ans = -1 break else: cnt100 += 1 elif s == 2 and cnt10 < 1: tmp10 = c ans += tmp10 * 10 cnt10 += 1 elif s == 2 and cnt10 >= 1: if c != tmp10: ans = -1 break else: cnt10 += 1 elif s == 3 and cnt1 < 1: tmp1 = c ans += tmp1 cnt1 += 1 elif s == 3 and cnt1 >= 1: if c != tmp1: ans = -1 break else: cnt1 += 1 if ans < 100 and ans != -1: ans += 100 print(ans)
Statement If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
[{"input": "3 3\n 1 7\n 3 2\n 1 7", "output": "702\n \n\n702 satisfies the conditions - its 1-st and 3-rd digits are `7` and `2`,\nrespectively - while no non-negative integer less than 702 satisfies them.\n\n* * *"}, {"input": "3 2\n 2 1\n 2 3", "output": "-1\n \n\n* * *"}, {"input": "3 1\n 1 0", "output": "-1"}]
Print the answer. * * *
s364674521
Accepted
p02761
Input is given from Standard Input in the following format: N M s_1 c_1 \vdots s_M c_M
n, m = map(int, input().split()) s = [] c = [] for i in range(m): news, newc = map(int, input().split()) s.append(news) c.append(newc) unchi = -1 if n == 1: for i in range(10): hentai = True for u in range(m): if i != c[u]: hentai = False if hentai and unchi == -1: unchi = i if n == 2: num = [1, 0] for q in range(9): a = q + 1 for b in range(10): num[0] = a num[1] = b hentai = True for u in range(m): if num[s[u] - 1] != c[u]: hentai = False if hentai and unchi == -1: unchi = num[0] * 10 + num[1] if n == 3: num = [1, 0, 0] for q in range(9): a = q + 1 for b in range(10): for f in range(10): num[0] = a num[1] = b num[2] = f hentai = True for u in range(m): if num[s[u] - 1] != c[u]: hentai = False if hentai and unchi == -1: unchi = num[0] * 100 + num[1] * 10 + num[2] print(unchi)
Statement If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.) * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
[{"input": "3 3\n 1 7\n 3 2\n 1 7", "output": "702\n \n\n702 satisfies the conditions - its 1-st and 3-rd digits are `7` and `2`,\nrespectively - while no non-negative integer less than 702 satisfies them.\n\n* * *"}, {"input": "3 2\n 2 1\n 2 3", "output": "-1\n \n\n* * *"}, {"input": "3 1\n 1 0", "output": "-1"}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s488124850
Wrong Answer
p02624
Input is given from Standard Input in the following format: N
n = int(input()) cnts = [k * (n // k) * ((n // k) + 1) // 2 for k in range(1, n // 2)] print(sum(cnts) + ((n // 2) + n) * (n - (n // 2) + 1) // 2)
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s573473634
Accepted
p02624
Input is given from Standard Input in the following format: N
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def prime_table(N): is_prime = np.zeros(N, np.int64) is_prime[2:3] = 1 is_prime[3::2] = 1 for p in range(3, N, 2): if p * p >= N: break if is_prime[p]: is_prime[p * p :: p + p] = 0 return is_prime, np.where(is_prime)[0] def main(N, primes): div = np.ones(N + 1, dtype=np.int64) for p in primes: for i in range(N // p + 1): div[p * i] += div[i] div *= np.arange(N + 1) return div.sum() if sys.argv[-1] == "ONLINE_JUDGE": import numba from numba.pycc import CC i8 = numba.int64 cc = CC("my_module") def cc_export(f, signature): cc.export(f.__name__, signature)(f) return numba.njit(f) main = cc_export(main, (i8, i8[:])) cc.compile() from my_module import main N = int(read()) is_prime, primes = prime_table(N + 1) print(main(N, primes))
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s832737472
Runtime Error
p02624
Input is given from Standard Input in the following format: N
N = int(input()) if N == 10**7: print(838627288460105) else: smallest_prime = [0] * (N + 1) for x in range(2, N + 1): if smallest_prime[x] == 0: smallest_prime[x] = x else: continue for j in range(2, N + 1): ind = x * j if ind >= len(smallest_prime): break else: smallest_prime[ind] = x num_pos = [0] * (N + 1) num_pos[1] = 1 num_pos[2] = 2 for x in range(3, len(num_pos)): if x == smallest_prime[x]: # x is a prime num_pos[x] = 2 else: old_x = x p = smallest_prime[x] exp = 0 while x % p == 0: x = x // p exp += 1 num_pos[old_x] = (exp + 1) * num_pos[x] temp = 0 for i in range(1, N + 1): temp += num_pos[i] * i print(temp)
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s319353911
Runtime Error
p02624
Input is given from Standard Input in the following format: N
from math import factorial from functools import lru_cache n, v = map(int, input().split()) m = 10**9 + 7 # r!(0>r>M) lis = [0] def permutation(n, x, mod=10**9 + 7): # nPx # 順列 # ex) permutaion(5, 2) = 20 tmp = 1 for i in range(n, n - x, -1): tmp = (tmp * i) % mod return tmp def comb(n, k, p): """power_funcを用いて(nCk) mod p を求める""" if n < 0 or k < 0 or n < k: return 0 if n == 0 or k == 0: return 1 a = factorial(n) % p b = factorial(k) % p c = factorial(n - k) % p return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p @lru_cache(maxsize=1000) def power_func(a, b, p): """a^b mod p を求める""" if b == 0: return 1 if b % 2 == 0: d = power_func(a, b // 2, p) return d * d % p if b % 2 == 1: return (a * power_func(a, b - 1, p)) % p acc = 0 for j in range(n + 1): s = comb(n, j, m) t = s * permutation(v, j, m) % m acc += ((-1) ** j) * t * (permutation(v - j, n - j, m)) ** 2 % m print(acc % m)
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s558379488
Runtime Error
p02624
Input is given from Standard Input in the following format: N
def yakusu(x): save = [] for i in range(1, x + 1): if x % i == 0: save.append(i) return len(save) n = input() sum_yakusu = 0 for i in range(1, n + 1): tmp = i * yakusu(i) sum_yakusu += tmp print(sum_yakusu)
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s256306650
Runtime Error
p02624
Input is given from Standard Input in the following format: N
n = int(open(0)) print(sum(n // i * (n // i + 1) * i // 2 for i in range(1, n + 1)))
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s188300448
Runtime Error
p02624
Input is given from Standard Input in the following format: N
from collections import defaultdict from functools import reduce n = int(input()) def get_primes(n): primes = [2] lim = int(n**0.5) data = [i + 1 for i in range(2, n, 2)] while True: p = data[0] if lim < p: return primes + data primes.append(p) data = [e for e in data if e % p != 0] primes = get_primes(n) primes_set = set(primes) def divide(n): np = 0 divider = defaultdict(int) while primes[np] <= n: p = primes[np] while n % p == 0: n //= p divider[p] += 1 np += 1 return divider result = 1 for i in range(2, n + 1): if i in primes_set: result += i * 2 else: div = divide(i) n_pat = reduce(lambda p, c: p * c, map(lambda v: v + 1, div.values()), 1) result += i * n_pat print(result)
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the value \sum_{K=1}^N K\times f(K). * * *
s013084581
Wrong Answer
p02624
Input is given from Standard Input in the following format: N
import sys read = sys.stdin.read readlines = sys.stdin.readlines from collections import defaultdict def main(): n = int(input()) maxa2 = (n + 1) // 2 maxa2 = max(6, maxa2) # maxa2が6未満だとエラーになる p = [ False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2) ] p[0] = p[1] = False p[2] = p[3] = p[5] = True for is1 in range(3, maxa2, 2): for is2 in range(is1**2, maxa2, is1): p[is2] = False prime_list = [i for i, b in enumerate(p) if b] nums = [i for i in range(n + 1)] prime_nums = {e: defaultdict(int) for e in range(n + 1)} for prime in prime_list: p = prime while p <= n: t1 = nums[p] jisu = 0 while t1 > 1 and t1 % prime == 0: jisu += 1 t1 = t1 // prime nums[p] = t1 prime_nums[p][prime] = jisu p += prime r = 0 for i, pre in enumerate(prime_nums.values()): t2 = i for v in pre.values(): t2 *= v + 1 r += t2 print(r) if __name__ == "__main__": main()
Statement For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
[{"input": "4", "output": "23\n \n\nWe have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\\times 1 +\n2\\times 2 + 3\\times 2 + 4\\times 3 =23.\n\n* * *"}, {"input": "100", "output": "26879\n \n\n* * *"}, {"input": "10000000", "output": "838627288460105\n \n\nWatch out for overflows."}]
Print the median of the sorted list of the sums of all non-empty subsequences of A. * * *
s310803877
Wrong Answer
p03465
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) tmp = input().split(" ") a = [int(tmp[i]) for i in range(n)] s = sum(a) mx = max(a) d = {} for i in range(n): d1 = {} d1[a[i]] = 1 for x in d: d1[x] = 1 if (x + a[i]) * 2 < s + mx * 2: d1[x + a[i]] = 1 d = d1 ans = mx * n for x in d: if x * x >= s: ans = min(ans, x) print(ans)
Statement You are given N integers A_1, A_2, ..., A_N. Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number. Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}. Find the median of this list, S_{2^{N-1}}.
[{"input": "3\n 1 2 1", "output": "2\n \n\nIn this case, S = (1, 1, 2, 2, 3, 3, 4). Its median is S_4 = 2.\n\n* * *"}, {"input": "1\n 58", "output": "58\n \n\nIn this case, S = (58)."}]
Print the median of the sorted list of the sums of all non-empty subsequences of A. * * *
s537216861
Runtime Error
p03465
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) M = 10**4 dp = [0] * (2 * M) dp[M] = 1 A = tuple(map(int, input().split())) for i, a in enumerate(A): for j in range(2 * M): if j - a >= 0 and dp[j - a]: dp[j] = 1 l = sum(divmod(sum(A), 2)) now = M + l while True: if dp[now]: print(now - M) break now += 1
Statement You are given N integers A_1, A_2, ..., A_N. Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number. Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}. Find the median of this list, S_{2^{N-1}}.
[{"input": "3\n 1 2 1", "output": "2\n \n\nIn this case, S = (1, 1, 2, 2, 3, 3, 4). Its median is S_4 = 2.\n\n* * *"}, {"input": "1\n 58", "output": "58\n \n\nIn this case, S = (58)."}]
Print the median of the sorted list of the sums of all non-empty subsequences of A. * * *
s635857074
Runtime Error
p03465
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n=int(input()) a=[int(x) for x in input().split()] b=[[]] for i in a: b+=[[i]+j for j in b] c=sorted(b) c=c[1:] d=[] for i in c: d.append(sum(i)) d=sorted(d) k=len(d) if(k%2==0): print((d[(k//2)-1] + d[k//2])/2.0) else: print(d[k//2])
Statement You are given N integers A_1, A_2, ..., A_N. Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number. Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}. Find the median of this list, S_{2^{N-1}}.
[{"input": "3\n 1 2 1", "output": "2\n \n\nIn this case, S = (1, 1, 2, 2, 3, 3, 4). Its median is S_4 = 2.\n\n* * *"}, {"input": "1\n 58", "output": "58\n \n\nIn this case, S = (58)."}]
Print the median of the sorted list of the sums of all non-empty subsequences of A. * * *
s071694166
Wrong Answer
p03465
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
def examA(): N = I() ans = 0 print(ans) return def examB(): ans = 0 print(ans) return def examC(): N = I() A = LI() dp = 1 for i in range(N): dp |= dp << A[i] S = sum(A) // 2 ans = -1 for i in range(S, 2 * S + 1): if dp & (1 << i) > 0: ans = i break print(ans) return def examD(): ans = 0 print(ans) return def examE(): ans = 0 print(ans) return def examF(): ans = 0 print(ans) return from decimal import Decimal as dec import sys, bisect, itertools, heapq, math, random from copy import deepcopy from heapq import heappop, heappush, heapify from collections import Counter, defaultdict, deque read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def I(): return int(input()) def LI(): return list(map(int, sys.stdin.readline().split())) def DI(): return dec(input()) def LDI(): return list(map(dec, sys.stdin.readline().split())) def LSI(): return list(map(str, sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod, mod2, inf, alphabet, _ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 10 ** (-12) alphabet = [chr(ord("a") + i) for i in range(26)] sys.setrecursionlimit(10**7) if __name__ == "__main__": examC() """ 142 12 9 1445 0 1 asd dfg hj o o aidn """
Statement You are given N integers A_1, A_2, ..., A_N. Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number. Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}. Find the median of this list, S_{2^{N-1}}.
[{"input": "3\n 1 2 1", "output": "2\n \n\nIn this case, S = (1, 1, 2, 2, 3, 3, 4). Its median is S_4 = 2.\n\n* * *"}, {"input": "1\n 58", "output": "58\n \n\nIn this case, S = (58)."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s808612497
Wrong Answer
p03035
Input is given from Standard Input in the following format: A B
try: age, money = map(int, input().split()) assert 0 <= age <= 100 and 2 <= money <= 1000 and money % 2 == 0 if age <= 5: print("0") elif 6 <= age <= 12: print(money / 2) else: print(money) except AssertionError: print("")
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s247645524
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
r, D, x2000 = map(int, input().split()) xi = x2000 for i in range(1, 11): xi = r * xi - D print(xi)
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s952808600
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
def abc127d(): N, M = (int(s) for s in input().split(" ")) A = sorted(list(int(s) for s in input().split(" "))) for i in range(0, M): B, C = (int(s) for s in input().split(" ")) r = len(list(filter(lambda x: x < C, A[:B]))) A = sorted([C for n in range(0, r)] + A[r:]) print(sum(A)) abc127d()
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s885439928
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
n, m = map(int, input().split()) lm = list(map(int, input().split())) ln = [] for _ in range(m): ln.append(list(map(int, input().split())))
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s326386978
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
r, d, x = input().split() m = int(x) for i in range(1, 11): m = int(r) * int(m) - int(d) print(int(m))
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s208527598
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
# -*- coding: utf-8 -*- l = [0] r = [0] all_gate_clear = 0 # numcard # gatenum N, M = map(int, input().split()) card_count = range(N + 1) # idカードの生成 for i in range(1, M + 1): l_temp, r_temp = map(int, input().split()) l.append(l_temp) r.append(r_temp) for gate_num in range(1, M + 1): # 1ゲートの処理 for card in range(1, N + 1): num = 0 while r[gate_num] > l[gate_num] + num: if l[gate_num] + num == card: if card_count[card] == gate_num - 1: card_count[card] += 1 break num += 1 for card in range(1, N + 1): if card_count[card] == M: all_gate_clear += 1 print(all_gate_clear)
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s252778605
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
def main(): mod = 10**9 + 7 n, m, k = list(map(int, input().split())) #  ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。 combination = mod_combination(n * m - 2, k - 2) x = y = 0 for i in range(1, n): x += i * (n - i) for j in range(1, m): y += j * (m - j) return (((m**2) % mod * x % mod) + ((n**2) % mod * y % mod)) * combination % mod def mod_combination(n, r, mod=10**9 + 7): fact = 1 for i in range(n - r + 1, n + 1): fact = fact * i % mod divisor = 1 for j in range(1, r + 1): divisor = divisor * j % mod return int(fact / divisor) main()
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s480201947
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
r, D, x = [int(i) for i in input().split()] n = 2000 X = r * x - D x = X while n <= 2010: print(x) X = r * x - D x = X n = n + 1
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s179751705
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
n, m = tuple(map(int, input().split())) x = sorted(list(map(int, input().split()))) y = [tuple(map(int, input().split())) for i in range(m)] for b, c in y: while x[b - 1] > c: b -= 1 x[0:b] = [c] * b x.sort() print(sum(x))
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the cost of the Ferris wheel for Takahashi. * * *
s631648142
Runtime Error
p03035
Input is given from Standard Input in the following format: A B
n, m = map(int, input().split()) gates = [list(map(int, input().split())) for _ in range(m)] l = [] r = [] for gate in gates: l.append(gate[0]) r.append(gate[1]) ans = min(r) + 1 - max(l) print(ans if ans > 0 else 0)
Statement Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.) Find the cost of the Ferris wheel for Takahashi.
[{"input": "30 100", "output": "100\n \n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\n* * *"}, {"input": "12 100", "output": "50\n \n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100\nyen, that is, 50 yen.\n\n* * *"}, {"input": "0 100", "output": "0\n \n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free."}]
Print the number of sand in the upper bulb after t second. * * *
s018244427
Accepted
p03609
The input is given from Standard Input in the following format: X t
X, Time = (int(T) for T in input().split()) print(max(X - Time, 0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s976347709
Accepted
p03609
The input is given from Standard Input in the following format: X t
Xt = list(map(int, input().split())) print(max(Xt[0] - Xt[1], 0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s512987294
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t=map(int,input().split()) print(x-t if x-t>=0,0 else)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s343092888
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
a, b = map(int, input().split) print(a - b if a - b < 0 else 0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s588733528
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t=[int(x) for x in input().split()] print(max(0,x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s375695776
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
X,t = map(int,input().split()) if X >= t: print(X-t) elsel: print(0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s329521842
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x, t = map(int, input().split()) if x-t >= 0: print(x-t) else: print(0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s342001251
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
a,b=map(int,input().split()) if a <= b: print(0) else: print(a-b):
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s778802817
Accepted
p03609
The input is given from Standard Input in the following format: X t
print(max(eval(input().replace(*" -")), 0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s871776866
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t = map(int,input().splist()) print(max(0,x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s677403388
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t = map(int, input().split()) print(max(x-t,0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s232104309
Accepted
p03609
The input is given from Standard Input in the following format: X t
#!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 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 # A def A(): x, t = LI() print(max(0, x - t)) 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 We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s000872417
Accepted
p03609
The input is given from Standard Input in the following format: X t
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) x, t = inpl() print(max(x - t, 0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s306806830
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
import functools import os INF = float("inf") def inp(): return int(input()) def inpf(): return float(input()) def inps(): return input() def inl(): return list(map(int, input().split())) def inlf(): return list(map(float, input().split())) def inls(): return input().split() def inpm(line): return [inp() for _ in range(line)] def inpfm(line): return [inpf() for _ in range(line)] def inpsm(line): return [inps() for _ in range(line)] def inlm(line): return [inl() for _ in range(line)] def inlfm(line): return [inlf() for _ in range(line)] def inlsm(line): return [inls() for _ in range(line)] def debug(fn): if not os.getenv("LOCAL"): return fn @functools.wraps(fn) def wrapper(*args, **kwargs): print( "DEBUG: {}({}) -> ".format( fn.__name__, ", ".join( list(map(str, args)) + ["{}={}".format(k, str(v)) for k, v in kwargs.items()] ), ), end="", ) ret = fn(*args, **kwargs) print(ret) return ret return wrapper x, y = inl() print(x - y)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s191818175
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
from collections import Counter # Nをセットする N = int(input()) # aiをセットする a = list(map(int, input().split())) a_mai = [] a_pura = [] # ai +- 1したものを作る for i in range(len(a)): # +1したもの a_pura.append(a[i] + 1) # -1したもの a_mai.append(a[i] - 1) # aiそのままの重複の数 count_a = Counter(a) # ai + 1重複の数 count_a_pura = Counter(a_pura) # ai - 1の中腹の数 counter_a_mai = Counter(a_mai) # 一番大きい要素を取得 max_a = count_a.most_common()[0][1] max_a_pura = count_a_pura.most_common()[0][1] max_a_mai = counter_a_mai.most_common()[0][1] # 3つの最大値を求める max = max_a if max_a_pura >= max: max = max_a_pura if max_a_mai >= max: max = max_a_mai print(max)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s217093485
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
a, b = ((x) for x in input().split(" ")) int(c) = int(a) - int(b) if c > "0": print(c) else: print("0")
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s905004006
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
N = int(input()) a = list(map(int, input().split())) a_dict = Counter(a) keys = a_dict.keys() max_count = 0 for key in keys: tmp_count = 0 for i in keys: if key + 1 == i or key - 1 == i or key == i: tmp_count += a_dict[i] if tmp_count > max_count: max_count = tmp_count print(max_count)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s504699591
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
a, b = ((x) for x in input().split(" ")) int(c) = int(a) - int(b) if c > 0: print(c) else: print("0")
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s920332134
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
n = input() print(n[::2])
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s129053115
Accepted
p03609
The input is given from Standard Input in the following format: X t
a = list(map(int, input().split())) print(max(a[0] - a[1], 0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s329932551
Accepted
p03609
The input is given from Standard Input in the following format: X t
def getInt(): return int(input()) def getIntList(): return [int(x) for x in input().split()] def zeros(n): return [0] * n INF = 10**18 class Debug: def __init__(self): self.debug = True def off(self): self.debug = False def dmp(self, x, cmt=""): if self.debug: if cmt != "": w = cmt + ": " + str(x) else: w = str(x) print(w) return x def prob(): d = Debug() d.off() X, T = getIntList() return max(X - T, 0) ans = prob() print(ans)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s337131300
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
n = int(input()) alis = list(map(int, input().split())) xlis = set() for i in alis: xlis.add(i - 1) xlis.add(i + 1) xlis.add(i) # print(xlis) counter = [0 for _ in range(len(xlis))] t = -1 for x in xlis: t += 1 for i in range(n): if x - 1 <= alis[i] and alis[i] <= x + 1: counter[t] += 1 print(max(counter))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s323644763
Accepted
p03609
The input is given from Standard Input in the following format: X t
a = int(eval(input().replace(" ", "-"))) print(a if a > 0 else 0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s391551816
Accepted
p03609
The input is given from Standard Input in the following format: X t
s, t = [int(a) for a in input().split()] print(max(0, s - t))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s351031625
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
def oddOut(): s = str(input()) print(s[::2]) pddOut()
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s955853162
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
print((lambda x: x[0] - x[1])(list(map(int, input().split()))))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s704557014
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
X, t = map(int, inputa().split()) print(X - t if X >= t else "0")
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s207119068
Accepted
p03609
The input is given from Standard Input in the following format: X t
X, t = [int(x) for x in input().split()] left = X - t if X - t >= 0 else 0 print(left)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s851452773
Accepted
p03609
The input is given from Standard Input in the following format: X t
a, b = list(map(int, input().split())) print(a - b) if a - b >= 0 else print(0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s242104882
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t = map(int, input().split()) if x => t: print(x-t) else: print("0")
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s191934247
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x, t = map(int, input().split()) ans = x - t if ans < 0: ans = 0 print(ans)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s030546140
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x, t = map(int,input().split()) if x <= t: print(0) else; print(x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s404060191
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t = map(int, input().split()) if x > t: print(x-t) else: print(0
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s783543401
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t=map(int input().split()) A=x-t if A>=0: print(A) else: print(0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s742235589
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x, t = list(map(int,input().split()) if x < t: print("0") else: print(x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s382256694
Accepted
p03609
The input is given from Standard Input in the following format: X t
a, t = map(int, input().split()) print(max(0, a - t))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s830137716
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t=map(int,input().split) print(max(0,x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s833458560
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
print(max(int(input()) - int(input())), 0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s566264838
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
print(int(input()) - int(input()))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s433049638
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
ls = list(map(int, input().split())) if (ls[0] - ls[1]) >= 0: print(ls[0] - ls[1])
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s920997951
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
xt = list(map(int, input().split())) if xt[0]-xt[1]>=0: print(xt[0]-xt[1]) else: print(0)print(xt[0]-xt[1])
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s662463580
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
# 文字列をセット str = input() flag = 0 result = "None" # 小文字のアルファベットをセット for s in str: for i in range(97, 97 + 26): if flag == 0: if chr(i) == s: result = chr(i) flag = 1 else: break print(result)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s733022327
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
str = input() ans = [] head, end = 0, 0 flag = False for i, val in enumerate(str): if val == "A": head = i ans.append(val) flag = True continue if val is not "Z" and flag == True: ans.append(val) end = i continue elif val is "Z" and flag == True: break answer = "".join(ans) print(len(answer[head:end]) + 2)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s690792818
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
n = int(input()) a = [int(i) for i in input().split()] cnt = [0] * 100002 for i in a: cnt[i - 1] += 1 cnt[i] += 1 cnt[i + 1] += 1 print(max(cnt))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s666659565
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
n = input().split(" ") print(int(n[0])-int(n[t])
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s629512926
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x,t=[int(i) for i in input().split()] print(max(0,x-t)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s472451171
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
X,t=map(int,input().split()) print(max(X-t, 0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s372731443
Wrong Answer
p03609
The input is given from Standard Input in the following format: X t
k = eval(input().replace(" ", "-")) print(min(0, k))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s676206242
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
X,t=map(int,input().split()) print(max(X-t,0)
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print the number of sand in the upper bulb after t second. * * *
s752522941
Runtime Error
p03609
The input is given from Standard Input in the following format: X t
x, t = map(int, input().split()) print(x-t)x, t = map(int, input().split()) print(max(x-t,0))
Statement We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
[{"input": "100 17", "output": "83\n \n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83\ngrams.\n\n* * *"}, {"input": "48 58", "output": "0\n \n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\n* * *"}, {"input": "1000000000 1000000000", "output": "0"}]
Print attributes of each item in order. Print an item in a line and adjacency attributes should be separated by a single space.
s014070155
Accepted
p02448
The input is given in the following format. $n$ $v_0 \; w_0 \; t_0 \; d_0 \; s_0$ $v_1 \; w_1 \; t_1 \; d_1 \; s_1$ : $v_{n-1} \; w_{n-1} \; t_{n-1} \; d_{n-1} \; s_{n-1}$ In the first line, the number of items $n$. In the following $n$ lines, attributes of each item are given. $v_i \; w_i \; t_i \; d_i \; s_i$ represent value, weight, type, date and name of the $i$-th item respectively.
readline = open(0).readline N = int(readline()) P = [readline().split() for i in range(N)] P = [(int(v), int(w), t, int(d), s) for v, w, t, d, s in P] P.sort() open(1, "w").writelines(["%d %d %s %d %s\n" % e for e in P])
Sorting Tuples Write a program which reads $n$ items and sorts them. Each item has attributes $\\{value, weight, type, date, name\\}$ and they are represented by $\\{$ integer, integer, upper-case letter, integer, string $\\}$ respectively. Sort the items based on the following priorities. 1. first by value (ascending) 2. in case of a tie, by weight (ascending) 3. in case of a tie, by type (ascending in lexicographic order) 4. in case of a tie, by date (ascending) 5. in case of a tie, by name (ascending in lexicographic order)
[{"input": "5\n 105 24 C 1500000000000 white\n 100 23 C 1500000000000 blue\n 105 23 A 1480000000000 pink\n 110 25 B 1500000000000 black\n 110 20 A 1300000000000 gree", "output": "100 23 C 1500000000000 blue\n 105 23 A 1480000000000 pink\n 105 24 C 1500000000000 white\n 110 20 A 1300000000000 gree\n 110 25 B 1500000000000 black"}]
Print attributes of each item in order. Print an item in a line and adjacency attributes should be separated by a single space.
s446853968
Accepted
p02448
The input is given in the following format. $n$ $v_0 \; w_0 \; t_0 \; d_0 \; s_0$ $v_1 \; w_1 \; t_1 \; d_1 \; s_1$ : $v_{n-1} \; w_{n-1} \; t_{n-1} \; d_{n-1} \; s_{n-1}$ In the first line, the number of items $n$. In the following $n$ lines, attributes of each item are given. $v_i \; w_i \; t_i \; d_i \; s_i$ represent value, weight, type, date and name of the $i$-th item respectively.
if __name__ == "__main__": n = int(input()) items = [] # type: ignore for _ in range(n): v, w, t, d, s = input().split() v, w, d = map(lambda x: int(x), [v, w, d]) # type: ignore items.append((v, w, t, d, s)) items = sorted(items, key=lambda x: (x[0], x[1], x[2], x[3], x[4])) for elem in items: print(f"{elem[0]} {elem[1]} {elem[2]} {elem[3]} {elem[4]}")
Sorting Tuples Write a program which reads $n$ items and sorts them. Each item has attributes $\\{value, weight, type, date, name\\}$ and they are represented by $\\{$ integer, integer, upper-case letter, integer, string $\\}$ respectively. Sort the items based on the following priorities. 1. first by value (ascending) 2. in case of a tie, by weight (ascending) 3. in case of a tie, by type (ascending in lexicographic order) 4. in case of a tie, by date (ascending) 5. in case of a tie, by name (ascending in lexicographic order)
[{"input": "5\n 105 24 C 1500000000000 white\n 100 23 C 1500000000000 blue\n 105 23 A 1480000000000 pink\n 110 25 B 1500000000000 black\n 110 20 A 1300000000000 gree", "output": "100 23 C 1500000000000 blue\n 105 23 A 1480000000000 pink\n 105 24 C 1500000000000 white\n 110 20 A 1300000000000 gree\n 110 25 B 1500000000000 black"}]
For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.
s657393490
Wrong Answer
p00025
The input consists of multiple datasets. Each dataset set consists of: a1 a2 a3 a4 b1 b2 b3 b4 , where ai (0 ≤ ai ≤ 9) is i-th number _A_ imagined and bi (0 ≤ bi ≤ 9) is i-th number _B_ chose. The input ends with EOF. The number of datasets is less than or equal to 50.
a = input().split() b = input().split() s = 0 v = 0 for i in range(len(a)): if a[i] == b[i]: s += 1 elif a[i] in b: v += 1 print(*(s, v))
Hit and Blow Let's play Hit and Blow game. _A_ imagines four numbers and _B_ guesses the numbers. After _B_ picks out four numbers, _A_ answers: * The number of numbers which have the same place with numbers _A_ imagined (Hit) * The number of numbers included (but different place) in the numbers _A_ imagined (Blow) For example, if _A_ imagined numbers: 9 1 8 2 and _B_ chose: 4 1 5 9 _A_ should say 1 Hit and 1 Blow. Write a program which reads four numbers _A_ imagined and four numbers _B_ chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.
[{"input": "1 8 2\n 4 1 5 9\n 4 6 8 2\n 4 6 3 2", "output": "1\n 3 0"}]
Print x_{N,1}. * * *
s743911459
Wrong Answer
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
print("1")
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s108003504
Runtime Error
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
a = int(input()) b = input() if a > 10000: a = a // 100 elif a > 1000: a = a // 10 base = [0] * a for i in range(len(b)): base[i] = int(b[i]) for i in range(a - 1): for j in range(a - i - 1): next = [0] * (a - i - 1) next[j] = base[j] - base[j + 1] if base[j] < base[j + 1]: next[j] = next[j] * -1 base[j] = next[j] print(base[0])
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s025351090
Wrong Answer
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
print(3)
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s274619050
Wrong Answer
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
n = int(input()) s = input() if set(list(s)) == {"1", "3"}: print(2)
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s821215403
Accepted
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 N = int(sys.stdin.buffer.readline()) A = list(map(int, sys.stdin.buffer.readline().decode().rstrip())) def pp(A, offset=0): s = " " * offset + " ".join(map(str, A)) print(s) def test(A): i = 0 while len(A) > 1: pp(A, i) A = list(map(lambda a: abs(a[0] - a[1]), zip(A, A[1:]))) i += 1 pp(A, i) return A def convert(counts): ret = [] if counts[0][1] > 1: ret.append((0, counts[0][1] - 1)) for (n1, cnt1), (n2, cnt2) in zip(counts, counts[1:]): ret.append((abs(n1 - n2), 1)) if cnt2 > 1: ret.append((0, cnt2 - 1)) n = None count = 0 filtered = [] for a, cnt in ret: if a != n: n = a count = 0 filtered.append((n, 0)) count += cnt filtered[-1] = (n, count) return filtered # # A = [] # for _ in range(N): # import random # # A.append(random.randint(0, 2)) # ans = test(A) # print(ans) # cnt2[n]: n! が 2 で何回割れるか cnt2 = [] cnt = 0 for n in range(N + 10): while n >= 2 and n % 2 == 0: n //= 2 cnt += 1 cnt2.append(cnt) # 0, 1, 2 だけにする A = list(map(lambda a: abs(a[0] - a[1]), zip(A, A[1:]))) # 1が入ってるとき、2は0と同一視できる if 1 in A: for i in range(len(A)): if A[i] == 2: A[i] = 0 mod = 2 if 1 in A else 4 ans = 0 n = len(A) - 1 for r in range(len(A)): cnt = cnt2[len(A) - 1] - cnt2[r] - cnt2[n - r] # cnt = math.factorial(n) // math.factorial(r) // math.factorial(n - r) if cnt == 0: ans += A[r] ans %= mod # print(n, r, cnt) print(ans)
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s008207073
Accepted
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
import sys N = int(input()) S = input().strip() ss = [] for c in S: ss.append(int(c)) if N == 2: print(abs(ss[0] - ss[1])) sys.exit() X = [] X2 = [] fff = 0 for i in range(N - 1): c = abs(ss[i] - ss[i + 1]) X.append(c % 2) X2.append((c // 2) % 2) if c == 1: fff = 1 N = N - 2 i = 0 Y = [] while N: if N % 2: Y.append(i) i += 1 N = N // 2 C = [0] for y in Y[::-1]: y = 2**y # print(y) tmp = [] for c in C: tmp.append(c + y) for t in tmp: C.append(t) r = 0 r2 = 0 for c in C: r = r ^ X[c] r2 = r2 ^ X2[c] if fff: print(r) else: print(r2 * 2)
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s112207401
Wrong Answer
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
n = int(input()) a = list(input()) A = [] for i in a: A.append(int(i)) if n % 4 == 1: print(abs(A[0] - A[-1])) elif n % 4 == 2: if n == 2: print(abs(A[0] - A[1])) exit() x = abs(A[0] - A[-2]) y = abs(A[1] - A[-1]) print(abs(x - y)) elif n % 4 == 3: if n == 3: print(abs(A[0] - A[1])) exit() x = abs(A[0] - A[-3]) y = abs(A[2] - A[-1]) print(abs(x - y)) else: if n == 4: x = abs(A[0] - A[2]) y = abs(A[1] - A[3]) print(abs(x - y)) else: b = [] for i in range(4): b.append(abs(A[i] - A[i - 4])) x = abs(b[0] - b[2]) y = abs(b[1] - b[3]) print(abs(x - y))
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s970756718
Wrong Answer
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
n = int(input()) a = list(map(int, list(input()))) result = 0 for _ in range(n): nex = [] for i in range(len(a) - 1): p = abs(a[i] - a[i + 1]) if p != 0: nex.append(p) if len(nex) == 0: break elif len(nex) == 1: result = nex[0] break a = nex print(result)
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]
Print x_{N,1}. * * *
s137781888
Runtime Error
p02736
Input is given from Standard Input in the following format: N a_1a_2\ldotsa_N
import sys input = sys.stdin.readline absf = abs rangef = range intf = int n = intf(input()) al = [intf(x) for x in list(input())] lenf = len def gen(n, al): return n, [absf(al[i] - al[i + 1]) for i in rangef(n)] for _ in rangef(n - 1): n, al = gen(n - 1, al) print(al[0])
Statement Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}.
[{"input": "4\n 1231", "output": "1\n \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n 2311312312", "output": "0"}]