akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N, L;

struct node {
	node* ch[2];
	node() {
		ch[0] = ch[1] = nullptr;
	}
	void putstr(const char *str) {
		if (*str == '\0')return;
		if (!ch[(*str) - '0'])
			ch[(*str) - '0'] = new node();
		ch[(*str) - '0']->putstr(str + 1);
	}
	//最後の子か？
	bool eval() {
		if (!ch[0] && !ch[1])return true;
		if (ch[0] && ch[1]) {
			if (ch[0]->eval() && ch[1]->eval()) {
				ch[0] = ch[1] = nullptr;
				return true;
			}
		}
		return false;
	}
	int grundy(int d) {
		if (!ch[0] && !ch[1]) {
			//ここに文字列がある⇒黒
			return 0;
		}
		if (!ch[0] && ch[1]) {
			//片方(ch0)は白い木　もう片方(ch1)は灰色木
			int val = ch[1]->grundy(d + 1);
			LL chim = L - (LL)d;
			LL lev = 0;
			while (chim % 2 == 0) {
				lev++;
				chim /= 2;
			}
			val ^= (1 << lev);
			return val;
		}
		if (ch[0] && !ch[1]) {
			//片方(ch1)は白い木　もう片方(ch0)は灰色木
			int val = ch[0]->grundy(d + 1);
			LL chim = L - (LL)d;
			LL lev = 0;
			while (chim % 2 == 0) {
				lev++;
				chim /= 2;
			}
			val ^= (1 << lev);
			return val;
		}
		//両方灰色木
		return ch[0]->grundy(d + 1) ^ ch[1]->grundy(d + 1);
	}
};

char str[114514];

