akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
const int maxn=200010;
long long b[maxn],mn,mx,ans;
long a[maxn],n,p=0,q=2,cp,cq;
using namespace std;
void f(long i){
	cp=abs(b[i]-2*b[p]);
	while(p<i && abs(b[i]-2*b[p+1])<cp)
		cp=abs(b[i]-2*b[++p]);
	mn=min(b[i]-b[p],b[p]);
	mx=max(b[i]-mn,mx);
}
void g(long i){
	if(i<q) q--;
	cq=abs(b[n-1]-2*b[q]+b[i]);
	while(q<n && abs(b[n-1]-2*b[q+1]+b[i])<cq)
		cq=abs(b[n-1]-2*b[++q]+b[i]);
	mn=min(mn,min(b[n-1]-b[q],b[q]-b[i]));
	mx=max(mx,max(b[n-1]-b[q],b[q]-b[i]));
}
int main(){
	cin>>n;
	for(long i=0;i<n;i++)
		cin>>a[i],b[i]=(i==0?a[i]:b[i-1]+a[i]);
	ans=b[n-1];
	for(long i=1;i<n-2;i++){
		mn=b[n-1],mx=0;
		f(i),g(i);
		ans=min(ans,mx-mn);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
ll a,b,c;
cin>>a>>b>>c;
ll ans = 0;
if(a==b&&b==c&&a%2==0){
    cout<<-1<<endl;  return 0;
    }
while(a%2==0&&b%2==0&&c%2==0){
  ans++;
  int x=(b+c)/2,y=(c+a)/2,z=(a+b)/2;
  a=x,b=y,c=z;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int s,w;
	cin>>s>>w;
	if(s<=w)
	cout<<"unsafe";
	else
	cout<<"safe";
	
	
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int foo(int a,int b,int n){
	for(int i=a ; i <= b ; i++ ){
		if( i%n == 0 ) return i;
	}
	return -1;
}

int bar(int a,int b,int n){
	for(int i=b ; i>= a ; i-- ){
		if( i%n == 0 ) return i;
	}
	return -1;
}

int main(){
	int n,m,a[1001];

	while( cin >> n >> m , n||m ){
		int rank,time,id;
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i];
		}

		for(int i=0 ; i < n ; i++ ){
			if( i == 0 ){
				int f = bar( 0 , m , a[0] );
				time = f;
				rank = a[0];
				id = 0;
			}else{
				if( rank < a[i] ){
					int f = foo( time , m , a[i] );
					if( f == -1 ){
						f = bar( 0 , time-1 , a[i] );
						time = f;
						rank = a[i];
						id = i;
					}
				}else if( rank == a[i] ){
					int f = foo( time+1 , m , a[i] );
					if( f == -1 ){
						f = bar( 0 , time , a[i] );
						if( f == time ){
							rank = a[n-1];
							id = n-1;
						}else{
							time = f;
							rank = a[i];
							id = i;
						}
					}
				}else{
					int f = foo( time+1 , m , a[i] );
					if( f == -1 ){
						f = bar( 0 , time , a[i] );
						time = f;
						rank = a[i];
						id = i;
					}
				}
			}
		}
		cout << id+1 << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
		ll n;
		cin >> n;
		ll a[n+1];
		ll b[n], x = 0;
			for(ll i = 0; i<=n; i++)
				cin >> a[i], x+= a[i];
			for(ll i = 0; i<n; i++)
				cin >> b[i];
			ll sum = 0;
		for(ll i = 0 ; i<n; i++)
			{
				if(b[i] >= a[i])
					sum += a[i], b[i] -= a[i], a[i] = 0;
				else if(a[i] > b[i])
				 sum += b[i] , a[i] = a[i] - b[i], b[i] = 0;
				
				if(b[i] >= a[i+1])
				sum += a[i+1], b[i] = b[i] - a[i+1], a[i+1] = 0;
				else if(a[i+1]> b[i])
				 sum +=  b[i], a[i+1] = a[i+1] - b[i], b[i] = 0;
			}
				
				cout << sum << endl;
}


Measured memory_bytes: 1792
N,M,C=map(int,input().split())
B=[int(i) for i in input().split()]
A=[]
for j in range(N):
    A.append([int(i) for i in input().split()])
ans=0
for k in range(N):
    sum_num=0
    for l in range(M):
        sum_num=sum_num+B[l]*A[k][l]
    if sum_num+C>0:
        ans=ans+1
print(ans)

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
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()))

