akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;


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

	int N, K;
	cin >> N >> K;
	vector<vector<long long int>>dp(N + 1, vector<long long int>(512));
	dp[0][0] = 1;
	for (int j = 0; j <= K; j++) {
		for (int k = 0; k < N; k++) {
			for (int l = 0; l < 512; l++) {
				dp[k + 1][l^j] += dp[k][l];
				dp[k + 1][l^j] %= MOD;
			}
		}
	}
	cout << dp.back()[K] << endl;
}


Measured memory_bytes: 5000
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = ''
    while N != 0:
        N, m = divmod(N, 26)
        if m == 0:
            N -= 1
            S = chr(122) + S
        else:
            S = chr(96 + m) + S
    print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10240
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int c = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		Arrays.parallelSort(t);

		int ans = 0;
		int s = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (cnt == 0) {
				s = t[i];
			}
			if (s + k < t[i] || cnt == c) {
				ans++;
				s = t[i];
				cnt = 1;
			} else {
				cnt++;
			}
		}
		if (cnt > 0) {
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 31896
#include<iostream>
#include<string>
using namespace std;
string s;
double a,d;
long long ans,n,b,c;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>s;
		if(s == "BTC")
		{
			a*=380000;
			b = a;
			d += a - double(b);
		}
		ans+=a;
	}
	c = d;
	ans+=c;
	cout<<ans<<".";
	for(int i=0;i<5;i++)
	{
		d*=10;
		c=d;
		cout<<c;
		d-=c;
	}
	cout<<endl;
}

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

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	int64_t c[n - 1], s[n - 1], f[n - 1];
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0; i < n - 1; i++) {
		int64_t ans = 0;
		for (int64_t j = i, time = 0; j < n - 1; j++) {
			//来年の目標
			//添え字をjと書くべき所にiと書いて無限時間溶かさない
			if (time <= s[j]) {
				ans += s[j] - time + c[j];
				time += s[j] - time + c[j];
			} else {
				int64_t puni = s[j] + f[j] * ((time - s[j] + f[j] - 1) / f[j]);
				ans += c[j] + puni - time;
				time += c[j] + puni - time;
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 384
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

int main() {
	int n, k;
	cin >> k >> n;
	VS d(n);
	rep(i, n)cin >> d[i];

	bool flag = true,jud;
	string str;
	while (1) {
		jud = true;
		str = to_string(k);
		rep(j, n) {
			int pos = str.find(d[j]);
			if (pos != std::string::npos) jud = false;
		}

		if (jud) break;
		else k++;
		//cout << k << endl;
	}
	cout << k << endl;
}



Measured memory_bytes: 256
import java.util.Scanner

/**
 * Setの生成コストをもう少し揃える。
 */
fun main(args: Array<String>) {
    class Drug(a: Int, b: Int, val cost: Int, ma: Int, mb: Int) {
        val excess = a * mb - b * ma
    }

    data class Input(val n: Int, val ma: Int, val mb: Int, val drugs: List<Drug>)
    val (n, ma, mb, drugs) = Scanner(System.`in`).use<Scanner, Input> {
        val n = it.nextInt()
        val ma = it.nextInt()
        val mb = it.nextInt()
        val drugs: List<Drug> = Array(n) {n ->
            Drug(it.nextInt(), it.nextInt(), it.nextInt(), ma, mb)
        }.toList()

        Input(n, ma, mb, drugs)
    }

    var minimumCost = 4001
    var memo: MutableList<Set<Int>>
    var nextMemo: MutableList<Set<Int>> = Array(minimumCost, {mutableSetOf<Int>()}).toMutableList()
    nextMemo[0] = mutableSetOf(0)

    for (i in 0 until n) {
        memo = nextMemo
        nextMemo = mutableListOf(memo[0])
        for (cost in 1 until memo.size) {
            val next = if (cost - drugs[i].cost < 0) {
                memo[cost]
            } else {
                memo[cost - drugs[i].cost].map{it + drugs[i].excess}.toMutableSet().apply{ addAll(memo[cost]) }
            }

            nextMemo.add(next)
            if (0 in nextMemo[cost]) {
                minimumCost = cost
                break
            }
        }

    }

    println(if (minimumCost == 4001) -1 else minimumCost)
}


Measured memory_bytes: 164596
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
struct DepthFirstSearch {
    n: usize,
    vals: Vec<(usize, usize)>,
    memo: Vec<Vec<i64>>,
}
impl DepthFirstSearch {
    fn rec(&mut self, k: usize, usable_weight: usize) -> usize {
        if self.memo[k][usable_weight] != -1 {
            return self.memo[k][usable_weight] as usize;
        }

        if usable_weight == 0 || k == self.n {
            return 0;
        }
        let (w, v) = self.vals[k];
        let res = if usable_weight >= w {
            let val1 = self.rec(k + 1, usable_weight - w) + v;
            let val2 = self.rec(k + 1, usable_weight);
            max(val1, val2)            
        } else {
            self.rec(k + 1, usable_weight)
        };
        self.memo[k][usable_weight] = res as i64;
        return res;
    }
}

fn main() {
    input! {
        n: usize,
        w: usize,
        vals: [(usize, usize); n],
    }
    let memo = vec![vec![-1; w + 1]; n + 1];
    let mut dfs = DepthFirstSearch{ n: n, vals: vals, memo: memo };
    println!("{}", dfs.rec(0, w))
} 


Measured memory_bytes: 106748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x)
{
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
template <class T>
inline T sqr(T x) { return x * x; }

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

// constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

// debug
#define dump(x) cerr << #x << " = " << x << endl;
#define debug(x) cerr << #x << " = " << x << " (L" << __LINE__ << ")"   \
  << " " << __FILE__ << endl;

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main(int argc, char const *argv[])
{
  int a, b;
  CIN(a), CIN(b);
  if(b % a == 0) COUT(a+b);
  else COUT(b-a);
  return 0;
}


Measured memory_bytes: 256
while True:
	n,x = map(int,input().split(" "))

	if n == 0 and x == 0:
		break

	#データリスト作成
	data = [m for m in range(1,n+1)]
	data_list = []
	cnt = 0
	#n種類の数字があって、xになる組み合わせは？
	for i in range(1,n+1):
		for j in range(1+i,n+1):
			for k in range(1+j,n+1):
				if i+j+k == x:
					cnt += 1

	print(cnt)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    for(ll i=k;i<n;i++)
    {
        if(arr[i]>arr[i-k])
        {
            cout <<"Yes\n";
        }
        else
        {
            cout <<"No\n";
        }
    }

}


Measured memory_bytes: 4836
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int pedras[100100];
long long dp[100100]; ///Guardo os valores da funcao frog;

int n,k;
const int inf = 1e9;

int frog2(int i,int j){

    if(dp[i] != -1){
        return dp[i];
    }

    int menor = inf;

    if(i>=j) return dp[i]=0;

    for(int x=1;x<=k;x++){ ///i=0; i=1;i=2;i=3;
        if(i+x <= j){      ///x=1, x=1;x=1;x=1;
            long long cost = (frog2(i+x,j)+ abs(pedras[i]-pedras[i+x]));

            if(cost < menor){
                menor = cost;
            }
        }
    }

    return dp[i] = menor;
}

int main(){

    memset(dp,-1,sizeof(dp));

    cin >>n>>k;

    for(int i=0;i<n;i++){
        cin >> pedras[i];
    }

    cout<<frog2(0,n-1)<<endl;
}


Measured memory_bytes: 12576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k, a[1010];
int ans;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < k; i++) ans += a[i];
	cout << ans << endl;
}

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

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