int main(void)
{
	node root;
	cin >> N >> L;
	for (int i = 0; i < N; ++i) {
		cin >> str;
		root.putstr(str);
	}
	root.eval();
	bool ans = root.grundy(0);
	if (ans) {
		cout << "Alice\n";
	}
	else {
		cout << "Bob\n";
	}
	return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;

int main(void){
    string s; 
    cin >> s;

    int n = s.size();
    int cnt = 0;

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 1; i < n; i++){
        if(s.at(i - 1) == s.at(i)){
            if(s.at(i - 1) == '0'){
                s.at(i) = '1';
                cnt++;
            }
            else{
                s.at(i) = '0';
                cnt++;
            }
        }
    } 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

int main() {
    int D,G;
    scanf("%d %d", &D, &G);
    int p[D];
    int c[D];
    for(int i = 0; i<D; i++) scanf("%d %d" , &p[i], &c[i]);

    int res = INT_MAX;
    for(int i = 0; i < (1 << D); i++) {
        int cnt = 0;
        int sum = 0;
        int oth = 0;
        for(int j = 0; j<D; j++) {
            if(i & (1<<j)) {
                cnt += 100*(j+1) * p[j] + c[j];
                sum += p[j];
            } else oth = j;
        }
        if(cnt < G) {
            int tmp = 100*(oth+1);
            int chk = (G - cnt + tmp - 1) / tmp;
            if (chk > p[oth]) continue;
            sum += chk;
        }
        res = min(res , sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
  int n,k; cin>>n>>k;
  
  map<int,int> mp;
  REP(i,n){
    int a; cin>>a;
    mp[a]++;
  }
vector<int> v;

 int res=0;
 for(auto itr = mp.begin(); itr != mp.end(); ++itr){
  v.push_back(itr->second);
}
 sort(ALL(v));
 int t=v.size()-k;//一旦変数でおかないとエラー139
 REP(i,t)res+=v[i];
 cout<<res<<endl;
}

Measured memory_bytes: 10748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S1 = sc.next(), S2 = sc.next(), S3 = sc.next();
		int cnt1 = 0, cnt2 = 0, cnt3 = 0;
		char turn = 'a';
		for(;;) {
			if(turn == 'a') {
				if(cnt1 == S1.length()) {
					System.out.println("A");
					return;
				}
				turn = S1.charAt(cnt1);
				cnt1++;
			} else if(turn == 'b') {
				if(cnt2 == S2.length()) {
					System.out.println("B");
					return;
				}
				turn = S2.charAt(cnt2);
				cnt2++;
			} else {
				if(cnt3 == S3.length()) {
					System.out.println("C");
					return;
				}
				turn = S3.charAt(cnt3);
				cnt3++;
			}
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
// typedef pair<int, int> P;
// typedef pair<int, P> PP;
// typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int MAX = 3e3;

typedef pair<string, string> P;
string str;
map<P, int> mp;
signed main(){
  int n;
  cin >> n >> str;
  rep(s,1<<n){
    string s1 = "", s2 = "";
    rep(j,n){
      if(s & (1<<j))s1.pb(str[n+j]);
      else s2.pb(str[n+j]);
    }
    reverse(all(s1));
    reverse(all(s2));
    mp[P(s2, s1)]++;
  }
  int ans = 0;
  rep(s,1<<n){
    string s1 = "", s2 = "";
    rep(j,n){
      if(s & (1<<j))s1.pb(str[j]);
      else s2.pb(str[j]);
    }
    ans += mp[P(s1, s2)];
  }
  printf("%lld\n", ans);
  return 0;
}










Measured memory_bytes: 87040
a,b,c,x,y = map(int,input().split())
cost = 0
cost += min(x,y)*min(a+b,2*c)
if x > y:
    cost += (x-y)*min(2*c,a)
if y > x:
    cost += (y-x)*min(2*c,b)
print(cost)

Measured memory_bytes: 3060
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S, T;
  cin >> S >> T;
  const int64_t N = static_cast<int64_t>(S.length());
  vector<char> from_s_to_t(256, 0);
  vector<char> from_t_to_s(256, 0);
  bool is_okay = true;
  for (int64_t i = 0; i < N; ++i) {
    const char ch_s = S.c_str()[i];
    const char ch_t = T.c_str()[i];
    if ((from_s_to_t[ch_s] != 0 && from_s_to_t[ch_s] != ch_t) ||
        (from_t_to_s[ch_t] != 0 && from_t_to_s[ch_t] != ch_s)) {
      is_okay = false;
    } else {
      from_s_to_t[ch_s] = ch_t;
      from_t_to_s[ch_t] = ch_s;
    }
  }
  if (is_okay) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 916
import math
n, k = map(int, input().split())

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
nn = 1+n if n < k else k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, math.ceil(math.log(k, 2))):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += (n-k+1) / n
print(r)

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int n, m;
int vis[1000] = {};
int G[1000][1000] = {};
int a, b;

bool dfs(int i, int c) {
    vis[i] = c;
    if (c == 1) a++;
    else b++;
    loop (n, k) {
        if (!G[i][k]) continue;
        if (vis[k] == 0 && !dfs(k, c * -1)) return 0;
        else if (vis[k] != c * -1) return 0;
    }
    return 1;
}

int main() {
    cin >> n >> m;
    loop (n, i) loop (n, j) if (i != j) G[i][j] = 1;
    loop (m, i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a][b] = 0;
        G[b][a] = 0;
    }

    vec<vec<int>> P;
    loop (n, i) {
        if (vis[i]) continue;
        a = 0, b = 0;
        if (!dfs(i, 1)) {
            cout << -1 << endl;
            return 0;
        }
        P.push_back(vec<int>({ a, b }));
    }

    int dp[701][701] = {};
    dp[0][0] = 1;
    loop (P.size(), i) {
        loop (n, j) {
            if (dp[i][j]) {
                dp[i + 1][j + P[i][0]] = 1;
                dp[i + 1][j + P[i][1]] = 1;
            }
        }
    }

    int s = 0;
    loop (n / 2 + 1, i) {
        if (dp[P.size()][i]) s = i;
    }
    int t = n - s;
    cout << s * (s - 1) / 2 + t * (t - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	x := nextInt()
	n := nextInt()
	sl := makeSlist()
	ans := x

	for i := 0; i < n; i++ {
		sl.add(nextInt())
	}

	for i := 0; i < 100; i++ {
		if !sl.contains(x - i) {
			ans = x - i
			break
		}
		if !sl.contains(x + i) {
			ans = x + i
			break
		}
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if(c >= a && c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int A[300][300];
	rep(i, N) {
		rep(j, M) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	vector<int>n(N);
	vector<int>a;
	int ans = N;
	bool flag = false;
	while (!flag) {
		int smax = 0;
		vector<int>s(M);
		rep(i, N) {
			s[A[i][n[i]]]++;
			if (s[smax] < s[A[i][n[i]]])smax = A[i][n[i]];
		}
		ans = min(ans, s[smax]);
		a.push_back(smax);
		rep(i, N) {
			rep(j,a.size()){
				if (A[i][n[i]] == a[j]) {
					n[i]++;
					j=-1;
					if (n[i] == M) {
						flag = true;
						break;
					}
				}
			}
			if (flag)break;
		}

	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
long double dp[3000][3000];

int main() {
    cout.precision(10);
    int n;
    cin >> n;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        long double p;
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1 - p);
        for(int j = 1; j <= i; j++){
            dp[i][j] = dp[i - 1][j] * (1 - p) + dp[i - 1][j - 1] * p;
        }
    }
    long double ans = 0;
    for(int i = n; i > n - i; i--){
        ans += dp[n][i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 139008
#include "bits/stdc++.h"

#include <atcoder/all>

using namespace std;
using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<int, int>;
signed main() {
	int N; cin >> N;
	vector<pair<int, P>>p;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		p.push_back({ x,{y,i} });
	}
	sort(p.begin(), p.end());
	set<P>st;
	dsu uf(N);
	for (int i = 0; i < N; i++) {
		st.insert({ p[i].second.first, p[i].second.second });
	}
	for (int i = 0; i < N; i++) {
		int t = p[i].second.first, idx = p[i].second.second;
		auto itr = st.upper_bound({ t,idx });
		while (itr != st.end()) {
			int idx2 = (*itr).second;
			if (uf.same(idx, idx2))break;
			uf.merge(idx, idx2);
			itr++;
		}
		st.erase({ t,idx });
	}
	for (int i = 0; i < N; i++) {
		cout << uf.size(i) << endl;
	}
	return 0;
}


Measured memory_bytes: 15916
#include<iostream>
#include<vector>
using namespace std;
using i64 = long long;
int main(){
    int N, K;
    cin >> N >> K;

    vector<vector<i64>> dp(N+1, vector<i64>(N+1, 0));
    dp[0][0] = 1;

    const i64 MOD = 1e9 + 7;
    for(int n = 0; n < N; n++){
        for(int r = 0; r <= n; r++){
            dp[n+1][r] = (dp[n+1][r] + dp[n][r]) % MOD;
            dp[n+1][r+1] = (dp[n+1][r+1] + dp[n][r]) % MOD; 
        }
    }

    for(int i = 1; i <= K; i++){
        cout << (dp[K-1][i-1] * dp[N-K+1][i]) % MOD << endl; 
    }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {
    int A,B,T;
    cin >> A >> B >> T;
    cout << (T/A)*B << endl;
}



Measured memory_bytes: 256
n = gets.to_i
ts = gets.chomp.split.map(&:to_i)
T = ts.inject(:+)
vs = gets.chomp.split.map(&:to_i)

v = [0]
n.times do |i|
  v[v.size - 1] = [v[v.size - 1], vs[i]].min
  v += [vs[i]] * (ts[i] * 2)
end
v[v.size-1]=0

(2*T).times do |t|
  v[t+1] = [v[t+1], v[t] + 0.5].min
end

(0...(v.size-1)).to_a.reverse.each do |t|
  v[t] = [v[t], v[t+1] + 0.5].min
end

ans = 0
(v.size-1).times do |t|
  ans += v[t] + v[t+1]
end
p ans/4
#
# v.size.times do |t|
#   puts "#{t*0.5} #{v[t]}"
# end


Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int H, W, A, B; cin >> H >> W >> A >> B;
    F0R(i, H) {
        string ans;
        F0R(j, W) {
            ans += (((j >= A) + (i >= B)) % 2 == 0) ? '1' : '0';
        }
        cout << ans << endl;
    }
}

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

int main() {
	string w, t;
	int count = 0;
	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::toupper);
	while (1) {
		cin >> t;
		if (t == "END_OF_TEXT")
			break;
		transform(t.begin(), t.end(), t.begin(), ::toupper);
		if (w==t)
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	int N, M;
	cin >> N >> M;
	vector<int>cnt(M);

	for (int i = 0; i < N;i++)
	{
		int K;
		cin >> K;
		for (int j = 0; j < K; j++)
		{
			int A;
			cin >> A;
			A--;
			cnt[A]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < M; i++)
	{
		if (cnt[i] == N) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
// #define N 1000005
#define ull unsigned long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define ull unsigned long long 
#define sc second
#define pb push_back
#define mp make_pair
#define sp <<" "
#define all(a) (a).begin(),(a).end()
#define fi(i,a,n) for(int i=a ; i<n ; i++)
#define fd(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define r0 return 0;
#define ln "\n"
#define INF (int)1e15
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
	// fast
    // int t;cin>>t;
    // while(t--){

    // }
    ll n;cin>>n;
    vector<int>v(n);
    fi(i,0,n) cin>>v[i];
    ll ans=0;
    fi(i,1,n){
        if(v[i]<v[i-1]){
            ans+=v[i-1]-v[i];
            v[i]=v[i-1];
        }
    }
    cout<<ans<<"\n";
	r0;
}
 

Measured memory_bytes: 4048
#include<stdio.h>
#include<stdlib.h>

int fibonacci(int);

int main(){
  int n;
  int output;

  scanf("%d",&n);

  printf("%d\n",fibonacci(n+1));

  return 0;
}

int fibonacci(int n){
  int *F=(int*)malloc(n*sizeof(int));
  int output;

  F[0]=1;
  F[1]=1;

  for(int i=2;i<n;i++){
    F[i]=F[i-1]+F[i-2];
  }
  output=F[n-1];
  free(F);

  return output;
}



Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
long long x;
long long now=100;
int main()
{
	scanf("%lld",&x);
	for (int i=1;;i++)
	{
		now=now+now/100;
		if (now>=x) {printf("%d\n",i); return 0;}
	}
return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N, K; cin >> N >> K;
  int res = K;
  for (int i = 0; i < N-1; ++i) {
    res *= (K-1);
  }
  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	int q;
	std::cin >> q;
	for (int i = 0;i < q;i++) {
		std::string s, t;
		std::cin >> s >> t;
		int dp[1010][1010];
		for (int j = 0;j < s.size();j++) {
			for (int k = 0;k < t.size();k++) {
				if (s[j] == t[k])dp[j + 1][k + 1] = dp[j][k] + 1;
				else dp[j + 1][k + 1] = std::max(dp[j][k + 1], dp[j + 1][k]);
			}
		}
		std::cout << dp[s.size()][t.size()] << std::endl;
	}
}


Measured memory_bytes: 7108
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("Yes\n")
#define NO printf("No\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 105
char a[N][N];
const lld dirx[4] = {1,-1,0,0};
const lld diry[4] = {0,0,1,-1};
int main()
{
    //sync;
    lld n,flag = 0,m;
    cin>>n>>m;
    rep(i,1,n+1) rep(j,1,m+1) cin>>a[i][j];
    rep(i,1,n+1) rep(j,1,m+1) if(a[i][j]=='#') {
        lld cnt = 0;
        rep(k,0,4) {
            if(a[i+dirx[k]][j+diry[k]] == '#') cnt++;
        }
        // cout<<i<<" "<<j<<" "<<cnt<<endl;
        if(cnt == 0) return 0*NO;
    }
    YES;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main() {
    ll h;
    ll w;
    cin>>h>>w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
 
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }
 
    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}
    
    



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int X;
    cin >> X;
    if(X == 3 || X == 5 || X == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,s,c=0,i;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s;
        if(i%2!=0 && s%2!=0)
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;

int main(){

    int N;
    cin >> N;

    int max_num = 1;
    for(int i=1; i<=N; i++) max_num *= 3;

    int temp, buf = 1;
    for(int i=0; i<N; i++){
        cin >> temp;

        if(temp%2 == 0) buf *= 2;
    }

    cout << max_num - buf << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a-b-c<0){
		d=b+c-a;
	}else{
		d=0;
	}
	printf("%d %d\n",min(b,c),d);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	string s;
	cin >> s;
	vector<string> c = { "dream","dreamer","erase","eraser" };
	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) {
		reverse(c[i].begin(),c[i].end());
	}
	for (int i = 0; i < s.size();) {
		int flag = 0;
		for (int j = 0; j < 4; j++) {
			if (s.substr(i, c[j].size()) == c[j]) {
				i = i + c[j].size();
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    _ = input()
    a = list(map(int, input().split()))

    result = 1
    for a_i in a:
        if a_i == 0:
            return 0

    for a_i in a:
        result *= a_i

        if 10**18 < result:
            return -1

    return result


if __name__ == '__main__':
    result = main()
    print(result)


Measured memory_bytes: 21600
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

vector<int> graph[100001];
long long dp1[100001], dp2[100001];

void dfs(int node, int parent) {
    for (auto& i : graph[node]) {
        if (i == parent) continue;
        dfs(i, node);
        dp1[node] = (dp1[node] * (dp1[i] + dp2[i]) % MOD + MOD) % MOD;
        dp2[node] = (dp2[node] * dp1[i] + MOD) % MOD;
    }
}

int main() {
	int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    fill(dp1, dp1 + 100001, 1);
    fill(dp2, dp2 + 100001, 1);
    dfs(1, 0);
    cout << (dp1[1] + dp2[1]) % MOD << '\n';
	return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scn  = new Scanner(System.in);
        System.out.println(maxVolume(scn.nextDouble()));
    }
    static double maxVolume(double l){
        return  l/3 * (l- l/3)/2 *(l - l/3 - (l-l/3)/2);

    }


}
// 2 4 6 8 10 12


Measured memory_bytes: 23124
import math
A, B, H, M = [ int(i) for i in input().strip().split(' ')]

h = (H / 12 + M / 60 / 12) * 360
m = M / 60 * 360

hx = A * math.cos(math.radians(h - 90))
hy = A * math.sin(math.radians(h - 90))
mx = B * math.cos(math.radians(m - 90))
my = B * math.sin(math.radians(m - 90))

print(math.sqrt((hx-mx)**2+(hy-my)**2))

Measured memory_bytes: 9532
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;

long long n,ans;
int main()
{
     while(cin >> n)
     {
//          cout << __gcd(n,(long long)2) << endl;
        if(__gcd((long long)2 ,n) == 1)
          cout << (long long)2 * n << endl;
        else {
             cout << n << endl;

        }
     }
     return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int w,h,x,y,r;cin>>w>>h>>x>>y>>r;
    if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 3232
N,M = map(int,input().split())
X = sorted(list(map(int,input().split())))
diff = []
for i in range(M-1):
    diff.append(X[i+1] - X[i])
diff.sort(reverse = True)
if N >= M:
    print(0)
else:
    for i in range(N-1):
        diff.pop(0)
    print(sum(diff))

Measured memory_bytes: 13968
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a= 0;

  for(int i = 0 ; i < 5; i += 2){
    if(pow(10, i) > n) break;
    a += min(n, (int)pow(10,i+1)-1) - (int)pow(10, i)+1;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll A,B,C,D,E;
    cin >> A >> B >> C;
    ll cnt=0;
    while(true){
        if(A%2==1||B%2==1||C%2==1){
            cout << cnt;
            return 0;
        }
        if(A==B&&B==C){
            cout << -1;
            return 0;
        }
        D=A;E=B;
        A=(B+C)/2;
        B=(D+C)/2;
        C=(D+E)/2;
        cnt++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int a,b;

int main(){
    cin>>a>>b;
    if(a==1){
        a=14;
    }
    
    if(b==1){
        b=14;
    }

    if(a==b){
        cout << "Draw" << endl;
    }else if(a>b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    
}

Measured memory_bytes: 256
def io_tmp():
    global input
    import io, sys
    #f = io.StringIO(open(0).read())
    f = io.BytesIO(sys.stdin.buffer.read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = [[float("inf")] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s-1][t-1] = graph[t-1][s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = dist <= L
#np.fill_diagonal(graph, 0)
#graph[dist > L] = 0
dist = floyd_warshall(graph, directed=False)
dist[np.isinf(dist)] = 0
dist = dist.astype(int)

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(dist[s-1][t-1] - 1)
print(*ans, sep='\n')


Measured memory_bytes: 22144
#include <bits/stdc++.h>              
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

//-------------------------------------------------

int n, m;
vector<P> v;

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

	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v.pb(P(b, a));
	}
	sort(ALL(v));
	int ans = 0, r = -1;
	for (auto p: v) {
		if (r > p.se) continue;
		r = p.fi;
		ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
priority_queue < int > pq;
int main() {
	int n,m;
	cin>>n>>m;
	long long cost=0;
	for(int i=0;i<n;i++) {
		int a;
		cin>>a;
		pq.push(a);
	}
	while(m--) {
		int a=pq.top();
		pq.pop();
		pq.push(a/2);
	}
	for(int i=0;i<n;i++) {
		cost+=pq.top();
		pq.pop();
	}
	cout<<cost<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  vector<string> v(3);
  rep(i,3) cin>>v[i];
  if(v[0][v[0].length()-1]==v[1][0] && v[1][v[1].length()-1]==v[2][0]) cout<<"YES"<<endl;  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}


int main() {
    
    ll N = lin();
    ll X = lin();
    
    vector<ll> x;
    
    for(auto i = 0; i<N; i++){
        x.push_back(abs(lin()-X));
    }
    
    ll pre = x[0];
    for(auto i = 1; i<N;i++){
        
        pre = gcb(pre,x[i]);
        
    }
    
    cout << pre << endl;
  
    
    
    return 0;
}






Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define mod 1000000007;

main(){
  int n,k; cin >> n >> k;
  long long ans = 1;
  rep(i,n)
    if(i == 0) ans *= k;
    else ans *= k-1;
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramD
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var w = long.Parse(inputs[1]);

            var list = new long[n, 2];
            for (var i = 0; i < n; i++)
            {
                var inputs1 = Console.ReadLine().Split(" ");
                list[i, 0] = long.Parse(inputs1[0]);
                list[i, 1] = long.Parse(inputs1[1]);
            }

            var dp = new long[n + 1, w + 1];
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < w + 1; j++)
                {
                    if (j >= list[i, 0])
                    {
                        dp[i + 1, j] = Math.Max(dp[i, j - list[i, 0]] + list[i, 1], dp[i, j]);
                    }
                    else
                    {
                        dp[i + 1, j] = dp[i, j];
                    }
                }
            }

            Console.WriteLine(dp[n, w]);
        }

    }
}


Measured memory_bytes: 105232
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;
const int MAXM = 100005;

struct bpm{
	vector<int> gph[MAXN];
	int dis[MAXN], l[MAXN], r[MAXM], vis[MAXN];
	void clear(){ for(int i=0; i<MAXN; i++) gph[i].clear();	}
	void add_edge(int l, int r){ gph[l].push_back(r); }
	bool bfs(int n){
		queue<int> que;
		bool ok = 0;
		memset(dis, 0, sizeof(dis));
		for(int i=0; i<n; i++){
			if(l[i] == -1 && !dis[i]){
				que.push(i);
				dis[i] = 1;
			}
		}
		while(!que.empty()){
			int x = que.front();
			que.pop();
			for(auto &i : gph[x]){
				if(r[i] == -1) ok = 1;
				else if(!dis[r[i]]){
					dis[r[i]] = dis[x] + 1;
					que.push(r[i]);
				}
			}
		}
		return ok;
	}
	bool dfs(int x){
		if(vis[x]) return 0;
		vis[x] = 1;
		for(auto &i : gph[x]){
			if(r[i] == -1 || (!vis[r[i]] && dis[r[i]] == dis[x] + 1 && dfs(r[i]))){
				l[x] = i; r[i] = x;
				return 1;
			}
		}
		return 0;
	}
	int match(int n){
		memset(l, -1, sizeof(l));
		memset(r, -1, sizeof(r));
		int ret = 0;
		while(bfs(n)){
			memset(vis, 0, sizeof(vis));
			for(int i=0; i<n; i++) if(l[i] == -1 && dfs(i)) ret++;
		}
		return ret;
	}
	bool chk[MAXN + MAXM];
	void rdfs(int x, int n){
		if(chk[x]) return;
		chk[x] = 1;
		for(auto &i : gph[x]){
			chk[i + n] = 1;
			rdfs(r[i], n);
		}
	}
	vector<int> getcover(int n, int m){ // solve min. vertex cover
		match(n);
		memset(chk, 0, sizeof(chk));
		for(int i=0; i<n; i++) if(l[i] == -1) rdfs(i, n);
		vector<int> v;
		for(int i=0; i<n; i++) if(!chk[i]) v.push_back(i);
		for(int i=n; i<n+m; i++) if(chk[i]) v.push_back(i);
		return v;
	}

}bpm;

int n, M[MAXN];
int proc[MAXN];
pi dap[MAXN];

vector<int> E[MAXN];
vector<int> R[MAXN];
queue<int> que;

int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int s;
		scanf("%d",&s);
		E[i].resize(s);
		for(auto &j : E[i]){
			scanf("%d",&j);
			R[j].push_back(i);
			if(j != 1) bpm.add_edge(i, j);
		}
	}
	int x = bpm.match(n + 1);
	if(x != n - 1){
		puts("-1");
		return 0;
	}
	for(int i=1; i<n; i++) M[i] = bpm.l[i];
	que.push(1);
	vector<pi> edg;
	while(!que.empty()){
		int x = que.front();
		que.pop();
		for(auto &j : R[x]){
			if(proc[j]) continue;
			proc[j] = 1;
			dap[j] = pi(M[j], x);
			que.push(M[j]);
		}
	}
	for(int i=1; i<n; i++) printf("%d %d\n", dap[i].first, dap[i].second);
}


Measured memory_bytes: 21720
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  x <- readInteger
  let p = x `div` 11
      r = if x `mod` 11 == 0 then 0 else if x `mod` 11 <= 6 then 1 else 2
  print $ 2 * p + r


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  r(i,n)cin >> v[i];
  r(i,n-1) v[0]=(v[0]^v[i+1]);
  if(v[0]==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

public class Program
{
    static List<double> results = new List<double>();

    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var valuesStr = Console.ReadLine().Split(' ');
        var values = new double[n];
        for (int i = 0; i < values.Length; i++)
        {
            values[i] = double.Parse(valuesStr[i]);
        }
        Array.Sort(values);
        double value = values[0];

        for (int i = 1; i < values.Length; i++)
        {
            value = (value + values[i]) / 2.0;
        }
        Console.WriteLine(value);
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(c>=a && c<=b) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 22868
#include<vector>
#include<iostream>
#include<algorithm>
int ReturnCap(std::vector<int> Baggage, int P, int k) {
	int v = 0, c = 0, ntrack = 0;
	for (int i = 0; i < Baggage.size(); ++i) {
		if (c > 0 && P > 0 && c + Baggage[i] > P) {
			c = 0;
			++ntrack;
		}
		if (ntrack == k) {
			break;
		}
		if (c + Baggage[i] <= P) {
			c += Baggage[i];
			++v;
		}
	}
	return v;
}
int main(void) {
	std::ios::sync_with_stdio(false);
	int n, k,max=0;
	std::cin >> n >> k;
	std::vector<int> Baggage(n, 0);
	for (int i = 0; i < n; ++i) {
		std::cin >> Baggage[i];
		max += Baggage[i];
	}
	int min = 1,P=(min+max)/2;
	while (min <= max) {
		if (n <= ReturnCap(Baggage,  P,  k)) {
			max = P - 1;
		}
		else {
			min = P + 1;
		}
		P = (min + max) / 2;
	}
	std::cout << P + 1 << std::endl;
	//	system("pause");
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n,n){
    vector<string> s(n);
    for(int i=0;i<n;i++){
      cin>>s[i];
      if(i==0)continue;
      int j;
      for(j=0;s[i][j+1]=='.';j++);
      s[i][j]='+';
      for(int k=i-1;k>0;k--){
        if(s[k][j]=='.')s[k][j]='|';
        else break;
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<(int)s[i].size();j++){
        if(s[i][j]=='.')s[i][j]=' ';
      }
      cout<<s[i]<<endl;
    }
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 3472
import string
A2Z="abcdefghijklmnopqrstuvwxyz"

def decode(msg,L):
    t = string.maketrans(A2Z,L)
    s = string.translate(msg,t)
    return s

def affine(msg, a, b):
    L = "".join([A2Z[(i*a+b)%26]for i in range(26)])
    return decode(msg,L)

def rot(msg, a):
    a = a % 26
    L = "".join(A2Z[a:]+A2Z[:a])
    return decode(msg,L)

def checkkey(s):
    c0="t"
    for i in range(26):
        a = 0
        x = affine(s,i,0)
        if x[0]!=c0:
            a = (ord(c0)-ord(x[0]))%26
            x = rot(x,a)
        if x in['this','that']: return i,a
    return -1,-1

n = input()
for i in range(n):
    s = raw_input()
    for w in s.split():
        if len(w)==4:
            a,b = checkkey(w)
            if a!=-1: break
    print affine(s,a,b)

Measured memory_bytes: 4420