n,A,B = inpl()
a = inpl()
res = 0
for i in range(n-1):
    tmp = B
    if (a[i+1]-a[i]) * A <= B:
        tmp = (a[i+1]-a[i]) * A
    res += tmp
print(res)

Measured memory_bytes: 16440
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()

typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;
int cnt[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

    int n, k, q;
    cin >> n >> k >> q;

    for (int i = 0; i < q; i++) {
        int x = 0;
        cin >> x;
        cnt[x]++;
    }

    for (int i = 1; i <= n; i++) {
        if (q - cnt[i] >= k)
            cout << "No" << '\n';
        else
            cout << "Yes" << '\n';
    }

    return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func GCD(a, b int) int {
        for b != 0 {
                t := b
                b = a % b
                a = t
        }
        return a
}

func LCM(a, b int, integers ...int) int {
        result := a * b / GCD(a, b)

        for i := 0; i < len(integers); i++ {
                result = LCM(result, integers[i])
        }

        return result
}

func main() {
        var a, b, c, d int
        fmt.Scan(&a, &b, &c, &d)

        e := LCM(c, d)
        sum := b/c - (a-1)/c + b/d - (a-1)/d - (b/e - (a-1)/e)
        fmt.Println(b - a + 1 - sum)
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;

int main () {
    int i;
    string s;
    cin >>  s;
    for(i=0;i<s.length();i++){
        if(s[i]=='A') s[i] = 'X';
        else if (s[i]=='B') s[i] = 'Y';
        else if (s[i]=='C') s[i] = 'Z';
        else                  s[i] = s[i]-3;
    }
    cout << s << endl;
}

Measured memory_bytes: 1180
N = int(input())
dp = [float('inf')]*(N+1)
dp[0] = 0
for i in range(1,N+1):
    dp[i] = 1 + dp[i-1]
    j,k = 1,1
    while pow(6,j)<=i:
        dp[i] = min(dp[i],1+dp[i-pow(6,j)])
        j += 1
    while pow(9,k)<=i:
        dp[i] = min(dp[i],1+dp[i-pow(9,k)])
        k += 1
print(dp[-1])
    

Measured memory_bytes: 74816
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;
vvi dp;

bool f(int l,int r){
	if(dp[l][r]!=-1) return dp[l][r];
	if(s[l]=='m'&&s[r-1]=='w'&&r-l>2){
		for(int i=l+1;i<r-1;i++) if(s[i]=='e'&&f(l+1,i)&&f(i+1,r-1)){
			dp[l][r]=1;
			return 1;
		}
	}
	dp[l][r]=0;
	return 0;
}

int main(){
	cin>>s;
	int S=s.size();
	dp=vvi(S,vi(S+1,-1));
	for(int i=0;i<S;i++) dp[i][i]=1;
	if(f(0,S)) cout<<"Cat"<<endl;
	else cout<<"Rabbit"<<endl;
}

Measured memory_bytes: 3988
import java.io.BufferedReader

fun main() = aising2019c()

@OptIn(ExperimentalStdlibApi::class)
fun aising2019c() = SimpleIO_aising2019c().exec {
    val (h, w) = readLine().split(" ").map { it.toInt() }
    val board = Array(h) { readLine().map { it == '#' }.toBooleanArray() }

    val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
    val visited = Array(h) { BooleanArray(w) }
    var answer = 0L

    for (i in 0 until h) for (j in 0 until w) {
        if (!board[i][j] || visited[i][j]) continue

        var blackCount = 0L
        var whiteCount = 0L

        fun dfs(y: Int, x: Int) {
            if (visited[y][x]) return else visited[y][x] = true
            if (board[y][x]) blackCount++ else whiteCount++
            around.map { y - it.first to x - it.second }
                .filter { (ny, nx) -> ny in 0 until h && nx in 0 until w && board[ny][nx] != board[y][x] }
                .forEach { (ny, nx) -> dfs(ny, nx) }
        }

        dfs(i, j)

        answer += blackCount * whiteCount
    }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleIO_aising2019c(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private val sb: StringBuilder = StringBuilder()
    fun readLine(): String = br.readLine()!!
    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)
    fun exec(action: SimpleIO_aising2019c.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 131860
import bisect
n = int(input())
As = list(map(int, input().split()))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = [0]*(n+1)
v = 0
for idx, b in enumerate(Bs[::-1]):
    v += len(Cs) - bisect.bisect_right(Cs, b)
    cnt[n-1-idx] = v

print(sum([cnt[bisect.bisect_right(Bs, a)] for a in As]))


Measured memory_bytes: 23360
#include <bits/stdc++.h>

// Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
// Problem: C: Slimes (https://atcoder.jp/contests/abc143/tasks/abc143_c)

using namespace std;

using ll = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n; cin >> n;
    ll mn = 1e18;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i)
            continue;
        mn = min(mn, (i - 1) + (n / i - 1));
    }

    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);



int main() {

    ll h;
    cin >> h;

    ll ans = 0;
    ll cnt = 1;
    while(h >= 1) {
        h /= 2;
        ans += cnt;
        cnt *= 2;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(){
    val n = readLine()!!.split(" ")[0].toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    var ans = 1L
    var flag = 0
    for (i in 0 until n){
        ans *= a[i]
        if (ans > 1000000000000000000) {
            flag = 1
            break
        } else if (ans < 0){
            flag = 1
            break
        }
    }
    var x = 1000000000000000000
    for (i in 0 until n){
        x /= a[i]
        if (x == 0L) {
            flag = 1
            break
        }
    }
    for (i in 0 until n){
        if (a[i] == 0L) {
            flag = 2
            break
        }
    }
    if (flag == 2) println(0)
    else if (flag == 1) println(-1)
    else println(ans)
}


Measured memory_bytes: 62556
n = gets.chomp.to_i
t,a = gets.chomp.split(" ").map(&:to_i)
h_arr = gets.chomp.split(" ").map(&:to_i)

min = 999999999999
index = nil
h_arr.each_with_index do |h, ind|
  diff = (t - h * 0.006 - a).abs
  if diff < min then
    min = diff
    index = ind
  end
end

puts index + 1


Measured memory_bytes: 1788
def main():
	n,p = map(int,input().split())
	s = input()
	num = 0
	s1 = [0]*(n+1)
	ans = 0
	if p == 2 or p == 5:
		for i in range(len(s)):
			if int(s[i])%p == 0:
				ans += i+1	
		print(ans)
		exit()
	ans = 0
	arr = [0]*p
	s = s[::-1]
	z = 1
	for i in range(n):
		s1[i+1] = s1[i] + int(s[i])*z
		z = z * 10 %p
		s1[i+1] %=p
		arr[s1[i]] += 1
	arr[s1[n]]+=1
	#print(s1)
	for i in range(p):
		ans += arr[i] * (arr[i] - 1) // 2
	print(ans)
if __name__ == '__main__':
	main()


Measured memory_bytes: 11020
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
const ll n_div = 1e9+7;
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 

int main() {
	// 入力
	ll N;
	string S;
	cin >> N>>S;
	string abc = "abcdefghijklmnopqrstuvwxyz";
	
	// 解法
	ll Acc[26] = {0};
	REP(i,N){
		REP(j,26){
			if (S[i]==abc[j]) Acc[j]++;
		}
	}
	
	ll ans = 1;
	REP(i,26){
		ans *= Acc[i]+1;
		ans %= n_div;
		// cout << i << " " << ans << endl;
	}
	ans--;
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
ll n,a,b;
cin>>n>>a>>b;
cout<< n/(a+b)*a + min( a , n%(a+b) )<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="Sunny")
		cout<<"Cloudy";
	else if(s=="Cloudy")
		cout<<"Rainy";
	else if(s=="Rainy")
		cout<<"Sunny";	
	return 0;
}

Measured memory_bytes: 256
def add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

def check_overk(in1, k):
    return len([i for i in in1 if i>k]) > 0

def split(ar, k, w):
    a = 0
    for i in ar:
        if check_overk(i, k):
            return -1
    tm = ar[0]
    for i in range(1, w):
        tm = add(tm, ar[i])
        if check_overk(tm, k):
            a += 1
            tm = ar[i]
    return a
            

h, w, k = map(int, input().split())
s = [[int(i) for i in input()] for j in range(h)]
ans = h*w

for i in range(2**(h-1)):
    data = []
    temp = s[0]
    sp = bin(i+2**h)[4:]
    if ans < sp.count("1"):
        continue
    for j in range(1, h):
        if sp[j-1] == "0":
            temp = add(temp, s[j])
        else:
            data.append(temp)
            temp = s[j]
    data.append(temp)
    ans_ = split([list(x) for x in zip(*data)], k, w)
    if ans_ == -1:
        continue
    ans_ += sp.count("1")
    if ans > ans_:
        ans = ans_
print(ans)


Measured memory_bytes: 3380
a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
b = list("DEFGHIJKLMNOPQRSTUVWXYZABC")

x = list(input())
for i in range(len(x)):
    for j in range(len(a)):
        if x[i] == b[j]:
            x[i] = a[j]
            break
for i in range(len(x)):
    print(x[i], end = "")
print("")

Measured memory_bytes: 7448
import java.util.*;
import java.io.*;
public class Main {
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int datasize = 0;//????????°
	int datasize2 = 0;//???????????°
	int start = 0;
	int distance[];//???????????¢
	@SuppressWarnings("unchecked")
	static ArrayList<Edge>[]G = new ArrayList[100000];
	static int Infinity = 1500000000;
	public static void main(String []args){
		Main m = new Main();
	}
	public Main(){
		try{
			String input = reader.readLine();
			String []get = input.split(" ");
			datasize = Integer.parseInt(get[1]);
			datasize2 = Integer.parseInt(get[0]);
			start = Integer.parseInt(get[2]);
			distance = new int[datasize2];
			for(int z = 0;z < datasize2;z++){
				G[z] = new ArrayList<Edge>(0);
				this.distance[z] = Infinity;
			}
			for(int z = 0;z < datasize;z++){
				input = reader.readLine();
				get = input.split(" ");
				G[Integer.parseInt(get[0])].add(new Edge(Integer.parseInt(get[1]),Integer.parseInt(get[2])));
			}
			Explore();
			for(int z = 0;z < datasize2;z++){
				if(distance[z] != Infinity)System.out.println(distance[z]);
				else System.out.println("INF");
			}
		}catch(IOException e){
			
		}
	}
	public void Explore(){
		
		PriorityQueue<Candidate> candidates = new PriorityQueue<Candidate>();
		candidates.offer(new Candidate(start,0));
		distance[start] = 0;
		while(!candidates.isEmpty()){
			Candidate c = candidates.poll();
			int number = c.number;
			int d = c.d;
			if(distance[number] < d){
				continue;
			}
			List<Edge> edges = G[number];//No.????????????????????????????????´????????¢??????????????¨??????
			for(Edge ed : edges){
				if(distance[ed.go] > distance[number] + ed.cost){//?????????????????????????????¢>????????????+????????????????????????
					distance[ed.go] = distance[number]+ed.cost;
					candidates.offer(new Candidate(ed.go,distance[ed.go]));
				}
			}
		}
	}
	static class Candidate implements Comparable<Candidate>{//???????????¢????£??????????
		int number = -1;//?????????????????????
		int d = 0;//?????¢
		public Candidate(int number,int d){
			this.number = number;
			this.d = d;
		}
		@Override
		public int compareTo(Candidate o) {
			return d-o.d;
		}
	}static class Edge{
		int go;//??????????????????
		int cost;//?????¢
		Edge(int go,int cost){
			this.go = go;
			this.cost = cost;
		}
	}
}

Measured memory_bytes: 193992
#include<stdio.h>
#include<string.h>
#include<math.h>
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,t;
  l = 2*i;
  r = 2*i+1;

  if(l<=H&&A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=H&&A[r] > A[largest]) largest = r;

  if(largest!=i){
    t=A[i];
    A[i]=A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int t;
  if(key <A[i]) return;
  A[i] = key;
  while(i>1&&A[i/2]<A[i]){
    t = A[i];
    A[i] = A[i/2];
    A[i/2] = t;
    i = i/2;
  }
}

void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5684
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  string s;
  cin >> s;

  while(s != ""){
    if(s.substr(s.length() - 5, 5) == "dream" || s.substr(s.length() - 5,5) == "erase"){
      s = s.substr(0, s.length() - 5);
    }
    else if(s.substr(s.length() - 6,6) == "eraser"){
      s = s.substr(0, s.length() - 6);
    }
    else if(s.substr(s.length() - 7,7) == "dreamer"){
      s = s.substr(0, s.length() - 7);
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 512
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-17 23:38:43
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

using ld = long double;

const ld PI = acos(-1.0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ld a, b; cin >> a >> b;
  ld h, m; cin >> h >> m;

  ld theta = abs(m / 60 * 360 - (h / 12 + m / 12 / 60) * 360) * PI / 180;
  ld ans = sqrtl(a * a + b * b - 2 * a * b * cos(theta));

  cout << setprecision(17) << ans << endl;

  return 0;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  int count=0;
  int wa=a+b;
  if(a%3==0)
    count++;
  if(b%3==0)
    count++;
  if((a+b)%3==0)
    count++;
  if(count==0)
    cout << "Impossible" << endl;
  else
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
string s, ans[4];
int n;

int index(string a, char b) {//この関数は文字列が存在しない場合は考えない　　bは次に追加する文字の判定
	int res;
	if (a[a.length() - 1] == 'S') {//ここが違う
		if (b == 'o') {
			if (a[a.length() - 2] == 'S')res = 0;  //ss
			else res = 1;                          //sw
		}
		else {
			if (a[a.length() - 2] == 'S')res = 1;  //sw
			else res = 0;                          //ss 
		}
	}
	else {
		if (b == 'o') {
			if (a[a.length() - 2] == 'S')res = 3;  //ww
			else res = 2;                          //ws
		}
		else {
			if (a[a.length() - 2] == 'S')res = 2;  //ws
			else res = 3;                          //ww 
		}
	}
	return res;
}

char nextC(int index) {
	if (index % 2 == 0) {//0
		return 'S';
	}
	else {
		return 'W';
	}
}

bool cond(string a, int index) {//indexは0,length()-1だけ
	bool flag = false;
	if (a == "-1")return flag;
	if (index == 0) {
		if (s[s.length() - 1] == 'o') {
			if (a[a.length() - 1] == 'S') {
				if (a[a.length() - 2] == a[0])flag = true;
			}
			else if (a[a.length() - 2] != a[0])flag = true;
		}
		else {
			if (a[a.length() - 1] == 'S') {
				if (a[a.length() - 2] != a[0])flag = true;
			}
			else if (a[a.length() - 2] == a[0])flag = true;
		}
	}
	else if(index == 1){
		if (s[0] == 'o') {
			if (a[0] == 'S') {
				if (a[a.length() - 1] == a[1])flag = true;
			}
			else if (a[a.length() - 1] != a[1])flag = true;
		}
		else {
			if (a[0] == 'S') {
				if (a[a.length() - 1] != a[1])flag = true;
			}
			else if (a[a.length() - 1] == a[1])flag = true;
		}
	}
	return flag;
}

int main() {
	cin >> n >> s;

	ans[0] = "SS"; ans[1] = "SW";  ans[2] = "WS"; ans[3] = "WW";
	for (int i = 1; i < s.length()-1; i++) {
		for (int j = 0; j < 4; j++) {
			//cout << ans[j] << endl;
			ans[j] += nextC(index(ans[j], s[i]));
		}
	}

	for (int i = 0; i < 4; i++) {
		if (cond(ans[i], 0) && cond(ans[i], 1)) {
			cout << ans[i] << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N, M;
  cin >> N >> M;

  /* vector<int> A(N); */
  /* REP(i, N) cin >> A[i]; */

  /* sort(ALL(A), greater<int>()); */

  /* REP(i, N) cout << A[i] << endl; */

  int a;
  priority_queue<double> p;
  REP(i, N){
    cin >> a;
    p.push(a);
  }

  REP(i, M){
    double q = p.top(); p.pop();
    p.push(q/2.0);
  }

  int ans = 0;
  REP(i, N){
    ans += (int)p.top(); p.pop();
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    vector<int> l(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                if(l[k] >= l[i]+l[j]) break;
                if(abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j]) ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int func(int a){
	if (a%2==0) return a/2;
	else return 3*a + 1;
}



int main() {
	int s; cin >> s;
	int ans;
	bool flag=false;
	std::vector<int> S;
	S.push_back(s);
	for (int i = 1; i < 200; ++i) S.push_back(func(S[i-1]));
	for (int i = 0; i < 200; ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			if (S[i]==S[j] && !flag) {
				ans = i+1;
				flag = true;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n, m = (int(i) for i in raw_input().split())
a = set([])
for i in range(m):
    a.add(int(raw_input()))

dp = [0 for i in range(n+2)]
for i in range(n+1):
    if i in a:
        dp[i] = 0
    elif i == 0:
        dp[0] = 1
    elif i == 1:
        dp[1] = 1
    else:
        dp[i] = (dp[i-1] + dp[i-2])

print (dp[n] % 1000000007)


Measured memory_bytes: 462812
#include <bits/stdc++.h>
using namespace std;
long long ans,n;
int bkt[10];

void dfs(string s, bool three, bool five, bool seven){
  long long ns = stoll(s);
  if(three&&five&&seven&&ns<=n){
    ans++;
  }else if(n<ns){
    return ;
  }
  dfs(s + "3", true, five, seven);
  dfs(s + "5", three, true, seven);
  dfs(s + "7", three, five, true);
}

int main(){
  cin >> n;
  ans = 0;
  dfs("3", true, false, false);
  dfs("5", false, true, false);
  dfs("7", false, false, true);
  cout << ans << endl;
}
    
      

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

typedef long long ll;

const ll INF = 1'000'000'000'007;

bool chmax(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	int P[N], C[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", P + i);
		P[i]--;
	}
	for (int i = 0; i < N; i++) scanf("%d", C + i);
	ll ans = -INF;
	for (int i = 0; i < N; i++) {
		int cnt = 1;
		ll M = C[i];
		ll pnt = C[i];
		for (int j = P[i]; ++cnt <= K && j != i; j = P[j]) {
			pnt += C[j];
			chmax(M, pnt);
		}
		// fprintf(stderr, "%d %lld\n", cnt, pnt);
		if (cnt > K || pnt < 0) {
			chmax(ans, M);
			continue;
		}
		cnt--;
		ll rot = K / cnt - 1;
		ll tmp = pnt * rot;
		ll k = K - rot * cnt;
		cnt = 1;
		M = C[i];
		pnt = C[i];
		for (int j = P[i]; ++cnt <= k; j = P[j]) {
			pnt += C[j];
			chmax(M, pnt);
		}
		chmax(ans, tmp + M);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

vector<string> split(const string& s, char delimiter) {
    vector<string> tokens;
    string token;
    istringstream tokenStream(s);
    while (getline(tokenStream, token, delimiter)) {
        tokens.push_back(token);
    }
    return tokens;
}


int main()
{
    string date;
    cin >> date;
    vector<string> d;
    vector<int> parseddate;
    boost::split(d, date, boost::is_any_of("/"));
    for (auto elem : d) {
        parseddate.push_back(stoi(elem));
    }
    if (parseddate.at(0) <= 2018) {
        cout << "Heisei" << endl;
        return 0;
    } else if (parseddate.at(0) >= 2020) {
        cout << "TBD" << endl;
        return 0;
    } else {
        if (parseddate.at(1) <= 3) {
            cout << "Heisei" << endl;
            return 0;
        } else if (parseddate.at(1) >= 5) {
            cout << "TBD" << endl;
            return 0;
        } else {
            if (parseddate.at(2) <= 30) {
                cout << "Heisei" << endl;
                return 0;
            } else {
                cout << "TBD" << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
ll cnt[26];
int main() {
    string A; cin >> A;
    ll len = A.length();
    rep(i,len) cnt[A[i]-'a']++;
    ll ans = len * (len - 1) / 2;
    rep(i,26) {
      if(cnt[i] >= 2) {
        ans -= cnt[i] * (cnt[i] - 1) / 2;
      }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin  >> n;
    string S;
    map<char, int> mp;

    REP(i,n){
        cin  >> S;
        mp[S[0]] ++;
    }
 
    long long ans = 0, x;
    string s = "MARCH";

    REP(i, 4){
        FOR(j, i+1, 5){
            vector<bool> f(5, true);
            f[i] = false;
            f[j] = false;
            x = 1;
            REP(k,5){
                if(f[k]) x *= mp[s[k]];
            }
            ans += x;
        }
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;

vector<int> E[200005];
int dist[200005];


void BFS(int s,int e){
    fill(dist,dist+N,INF);
    queue<P1> que;
    que.push(P1(s,0));
    while(que.size()){
        P1 p=que.front();
        que.pop();
        for(auto u:E[p.first]){
            if(dist[u]>p.second+1){
                dist[u]=p.second+1;
                que.push(P1(u,dist[u]));
            }
        }
    }
}

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    BFS(0,N-1);
    if(dist[N-1]<=2)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 15976
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    char ttng[105][105];
    rep(i,a){
        scanf("%s",ttng[i]);
    }
    for(int i=0,j=0;i<a;i++,j++){
        printf("%s\n",ttng[i]);
        printf("%s\n",ttng[j]);
    }
    return 0;
}


Measured memory_bytes: 1648
Int = input()
Var = int(Int[len(Int) - 1])

if Var == 2 or Var == 4 or Var == 5 or Var == 7 or Var == 9:
    print("hon")

if Var == 0 or Var == 1 or Var == 6 or Var == 8:
    print("pon")

if Var == 3:
    print("bon")

Measured memory_bytes: 9184
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let a: isize;
    let b: isize;
    let c: isize;
    let d: isize;

    input!(a, b, c, d);
    println!(
        "{} {} {} {}",
        c - (d - b),
        d + (c - a),
        a - (d - b),
        b + (c - a),
    );
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)
        return 1;
    else if(power%2)
    {
        ll p1=base%mod;
        ll p2=bigmod(base, power-1, mod) %mod;
        return (p1*p2)%mod;
    }
    else
    {
        ll p= bigmod(base, power/2, mod)%mod;
        return (p*p)%mod;
    }
}

int main()
{
    ll t,n,i,j,k,l,mn=0, mx=0;
    sl(n);
    if(n==1)
    {
        cout<<0;
        return 0;
    }



    ll ans=bigmod(10LL, n, md);
    ans= (ans%md - (2*bigmod(9LL, n, md))%md + md) %md ;
    ans+=bigmod(8LL, n, md);
    ans%=md;

    cout<<ans;
}



Measured memory_bytes: 3740
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}else if(a>b){
		cout<<"a > b"<<endl;
	}else if(a==b){
		cout<<"a == b"<<endl;
	}
	
		return 0;
}

Measured memory_bytes: 3056
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

int main(){
  FAST;
  LL i,ans=0,X,Y,Z;
  cin>>X>>Y>>Z;
  swap(X,Y);
  swap(X,Z);

  cout<<X<<" "<<Y<<" "<<Z<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<algorithm>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef complex<double> P;
typedef pair<double,double> point;


double dot(P a,P b){
	return real(conj(a)*b);
}

double cross(P a,P b){
	return imag(conj(a)*b);
}

double dist(P a, P b,P c){
	if(dot(b-a,c-a)<0)return abs(c-a);
	if(dot(a-b,c-b)<0)return abs(c-b);
	return abs(cross(c-a,b-a))/abs(b-a);
}

int main(){
	int n,m;
	double x,y,r;
	P taro,oni;
	vector<pair<P,double> > circle; 
	while(cin>>n,n){
		circle.clear();
		rep(i,n){
			cin>>x>>y>>r;
			circle.pb(pair<P,double>(P(x,y),r));
		}
		cin>>m;
		rep(p,m){
			cin>>x>>y;
			taro=P(x,y);
			cin>>x>>y;
			oni=P(x,y);
			bool check=false;
			rep(i,n){
				r=circle[i].second;
				double d=dist(taro,oni,circle[i].first);
				if(d<=r && (abs(taro-circle[i].first)>=r || abs(oni-circle[i].first)>=r)){
					check=true;
					break;
				}
			}
			if(check)cout<<"Safe"<<endl;
			else cout<<"Danger"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1252
#include <limits.h>
#include <stdio.h>
#include <string.h>

inline int dif(int a, int b){return a<b?b-a:a-b;}

int h, w, i, j;
int l, k;
int a[81][81];
char d[81][81][12801];

int main(void){
	scanf("%d%d", &h, &w);
	l = (h+w-1)*80;
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			scanf("%d", &k);
			a[i][j] = dif(k, a[i][j]);
		}
	}
	d[0][0][a[0][0]]=1;
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			for(k=0; k<=l; k++){
				if(d[i][j][k]==1){
					d[i+1][j][k+a[i+1][j]]=1;
					d[i+1][j][dif(k,a[i+1][j])]=1;
					d[i][j+1][k+a[i][j+1]]=1;
					d[i][j+1][dif(k,a[i][j+1])]=1;
				}
			}
		}
	}
	for(k=0; k<=l; k++){
		if(d[h-1][w-1][k]==1) break;
	}
	printf("%d\n", k);
}



Measured memory_bytes: 81280
using System;
using System.Collections.Generic;

namespace ABC071B
{
    class Program
    {
        static void Main(string[] args)
        {
            string target = Console.ReadLine();
            int[] t = new int[26];
            for(int i=0; i< 26;i++){
                t[i] = 0;
            } 
            for(int i=0; i< target.Length;i++){
                t[(int)(target[i]-'a')]++;
            } 
            Boolean f = false;
            Boolean c = true;
            for(int i=0; i< 26;i++){
                if(t[i] == 0 && c) {
                    f = true; c = false;
                    Console.Write((char)(i + 'a'));
                }
            } 
            if(!f) Console.WriteLine("None");
        }
    }
}


Measured memory_bytes: 13140
import sys
from collections import Counter
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))


table = Counter()
for a in A:
    table[a] += 1

table = list(table.values())
table.sort(reverse = True)
L = len(table)
ata = table[:] + [0]
for i in range(1, L):
    ata[i] += ata[i-1]


vm = [-1]*(N+2)
for med in range(N, 0, -1):
    idx = -1
    for v in range(max(0, vm[med+1]), L):
        if table[v] <= med:
            break
        idx = v
    vm[med] = idx
Ans = [None]*N
for k in range(1, N+1):
    ok = 0
    ng = N//k+1
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        res = N - ata[vm[med]] + med*(vm[med]+1)
        if res >= k*med:
            ok = med
        else:
            ng = med
    Ans[k-1] = ok
print('\n'.join(map(str, Ans)))

Measured memory_bytes: 126000
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;cin>>n;
  long int a[n];int m=0;int c=0;
  for(int i=0;i<n;i++)
  {
  cin>>a[i];
  }int i=0;
 while(i<n-1)
 {while(a[i+1]<=a[i])
 {c++;i++;}
   if(c>m)
     m=c;
     c=0;i++;
   }
  cout<<m;
}

Measured memory_bytes: 1152
// バイナリーハックイージー
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size(),len=0;
    char ans[100]={};
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            if(len){
                len--;
            }
        }else{
            ans[len]=s[i];
            len++;
        }
    }
    for(int i=0;i<len;i++){
        cout<<ans[i];
    }cout<<endl;
    return 0;
}

Measured memory_bytes: 256