// mod add
const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

// 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
// "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
long long solve(int N) {
    auto dp = make_vec<long long>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                 for (int k = 0; k < 5; ++k) {
                     for (int l = 1; l < 5; ++l) {
                         if (i == 1 && j == 2 && l == 3) continue;
                         if (i == 1 && k == 2 && l == 3) continue;
                         if (j == 1 && k == 2 && l == 3) continue;
                         if (j == 2 && k == 1 && l == 3) continue;
                         if (j == 1 && k == 3 && l == 2) continue;
                         add(dp[n+1][j][k][l], dp[n][i][j][k]);
                     }
                }
            }
        }
    }
    long long res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                add(res, dp[N][i][j][k]);
    return res;
}

int main() {
    int N;
    while (cin >> N) cout << solve(N) << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

#define reps(i, f, n) for (int i = (f); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

const int N = 111111;
int n, q;
int a[N];
int b[N];
int c[N];

void init()
{
	cin >> n;
	rep(i, n) cin >> a[i];
	cin >> q;
	rep(i, q) cin >> b[i] >> c[i];
}

int cnt[N];

void solve()
{
	rep(i, n) cnt[a[i]]++;

	ll sum = 0;
	rep(i, N)
	{
		sum += cnt[i] * i;
	}

	rep(i, q)
	{
		int prev = b[i];
		int next = c[i];
		int minus = cnt[prev] * prev;
		int plus = cnt[prev] * next;

		cnt[next] += cnt[prev];
		cnt[prev] = 0;
		sum += plus;
		sum -= minus;
		cout << sum << endl;
	}
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,sum=0;
  cin>>n;
  vector<int64_t> a(n),vec(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i)
  {
    sum+=a[i];
    vec[i]=sum;
  }
  int64_t cnt=1;
  for (int i = n-2; i >= 0; --i)
  {
    if(vec[i]*2>=a[i+1]) cnt++;
    else break;
  }
  cout<<cnt;
}

Measured memory_bytes: 1792
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    if(a>=13)   cout<<b<<endl;
    else if(a>=6 && a<=12)  cout<<b/2<<endl;
    else                    cout<<0<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) :
		src(src_), dst(dst_), weight(weight_) { }
	Edge(int src_, int dst_) :
		src(src_), dst(dst_) {

	}
};
pair<bool, vector<Weight>> spfa(const int v_num, const vector<vector<Edge>>&es, const int start) {
	vector<Weight>diss(v_num, INT_MAX);
	queue<int>que;
	vector<bool>use(v_num);
	vector<int>count(v_num);
	que.emplace(start);
	diss[start] = 0;
	while (!que.empty()) {
		int src(que.front());
		que.pop();
		use[src] = false;
		for (auto e : es[src]) {
			const int d = e.dst;
			if (diss[src] + e.weight < diss[d]) {
				diss[d] = diss[src] + e.weight;
				if (!use[d]) {
					use[d] = true;
					count[d]++;
					if (count[d] >= v_num) {
						return make_pair(false, vector<Weight>());
					}
					que.emplace(d);
				}
			}
		}
	}
	return make_pair(true, diss);
}
int main() {
	int V, E, R; cin >> V >> E >> R;
	vector<vector<Edge>>es(V);
	for (int i = 0; i < E; ++i) {
		int a, b, c; cin >> a >> b >> c;
		es[a].push_back(Edge(a, b, c));
	}
	auto p = spfa(V, es, R);
	if (p.first) {
		for (int i = 0; i < V; ++i) {
			if (p.second[i] >= 1e9) {
				cout << "INF" << endl;
			}
			else {

				cout << p.second[i] << endl;
			}
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}
	return 0;
}

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

int main() {
    string a,b;
    cin>>a;
    cin>>b;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> ans(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(a[i-1]==b[j-1]){
                ans[i][j] = 1+ans[i-1][j-1];
            }
            else
                ans[i][j] = max(ans[i][j-1],ans[i-1][j]);
            //cout<<ans[i][j]<<" ";
        }
        //cout<<endl;
    }
    string str = "";
    int i=n,j=m;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            str.push_back(a[i-1]);
            i--;
            j--;
        }
        else if(ans[i-1][j] > ans[i][j-1]){
            i--;
        }
        else
            j--;
    }
    reverse(str.begin(),str.end());
    cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

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

    if (s[0] == s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc046_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, K;
  cin >> N >> K;
  
  ll ans = K * pow(K - 1, N - 1);

  cout << ans << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    int ans;
    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
    }
    int L = x[0];
    int R = x[0];
    rep(i, n){
        L = min(L, x[i]);
        R = max(R, x[i]);
    }
