message
stringlengths
2
45.8k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
254
108k
cluster
float64
3
3
__index_level_0__
int64
508
217k
Provide a correct Python 3 solution for this coding contest problem. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strata to be dug, we can reach the buried treasure at the low...
instruction
0
105,192
3
210,384
"Correct Solution: ``` import queue di = [0, 1, 0, -1] dj = [1, 0, -1, 0] while True: w,h = map(int,input().split()) if w == 0: break f, m, o = map(int,input().split()) c = [list(map(int,input().split())) for _ in range(h)] d = [[[1e9]*w for x in range(h)] for y in range(m+1)] que = q...
output
1
105,192
3
210,385
Provide a correct Python 3 solution for this coding contest problem. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strata to be dug, we can reach the buried treasure at the low...
instruction
0
105,193
3
210,386
"Correct Solution: ``` INF = 10 ** 20 def update_state(state, newx): tmp = list(state) tmp[newx] = 1 return tuple(tmp) def get_co(x, y): dc = do = 0 score = mp[y][x] if score < 0: dc = -score else: do = score return dc, do def minimum_cost(x, y, state, ox, goal, dic, w, m): if (x, y, state,...
output
1
105,193
3
210,387
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strat...
instruction
0
105,194
3
210,388
No
output
1
105,194
3
210,389
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strat...
instruction
0
105,195
3
210,390
No
output
1
105,195
3
210,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strat...
instruction
0
105,196
3
210,392
No
output
1
105,196
3
210,393
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aizu has an ancient legend of buried treasure. You have finally found the place where the buried treasure is buried. Since we know the depth of the buried treasure and the condition of the strat...
instruction
0
105,197
3
210,394
No
output
1
105,197
3
210,395
Provide a correct Python 3 solution for this coding contest problem. You are working as a night watchman in an office building. Your task is to check whether all the lights in the building are turned off after all the office workers in the building have left the office. If there are lights that are turned on, you must...
instruction
0
105,202
3
210,404
"Correct Solution: ``` import sys,queue,math,copy,itertools LI = lambda : [int(x) for x in sys.stdin.readline().split()] while True: M,N,D = LI() if N == 0 : break S = [] for _ in range(N): S.extend(LI()) x = [] for i in range(N): for j in range(M): y = [0 for _ in...
output
1
105,202
3
210,405
Provide a correct Python 3 solution for this coding contest problem. There is an evil creature in a square on N-by-M grid (2 \leq N, M \leq 100), and you want to kill it using a laser generator located in a different square. Since the location and direction of the laser generator are fixed, you may need to use several...
instruction
0
105,205
3
210,410
"Correct Solution: ``` from collections import deque N, M, A = map(int, input().split()) MP = [[0]*M for i in range(N)] sx = sy = gx = gy = -1 for i in range(N): for j, c in enumerate(input()): if c == '#': MP[i][j] = 1 elif c == 'S': sx = j; sy = i elif c == 'G': ...
output
1
105,205
3
210,411
Provide a correct Python 3 solution for this coding contest problem. There is an evil creature in a square on N-by-M grid (2 \leq N, M \leq 100), and you want to kill it using a laser generator located in a different square. Since the location and direction of the laser generator are fixed, you may need to use several...
instruction
0
105,206
3
210,412
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int...
output
1
105,206
3
210,413
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediate...
instruction
0
105,784
3
211,568
No
output
1
105,784
3
211,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediate...
instruction
0
105,785
3
211,570
No
output
1
105,785
3
211,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediate...
instruction
0
105,786
3
211,572
No
output
1
105,786
3
211,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediate...
instruction
0
105,787
3
211,574
No
output
1
105,787
3
211,575
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,914
3
211,828
"Correct Solution: ``` #!/usr/bin/env python3 import sys import bisect input = sys.stdin.readline sys.setrecursionlimit(10**6) n, m = map(int, input().split()) seen = set() ab = [] for _ in range(n): a, b = map(int, input().split()) ab.append((a, b)) seen.add(a) ab.sort() decomp = list(seen) decomp.sort()...
output
1
105,914
3
211,829
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,915
3
211,830
"Correct Solution: ``` import sys input = sys.stdin.readline LLL = 1<<20 N, M = map(int, input().split()) R = [] for _ in range(N): a, b = map(int, input().split()) R.append((a*2, b, 0)) for i in range(M): l, r = map(int, input().split()) R.append((l*2-1, 2, i)) R.append((r*2+1, 3, i)) R.sort(key=...
output
1
105,915
3
211,831
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,916
3
211,832
"Correct Solution: ``` # 解説動画の通り import sys from bisect import * from collections import defaultdict sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(ma...
output
1
105,916
3
211,833
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,917
3
211,834
"Correct Solution: ``` # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n,m = map(int,readline().split()) ab = [tuple(map(int,readline().split())) for _ in range(n)] lr = [tuple(map(int,readline().split())) for _ in range(m)] ab.sort() a = [] b = [] for i,j in ab: a...
output
1
105,917
3
211,835
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,918
3
211,836
"Correct Solution: ``` # coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.readline read = sys.stdin.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import combinations import bisect# lower_bound etc #im...
output
1
105,918
3
211,837
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,919
3
211,838
"Correct Solution: ``` import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from bisect import bisect_left, bisect_right def resolve(): n, m = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(n)] AB....
output
1
105,919
3
211,839
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,920
3
211,840
"Correct Solution: ``` import bisect 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, M = list(map(int, sys.stdin.buffer.readline().split())) AB = [list(map(int, sys.stdin.buffe...
output
1
105,920
3
211,841
Provide a correct Python 3 solution for this coding contest problem. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bom...
instruction
0
105,921
3
211,842
"Correct Solution: ``` #!/usr/bin/env python3 import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) import bisect n, m = map(int, input().split()) seen = set() ab = [] for _ in range(n): a, b = map(int, input().split()) ab.append((a, b)) seen.add(a) ab.sort() seen_list = list(seen) seen_list....
output
1
105,921
3
211,843
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,922
3
211,844
Yes
output
1
105,922
3
211,845
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,923
3
211,846
Yes
output
1
105,923
3
211,847
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,924
3
211,848
Yes
output
1
105,924
3
211,849
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,925
3
211,850
Yes
output
1
105,925
3
211,851
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,926
3
211,852
No
output
1
105,926
3
211,853
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,927
3
211,854
No
output
1
105,927
3
211,855
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,928
3
211,856
No
output
1
105,928
3
211,857
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a pa...
instruction
0
105,929
3
211,858
No
output
1
105,929
3
211,859
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,008
3
212,016
"Correct Solution: ``` def main(): while True: n = int(input()) if not n: break start = int(input()) - 1 #開始の位置 goal = int(input()) - 1 #あたりの位置 d = int(input()) nums = [[i for i in range(n)]] #各段での数字の並び bars = [] #横棒リスト for i in range(d): s = input() bar...
output
1
106,008
3
212,017
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,009
3
212,018
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) if N == 0: return False M = int(readline()) K = int(readline()) D = int(readline()) P = [list(map(int, readline().strip())) + [0] for i in range(D)] INF = (10, 0)...
output
1
106,009
3
212,019
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,010
3
212,020
"Correct Solution: ``` from copy import copy def change(n,a): temp = a[n] a[n] = a[n+1] a[n+1] = temp return a while(1): st = 1 n = int(input()) if n == 0: break elif n == 1: st = 0 m_ = int(input()) m = m_ -1 w = int(input()) d = int(input()) b = []...
output
1
106,010
3
212,021
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,011
3
212,022
"Correct Solution: ``` while True: n = int(input()) if not n: break start = int(input()) - 1 #開始の位置 goal = int(input()) - 1 #あたりの位置 d = int(input()) nums = [[i for i in range(n)]] #各段での数字の並び bars = [] #横棒リスト for i in range(d): s = input() bars.append(s) new = nums[-1][:] for...
output
1
106,011
3
212,023
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,012
3
212,024
"Correct Solution: ``` import copy def check_lots(start, goal, line): for i in range(len(line)): for j in range(len(line[i])): if line[i][j] == 1: if j == start - 1: start -= 1 elif j == start: start += 1 return start =...
output
1
106,012
3
212,025
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,013
3
212,026
"Correct Solution: ``` def check(n,m,star,d,f): ns=[i for i in range(n)] for i in range(d): for j in range(n-1): if f[i][j]: c=ns[j+1] ns[j+1]=ns[j] ns[j]=c return ns[star-1]==m-1 while True: n=int(input()) if(n==0):break m=i...
output
1
106,013
3
212,027
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,014
3
212,028
"Correct Solution: ``` # AOJ 0069: Drawing Lots II # Python3 2018.6.28 bal4u while True: n = int(input()) if n == 0: break m, p, d = [int(input()) for i in range(3)] m -= 1 p -= 1 a = [[] for i in range(d+1)] for i in range(d): a[i] = list(map(int, input())) s = [[0 for j in range(n)] for i in range(d+1)] s[d...
output
1
106,014
3
212,029
Provide a correct Python 3 solution for this coding contest problem. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal ...
instruction
0
106,015
3
212,030
"Correct Solution: ``` import sys f = sys.stdin while True: n = int(f.readline()) if n ==0: break m, star, d = [int(f.readline()) for _ in range(3)] lines = [f.readline().strip() for _ in range(d)] lots = [None for j in range(d + 1)] lots[0] = [i + 1 for i in range(n)] for i, line ...
output
1
106,015
3
212,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,016
3
212,032
Yes
output
1
106,016
3
212,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,017
3
212,034
Yes
output
1
106,017
3
212,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,018
3
212,036
Yes
output
1
106,018
3
212,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,019
3
212,038
No
output
1
106,019
3
212,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,020
3
212,040
No
output
1
106,020
3
212,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,021
3
212,042
No
output
1
106,021
3
212,043
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect ...
instruction
0
106,022
3
212,044
No
output
1
106,022
3
212,045
Provide a correct Python 3 solution for this coding contest problem. Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are known ...
instruction
0
106,077
3
212,154
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int...
output
1
106,077
3
212,155
Provide a correct Python 3 solution for this coding contest problem. Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are known ...
instruction
0
106,078
3
212,156
"Correct Solution: ``` a={};b=0 for _ in [0]*int(input()): x,y,w=map(int,input().split()) for i in range(2): for j in range(2): if (x+i,y+j) not in a:a[(x+i,y+j)]=0 a[(x+i,y+j)]+=w b=max(b,a[(x+i,y+j)]) print(str(b)+' / 1') ```
output
1
106,078
3
212,157
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. Wi...
instruction
0
106,079
3
212,158
No
output
1
106,079
3
212,159
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. Wi...
instruction
0
106,080
3
212,160
No
output
1
106,080
3
212,161
Provide tags and a correct Python 3 solution for this coding contest problem. Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards"...
instruction
0
106,412
3
212,824
Tags: math Correct Solution: ``` MOD = 1000000007 def bib(x, y): ans = 1 x = x % MOD while y > 0: if (y & 1 != 0): ans = (ans * x) % MOD y = y >> 1 x = (x * x) % MOD return ans % MOD n = int(input()) ans = bib(2, 2 * n - 1) + bib(2, n - 1) if (n == 0): print(1) else: print(ans % MOD) ```
output
1
106,412
3
212,825
Provide tags and a correct Python 3 solution for this coding contest problem. Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards"...
instruction
0
106,413
3
212,826
Tags: math Correct Solution: ``` n = int(input()) u1 = pow(2, n-1, 1000000007) u2 = pow(2, 2*n-1, 1000000007) u3 = (u1 + u2)%1000000007 print(int(u3%1000000007)) ```
output
1
106,413
3
212,827