ans = 100000000;
    for(int k = L; k < R + 1; k++){
        int cost = 0;
        rep(i, n){
            cost += (x[i] - k) * (x[i] - k);
        }
        ans = min(ans, cost);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
    static long mod = 1000000007;
    static long[] p = new long[1000001];
    String yes = "Yes";
    String no = "No";
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }
        long ans = h[0];
        for(int i = 1; i < n; i++){
            ans += Math.max(0, h[i] - h[i-1]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 33364
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string s, t;
    cin >> s >> t;
    if (s.size() > t.size())
        cout << "GREATER" << endl;
    else if (s.size() < t.size())
        cout << "LESS"<<endl;
	else {
		if (s>t)
                    cout << "GREATER" << endl;
		else if (s<t)
                    cout << "LESS" << endl;
        else
            cout << "EQUAL" << endl;
        }
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int h[mx5];

int main()
{
    int n, k;
    cin >> n >> k;

    for(int i = 0; i < n; i++)
        cin >> h[i];

    sort(h, h + n);

    int ans = INT_MAX;
    for(int i = 0; i <= n - k; i++)
        ans = min(ans, h[i + k - 1] - h[i]);

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


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(false)
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int maxn = 1e3+50;

int a[200];

int main(){
	string s;
	cin >> s;
	if(s=="zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl;
		return 0; 
	}
	int l = s.length();
	for(int i=0;i<l;i++){
		a[(int)s[i]]++;
	}
	if(l<26){
		for(int i=97;i<=122;i++){
			if(!a[i]){
				s+=(char)i;
				break;
			}
		}
		cout << s << endl;
		return 0;
	}
	int pos = -1;
	char tmp;
	for(int i=l-1;i>=0;i--){
		tmp = 'z';
		bool flag = 0; 
		for(int j=l-1;j>i;j--){
			if(s[j]>s[i]&&s[j]<=tmp){
				tmp = s[j];
				flag = 1;
				pos = j;
			}
		}
		if(flag){
			s[i] = s[pos];
			pos = i;
			break;
		}
	}
	for(int i=0;i<=pos;i++){
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char ca[10];
	cin>>ca;
	for(int i=0;i<strlen(ca)-1;i++){
		if(ca[i]=='A' && ca[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

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

ll lcm(ll a, ll b){
    return a / gcd(a,b) * b;
}

int main(void){
    ll a,b;
    cin >> a >> b;
    ll ans = lcm(a, b);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
count=N
for i in range(0,N+1,1):
    n=(i%9 + (N-i)%6)

    n9=0
    num9=i//9
    while num9:
        n9+=num9%9
        num9//=9

    n6=0
    num6=(N-i)//6
    while num6:
        n6+=num6%6
        num6//=6
    count=min(n9+n6+n,count)
print(count)


Measured memory_bytes: 41068
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int A[]=new int[n];
        int ans=0;
        boolean flag=true;
    for(int i=0;i<n;i++){
        A[i]=Integer.parseInt(sc.next());
    }
    while(flag){
        for(int i=0;i<n;i++){
            if(A[i]%2==0){A[i]/=2;}
            else{flag=false;}
            }
        if(flag){ans++;}
        }
    System.out.print(ans);
    }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    LL x;cin>>x;
    LL result = 0;

    result += (x/500)*1000;
    x %= 500;
    result += (x/5)*5;

    cout<<result<<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main(void) {
    int A, B;
    scanf("%d %d", &A, &B);

    char *S = (char*)malloc((A+B+2) * sizeof(char));
    scanf("%s", S);

    if(S[A] != '-') {
        printf("No\n");
        return 0;
    }

    int i;
    for(i=0; S[i] != '\0'; i++) {
        if(i != A) {
            if(S[i] < '0' || S[i] > '9') {
                printf("No\n");
              	free(S);
                return 0;
            }
        }
    }
    printf("Yes\n");
  	free(S);
    return 0;
}

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

#define MAXN 100100
#define pb push_back
typedef long long ll;
typedef pair<ll, int> ii;

int n;
int a[MAXN];
vector<ii> s;
int lm = MAXN;
ll r[MAXN];

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s.pb({a[i], i});
  }
  sort(s.begin(), s.end(), greater<ii>());
  for (int i = 0; i < n; i++) {
    //cout << s[i].first << ' ' << s[i].second<<endl;
    lm = min(lm, s[i].second);
    if (i + 1 == n || s[i].first != s[i + 1].first) {
      r[lm] += (i + 1 == n ? s[i].first : s[i].first - s[i + 1].first) * ll(i + 1);
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%lld\n", r[i]);
  }
  return 0;
}


Measured memory_bytes: 3952
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long pow(long x, long k) {
    if(k == 0) { 
        return 1;
    }
    return (pow((x*x)%p, k/2) * (k % 2 == 1 ? x: 1)) % p;
}

long solve(long[] a) {
    auto c = new long[](a.length);
    foreach(ai; a) {
        ++c[ai];
    }
    if(a.length % 2 == 1) {
        if(c[0] != 1) {
            return 0;
        }
        foreach(i; iota(1, a.length)) {
            if(i%2 == 0 && c[i] != 2) {
                return 0;
            }
            if(i % 2 == 1 && c[i] != 0) {
                return 0;
            }
        }
    } else {
        foreach(i; iota(a.length)) {
            if(i%2 == 0 && c[i] != 0) {
                return 0;
            }
            if(i%2 == 1 && c[i] != 2) {
                return 0;
            }
        }
    }
    return pow(2, a.length/2);
}

void main(){
    auto n = readLong();
    auto a = readLongs();
    writeln(solve(a));
}



Measured memory_bytes: 4412
#include <cstdio>
#include <iostream>

using namespace std;

int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int m,d;
	int day=0;
	while(1){
		scanf("%d %d",&m,&d);
		if(m==0&&d==0)break;
		day=0;
		for(int i=0;i<m-1;i++){
			day+=month[i];
		}
		day+=d;
		string result;
		const int r=day%7;
		switch(r){
			case 0:
			result="Wednesday";
			break;
		case 1:
			result="Thursday";
			break;
		case 2:
			result="Friday";
			break;
		case 3:
			result="Saturday";
			break;
		case 4:
			result="Sunday";
			break;
		case 5:
			result="Monday";
			break;
		case 6:
			result="Tuesday";
			break;
		}
		cout<<result<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

#define LIMIT 1000000007
typedef long long LL;

LL summax(LL k, LL max);
LL summin(LL k){
    //0~k-1の和
    LL ans = ((k-1)*k);
    ans /= 2;
    return ans;
}

LL summax(LL k, LL max){
    //~max,k項の和
    LL ans = 2*max;
    ans = (ans-k+1);
    ans = ans*k;
    ans /= 2;
    return ans;
}

int main(){
    LL N, K, k;
    scanf("%lld%lld", &N, &K);
    LL ans = 0, buf;
    for(k=K; k<=N+1; k++){
        buf = summax(k, N) - summin(k) + 1;
        ans += buf;
        ans %= LIMIT;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstring>

using namespace std;

const int mod = 998244353;
char s[301];
int a[300];
bool f[301][301][301];
long long dp[301][301][301];

int main() {
    int n, i, j, k;
    long long ans = 1;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n; i++) a[i] = s[i] - '0';
    
    f[0][0][0] = true;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            for (k = 0; k < n; k++) {
                if (!f[i][j][k]) continue;
                
                if (i > 0) {
                    f[i + 1][j][k] = true;
                    
                    if (a[i] == 0 && k > 0) f[i + 1][j + 1][k - 1] = true;
                    if (a[i] == 1 && j > 0) f[i + 1][j - 1][k + 1] = true;
                }
                
                if (i + 2 <= n) {
                    if (a[i] == 0 || a[i + 1] == 0) f[i + 2][j + 1][k] = true;
                    if (a[i] == 1 || a[i + 1] == 1) f[i + 2][j][k + 1] = true;
                }
            }
        }
    }
    
    for (i = 0; i <= n; i++) {
        for (j = n - 1; j >= 0; j--) {
            for (k = n - 1; k >= 0; k--) {
                f[i][j][k] |= f[i][j + 1][k];
                f[i][j][k] |= f[i][j][k + 1];
            }
        }
    }
    
    dp[n][0][0] = 1;
    
    for (i = n; i >= 0; i--) {
        for (j = 0; j < n; j++) {
            for (k = 0; k < n; k++) {
                if (dp[i][j][k] == 0) continue;
                
                if (f[i][j][k]) ans += dp[i][j][k];
                
                if (i == 0) continue;
                
                dp[i - 1][j][k] += dp[i][j][k];
                if (dp[i - 1][j][k] >= mod) dp[i - 1][j][k] -= mod;
                
                if (a[i - 1] == 0) {
                    dp[i][j][k + 1] += dp[i][j][k];
                    if (dp[i][j][k + 1] >= mod) dp[i][j][k + 1] -= mod;
                } else {
                    dp[i][j + 1][k] += dp[i][j][k];
                    if (dp[i][j + 1][k] >= mod) dp[i][j + 1][k] -= mod;
                }
            }
        }
    }
    
    printf("%lld\n", (ans - 1) % mod);
    
    return 0;
}


Measured memory_bytes: 241360
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;

  vector<int> A, B;

  for (int n=0; n<=N; ++n) {
    unsigned a;
    cin >> a;
    A.push_back(a);
  }

  for (int n=0; n<N; ++n) {
    unsigned b;
    cin >> b;
    B.push_back(b);
  }

  int64_t killed = 0;

  for (int n=0; n<N; ++n) {
    int64_t killed_this_town, killed_next_town;
    killed_this_town = min(B[n],A[n]);
    killed_next_town = min(A[n+1], max(B[n]-A[n], 0));
    A[n+1] -= killed_next_town;
    killed += killed_this_town + killed_next_town;
  }
  
  cout << killed << endl;

  return 0;
}


Measured memory_bytes: 1400
N = int(input())
P = list(map(int, input().split(' ')))

import math
buf = []
prev = -1
i = 0

ret = 0
while i < N:
    if i+1 == P[i]:
        ret += 1
        if i +1 < N:
            P[i], P[i+1] = P[i+1], P[i]

    i += 1

print(ret)

Measured memory_bytes: 52332
#include <stdio.h>
#include<math.h>
int main()
{
 long int x,y,z,sum,i=0,k;
 
 scanf("%ld",&x);
while(x>0)
{
    y=x%10;
    x=x/10;
    if(y==9)
    {
        i=1;
        break;
    }
}
if(i==1)
{
    printf("Yes");
}else{
    printf("No");
}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

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

typedef long long ll;
const int maxn = 200010;
int n;
ll A[maxn], B[maxn], C[maxn];

struct P { ll x, y; };
P operator - (P x, P y) { return (P){x.x - y.x, x.y - y.y}; }
ll cross(P x, P y) { return x.x * y.y - x.y * y.x; }

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &A[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &B[i]);
    }
    int pos = max_element(A + 1, A + n + 1) - A;
    rotate(A + 1, A + pos, A + n + 1);
    rotate(B + 1, B + pos, B + n + 1);
    A[++n] = A[1], B[n] = B[1];
    for (int i = 3; i <= n; i++) {
        C[i] = 2 * (C[i - 1] + B[i - 1]) - C[i - 2];
    }
    vector<P> st;
    for (int i = 1; i <= n; i++) {
        P p = (P){i, A[i] - C[i]};
        while (st.size() >= 2 && cross(st.back() - st[st.size() - 2], p - st.back())
            >= 0) st.pop_back();
        st.push_back(p);
    }
    long long ans = 0;
    for (int i = 1; i < st.size(); i++) {
        ans += (st[i].x - st[i - 1].x) * (st[i].y + st[i - 1].y);
    }
    ans += st[0].y + st[st.size() - 1].y;
    for (int i = 1; i <= n; i++) ans += 2 * C[i];
    printf("%.12f\n", 1.0 * (ans - A[1] * 2) / (2 * (n - 1)));
    return 0;
}

Measured memory_bytes: 12056
#include<iostream>
using namespace std;
int main(){
  int a,b,ans=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
    if(i%10==i/10000 and i/1000%10==i/10%10)ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
def main():
    N = int(input())
    V = [int(a) for a in input().split()]
    
    even = list()
    odd = list()

    for i in range(N):
        if (i + 1) % 2 == 0:
            odd.append(V[i])
        else:
            even.append(V[i])

    even_counter = Counter(even).most_common()
    odd_counter = Counter(odd).most_common()

    ans = 0
    if even_counter[0][0] != odd_counter[0][0]:
        if len(even_counter) >= 2:
            ans += len(even) - even_counter[0][1]

        if len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[0][1]

    else:
        if len(even_counter) == 1 and len(odd_counter) == 1:
            ans += even_counter[0][1]

        elif len(even_counter) == 1 and len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[1][1]

        elif len(even_counter) >= 2  and len(odd_counter) == 1:
            ans += len(even) - even_counter[1][1]

        elif len(even_counter) >= 2 and len(odd_counter) >= 2:
            cost_even = len(even) - even_counter[0][1] + len(odd)  - odd_counter[1][1]
            cost_odd  = len(odd)  - odd_counter[0][1]  + len(even) - even_counter[1][1]
            ans += min(cost_even, cost_odd)

    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
  int N1,N2,N3,K;
  cin >> N1 >> N2 >> N3 >> K;

  for(int k=0; k<K; k++){
    if(N1 >= N2){
      N2*= 2;
    }
    else{
      N3*= 2;
    }
  }

  string ans= (N1 < N2 && N2 < N3) ? "Yes"
                                   : "No";
  
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 300010
using namespace std;
int num[N];
int main()
{
	int n,k;
	scanf("%d%d",&k,&n);
	if(k&1)
	{
		for(int i=1;i<=n;i++) num[i]=(k+1)/2;
		int u=n;
		for(int i=1;i<=n/2;i++)
		if(num[u]==1) u--;
		else 
		{
			num[u]--;
			for(int j=u+1;j<=n;j++) num[j]=k;
			u=n;
		}
		for(int i=1;i<=u;i++) printf("%d ",num[i]); 
	}
	else
	{
		printf("%d ",k/2);
		for(int i=1;i<n;i++) printf("%d ",k);
	}
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
//#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
//#include <cmath>
//#include <deque>
//#include <queue>
//#include <list>
#include <array>
using namespace std;
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	IOS;
	string s;
	cin >> s;
	ll sum = 0;
	for (int i = 0; i < (int)s.size(); ++i) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}


Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// 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 MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  string s;
  cin >> s;

  if(P == 2 || P == 5){
    int ans = 0;
    REP(i, N){
      if((s[i]-'0')%P == 0){
        ans += i+1;
      }
    }
    cout << ans << "\n";
    return 0;
  }

  map<int, int> m;
  m[0] = 1;

  int sum = 0;
  int zyuu = 1;
  int cur = 0;
  RREP(i, N){
    int d = s[i]-'0';
    (sum += d*zyuu) %= P; 
    (zyuu *= 10) %= P;
    m[sum]++;
  }

  int ans = 0;
  for(auto p : m){
    ans += p.second*(p.second-1)/2;
  }

  cout << ans << "\n";

  return 0;
}

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

int main() {
    int N;
    cin >> N;

    vector <int> data(N);
    for(int i = 0; i < N; i++){
        cin >> data[i];
    }

    int ans = 0;
    for(int i = 0; i < N-1; i++){
        if(data[i] < data[i+1]){
            continue;
        }
        int tmp_i = i;
        int count = 0;
        for(int j = i+1; j < N; j++){
            if(data[tmp_i] >= data[j]){
                count ++;
                tmp_i ++;
            }
            else break;
        }
        ans = max(count, ans);
        if(ans >= (N/2)) break;
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int main(){
	int T;
	cin>>T;
	rep(tt,T){
		unsigned x[9];
		rep(i,9) scanf("%x",&x[i]);
		unsigned a=0;
		rep(i,32){
			unsigned sum=0;
			rep(j,8) sum+=x[j];
			if(((sum>>i)&1)!=((x[8]>>i)&1)){
				rep(j,9) x[j]^=(1<<i);
				a+=(1<<i);
			}
		}
		printf("%x\n",a);
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    char a,b,c;

    rep(i,3){
        cin >> a >> b >> c;
    }
    if(a==b&&b==c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
def main():
    N=int(input())
    X=list(map(int,input().split()))

    count=0
    result=10**10
    for p in range(101):
        count=0
        for i in range(N):
            count+=(X[i]-p)**2
        result=min(result,count)
    print(result)
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long sum = 100;
		int i = 0;

		for (; ;i++ ) {
			if (sum>=x) {
				System.out.println(i);
				break;
			}
			sum+=(double)sum*0.01;
		}


	}
}


Measured memory_bytes: 35772