akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  int64_t ans=1;
  for(int i=0;i<n;i++){
    if(a.at(i)%2==0)
      ans*=2;
  }
  ans=pow(3,n)-ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4112
#include <iostream>
using namespace std;
long GCDr(long m, long n) {
	int r;
	if (m < n) {
		swap(m, n);
	}
	while (n > 0) {
		r = m % n;
		m = n;
		n = r;
	}
	return m;
}
int main() {
	long long a, b;
	while (cin >> a >> b) {
		long long GCD, LCM;
		if (a == b) {
			//a=b??????????????????
			GCD = a;
			LCM = a;
		}
		else {
			GCD = GCDr(a, b);
		}
		LCM = a * b / GCD;
		cout << GCD << " " << LCM << endl;
	}
}

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


int main()
{
    int n;
    int c=0,c1=0,c2=0,c3=0;
    cin>>n;
    string arr[n];
    for(int i =0; i<n; i++)
        cin>>arr[i];
    for(int i=0; i<n; i++)
    {
        if(arr[i]=="AC")
            c++;
        else if(arr[i]=="WA")
            c1++;
        else if(arr[i]=="TLE")
            c2++;
        else if(arr[i]=="RE")
            c3++;
    }
cout<<"AC x "<<c<<endl;
cout<<"WA x "<<c1<<endl;
cout<<"TLE x "<<c2<<endl;
cout<<"RE x "<<c3<<endl;
    return 0;
}

Measured memory_bytes: 6628
import std.stdio, std.string, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] a = [1, 5, 10, 25];
    int coin = 0;
    foreach_reverse (x; a) {
        coin += n / x;
        n %= x;
    }
    coin.writeln;
}


Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		if(0 == $s[1] % $s[0]){
			$ans = $s[0] + $s[1];
		}else{
			$ans = $s[1] - $s[0];
		}
		
		echo $ans . "\n";

	}
}
?>


Measured memory_bytes: 4856
import math
import sys
sys.setrecursionlimit(100000000)

N, A, B = [int(n) for n in input().split()]
h = []
for i in range(N):
  h.append(int(input()))

def bsearch(begin, end):
  if begin == end:
    return begin
  else:
    if is_ok( (begin+end)//2):
      return bsearch(begin, (begin+end)//2)
    else:
      return bsearch( (begin+end)//2 + 1, end)

def is_ok(n):
  h_tmp = h.copy()
  cnt = 0
  cnt = sum([math.ceil((hp-B*n)/(A-B)) for hp in h_tmp if hp-B*n >= 0])
  return cnt <= n

print(bsearch(0, 1000000000))

Measured memory_bytes: 11848
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		int s,i=0,j;
		int[] x = new int[50];
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextInt()){
        	s = scan.nextInt();
       	
        	x[i] = sum4(s);
        	
        	i++;
        
        }
        for(int p : x){
        	System.out.println(p);
        }
    }
    
    public static int sum4(int k){
    	int count = 0,sum;
    	for(int a=0;a<=9;a++){
    		for(int b=0;b<=9;b++){
    			for(int c=0;c<=9;c++){
    				for(int d=0;d<=9;d++){
    					sum = a+b+c+d;
    					if(sum == k)count++;
    					if(d >= k)break;
    				}
    				if(c >= k)break;
    			}
    			if(b >= k)break;
    		}
    		if(a >= k)break;
    	}
    	return count;
    }
    
    
    
}

Measured memory_bytes: 26648
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n[3];
	for(int i=1;i<=3;i++)
	{
		cin>>n[i];
	}
	sort(n+1,n+1+3);
	int ans=n[1]+n[2];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a:number[]=[];for(let i=0;i<arg;i++) {a.push(t.n());}return a;}else{const a = t.input[0];t.input.shift();return Number(a);}},s:(arg:number=0):any=>{if(arg){const a:string[]=[];for(let i=0;i<arg;i++){a.push(t.s());}return a;}else{const a=t.input[0];t.input.shift();return String(a);}},c:(arg:number=0):any=>{if(arg) {const a:string[]=[];for(let i=0;i<arg;i++) {a.push(t.c());}return a;}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('');}else{t.input.shift();}return String(b);}},o: (...arg)=>{console.log(...arg);},abs:(a)=>{return Math.abs(a);},min:(a)=>{return Math.min(a);},max:(a)=>{return Math.max(a);},floor:(a)=>{return Math.floor(a);},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b});},desc:(ar:number[])=>{ return ar.sort((a,b)=>{return b-a});},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1]}return arr[arr.length-1];}}
const main = ()=>{
  let [a,b,c,d,e,f] = t.c(6)
  t.o(a==f&&b==e&&c==d?'YES':'NO')
}
main()

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

#define sz(x) (int) x.size()

using namespace std;
using pii = pair<int, int>;

const int N = 3e3+1e2;

string s, t;

int dp[N][N];

int calc(int l1 = 0, int l2 = 0) {
    if (l1==s.size()||l2==t.size()) 
        return dp[l1][l2] = 0;
    if (~dp[l1][l2]) 
        return dp[l1][l2];
    if (s[l1] == t[l2]) 
        return dp[l1][l2] = calc(l1+1,l2+1)+1;
    else 
        return dp[l1][l2] = max(calc(l1,l2+1), calc(l1+1,l2));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> s >> t;
    for (int i = 0; i < N; ++i)
        fill(dp[i],dp[i]+N,-1);
    calc();
    int i = 0, j = 0;
    while (i < sz(s) && j < sz(t)) {
        if (s[i] == t[j]) 
            cout << s[i], ++i, ++j;
        else if (dp[i+1][j] > dp[i][j+1])
            ++i;
        else
            ++j;
    }
    return 0;
}

Measured memory_bytes: 38144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define vi vector<long long>
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(max(a, d), max(b, c))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int n, c, s, e, ch, ans=0;
int a[1000001];
pair<int, int> b[31][100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
   // freopen("A.txt", "r", stdin);
    #endif
    cin >> n >> c;
    for(int i=0; i<n; i++)
    {
        cin >> s >> e >> ch;
        a[s-1]++; a[e]--;
        b[ch][s].F = 1, b[ch][e].S = 1;
    }
    int cur=0;
    for(int i=0; i<=100000; i++)
    {
        cur += a[i];
        for(int j=1; j<=c; j++)
        {
            if(b[j][i+1].F&&b[j][i+1].S)
            {
                cur--;
                a[i+1]++;
            }
        }
        ans = max(ans, cur);
    }
    cout << ans;
}



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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

bool AC[N];
int WA[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int p; cin >> p;
		string s; cin >> s;
		if (s == "AC") AC[p] = true;
		else if (s == "WA") WA[p] += !AC[p];
	}
	int ans = 0, cnt = 0;
	for (int i = 1; i <= n; i++) ans += AC[i] * WA[i], cnt += AC[i];
	cout << cnt << ends << ans << endl;

	return 0;
}


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

int main()
{
	long long n;
	cin>>n;
	queue<long long>q;
	for(long long i=1;i<=9;i++)
		q.push(i);
	while(!q.empty())
	{
		long long k=q.front();
		q.pop();
		n--;
		if(n==0)
		{
			cout<<k<<endl;
			break;
		}
		for(long long i=(k%10)-1;i<=(k%10)+1;i++)
		{
			if(i<0||i>=10)
				continue;
			q.push(k*10+i);
		}
	}

	return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main{
	
	public static void main(String args[]){
		String[] ans={"Sunny","Cloudy","Rainy"};
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		for(int i=0;i<3;i++)
			if(s.equals(ans[i]))
			{
				System.out.println(ans[(i+1)%3]);
				break;
			}
	}

}







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


char S[3];


int main() {
    scanf("%s", S);
    bool a = false;
    bool b = false;
    bool c = false;
    for(int i = 0; i < 3; i++) {
        if(S[i] == 'a') {
            a = true;
        }
        else if(S[i] == 'b') {
            b = true;
        }
        else if(S[i] == 'c') {
            c = true;
        }
    }

    if(a && b && c)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
n, m, q = list(map(int, input().split(" ")))
Q = [list(map(int, input().split(" "))) for i in range(q)]
Q = [[i[0] - 1, i[1] - 1, i[2], i[3]] for i in Q]

def calc(arr: list):
    return sum([i[3] for i in Q if arr[i[1]] - arr[i[0]] == i[2]])

def get_array(arr: list, num):
    if len(arr) == n:
        return calc(arr)
    return max([get_array(arr + [i], i) for i in range(num, m + 1)])

print(get_array([], 1))


Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


llint N;
VLL fact;


void makeFact(){
	for(llint i = 1;i*i <= N;i++)
		if(N%i == 0) fact.pb(i);
}


int solve(){
	int ans = INF;
	for(llint A : fact){
		llint B = N/A;
		ans = min(ans, max((int)log10(A)+1, (int)log10(B)+1));
	}
	return ans;
}


signed main(){
	cin >> N;

	makeFact();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
long long dist[100][100];

int main(){

    // 1. 入力情報.
    int V, E;
    scanf("%d %d", &V, &E);
    
    // 2. 初期化.
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            if(i == j) dist[i][i] = 0;
            else       dist[i][j] = INF;
        }
    }
    for(int i = 0; i < E; i++){
        int s, t;
        long long d;
        scanf("%d %d %lld", &s, &t, &d);
        dist[s][t] = d;
    }
    
    // 3. Warshall–Floyd法.
    // https://ja.wikipedia.org/wiki/ワーシャル–フロイド法
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    // 4. 負の閉路持つかを判定.
    bool negative = false;
    for(int i = 0; i < V; i++) if(dist[i][i] < 0) negative = true;
    
    // 5. 出力 ～ 後処理.
    if(negative){
        printf("%s\n", "NEGATIVE CYCLE");
        return 0;
    }else{
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++){
                if(dist[i][j] > 2e9) printf("%s", "INF");
                else                 printf("%lld", dist[i][j]);
                if(j < V - 1)        printf(" ");
            }
            printf("\n");
        }
    }
    
    return 0;

}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    int a[200010], b[200010];
    map<pair<int, int>, int> MM;

    for(int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i];
        MM[make_pair(a[i], b[i])] = 1;
        MM[make_pair(b[i], a[i])] = 1;
    }

    int G = 0;
    for(int i = 2; i <= n-1; i++) {
        if(MM[make_pair(1, i)] == 1 && MM[make_pair(i, n)] == 1) {
            G = 1;
        }
    }

    if(G == 0) {
        cout << "IMPOSSIBLE";
    }
    else {
        cout << "POSSIBLE";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 39296
"""
中央値を求めれば良い.
"""
def get_diff(value, array):
  diff = 0
  for i in array:
    diff += abs(value - i)
  return diff

length = int(input())
inp = input().split(' ')
A = []
for i in range(0, length):
  A.append(int(inp[i]) - i - 1)

A.sort()

# print(A)

# odd numbers
if len(A) % 2 == 1:
  center_number = A[len(A) // 2]
else:
  center_number = int(A[len(A) // 2 ] + A[len(A) // 2]) / 2

# print(center_number)
print(int(get_diff(center_number, A)))

Measured memory_bytes: 25952
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <cmath>
#include<vector>
using namespace std;
#define pb push_back
#define pf push_front
#define M 1000000007
#define ll long long int
int main()
 {
 	 
     double n;
     scanf("%lf",&n);
     double ans;
    ans=2*3.14159265358979323846*n;
    printf("%.20lf",ans);
     return 0;
 }


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+9;
int a[N],b[N];
int n,m,x,y,z;
string s,t;
int main(){
	cin>>s>>t;
	bool ans=1;
	for(int i=0;i<s.size();i++) if(s[i]!=t[i]) ans=0;
	cout<<(ans?"Yes":"No");
	return 0;
} 

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1+1e4;
const int mod =1e9+7;
int n,m,a[MAXN],b[MAXN],f[MAXN][MAXN];

int main()
{
#define TASK "ABC"
    //freopen(TASK ".inp","r",stdin);
   // freopen(TASK ".out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=0;i<n;++i) cin>>a[i];
    for(int i=0;i<m;++i) cin>>b[i];
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
        if(a[i-1]==b[j-1]) f[i][j]=(1+f[i][j-1]+f[i-1][j])%mod;
        else {
            f[i][j]=(f[i][j-1]+f[i-1][j]-f[i-1][j-1])%mod;
        }

        f[i][j]=(f[i][j]+mod)%mod;
    }
    }
    cout<<f[n][m]+1;
    return 0;
}


Measured memory_bytes: 27200
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}


int main() {

	string x;
	cin>>x;

	ll s=0,t=0;

	rep(i,x.size()){
		if(x[i]=='T'&&s>0)s--;
		else if(x[i]=='T')t++;
		else s++;
	}
	cout<<s+t<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	int n=0,a,b,c,x;
	scanf("%d",&n);
	a=n/100;
	b=(n/10)%10;
	c=n%10;
	if(a<b&&(a+1)<10)
	{
		x=(a+1)*100+(a+1)*10+(a+1);
	}
	else if((a>b||a==b)&&(a>c||a==c))
	{
		x=a*100+a*10+a;
	}
	else if(c>a)
	{
		x=(a+1)*100+(a+1)*10+(a+1);
	}
	printf("%d\n",x);
	return 0;
} 

Measured memory_bytes: 128
while True:
	try:
		n = input() ; plumbs = [] ; answer = ''
		if n >= 512: plumbs.insert(0,512);n-=512
		if n >= 256: plumbs.insert(0,256);n-=256
		if n >= 128: plumbs.insert(0,128);n-=128
		if n >= 64: plumbs.insert(0,64);n-=64
		if n >= 32: plumbs.insert(0,32);n-=32
		if n >= 16: plumbs.insert(0,16);n-=16
		if n >= 8: plumbs.insert(0,8);n-=8
		if n >= 4: plumbs.insert(0,4);n-=4
		if n >= 2: plumbs.insert(0,2);n-=2
		if n >= 1: plumbs.insert(0,1);n-=1
		for val in plumbs: answer += str(val) + ' '
		print answer.rstrip()
	except: break

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define brep1(i,n) for(int i=n-1;i>=1;i--)

vector<int> a;

bool check(int x){//x文字以内で要件を満たせるかどうか
    map<int,int>mp;//(mp[x]-1)はx文字目で何種類文字を使っているかを表す
    rep1(i,a.size()){
        if(a[i-1]<a[i])continue;//後ろに文字追加してるだけなのでスキップ
        if(x==1)return false;//これがないと繰り上がり部分でTLE
        mp[a[i]]++;//a[i]文字目の番号を+1
        mp.erase(mp.upper_bound(a[i]),mp.end());//a[i]より後ろはリセット
        brep1(j,a[i]+1){//繰り上がり処理
            if(mp[j]>=x){
                if(j==1) return false;//最初の文字を越えて繰り上がるようなら失敗
                mp[j]=0;mp[j-1]++;//繰り上がり
            }
            else break;//繰り上がり処理の終了
        }
    }
    return true;//最後までいったら成功
}

int main(void){
    int n;cin >> n;
    rep(i,n){int num;cin >>num;a.emplace_back(num);}//入力
    int min=0;int max=n;
    while(max-min>1){//min<x<=maxでxを二部探索,x=maxになり次第探索を終了
        int mid = (max+min)/2;
        if(check(mid))max=mid;
        else min = mid;
    }
    cout << max << endl;
}

Measured memory_bytes: 1400
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if b == 1 {
		fmt.Println(0)
		return
	}
	for i := 1; ; i++ {
		n := a*i - (i - 1)
		if n >= b {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main () {
	int n = ri();
	std::string s;
	std::cin >> s;
	if (n == 1) {
		if (s == "BB") std::cout << 1 << std::endl;
		else std::cout << 0 << std::endl;
		return 0;
	}
	int cur = 0;
	int res = 1;
	for (int i = 0; i < 2 * n; i++) {
		bool plus;
		if (!i) plus = true;
		else if (i + 1 >= 2 * n) plus = false;
		else {
			if (cur % 2 == (s[i] == 'B')) plus = false;
			else plus = true;
		}
		if (plus) cur++;
		if (cur % 2 != (s[i] == 'B')) res = 0;
		if (!plus) res = (int64_t) res * (cur--) % MOD;
	}
	if (cur != 0) res = 0;
	for (int i = 0; i < n; i++) res = (int64_t) res * (i + 1) % MOD;
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            cnt += 1

cmb_cnt = 0
for a in A:
   cmb_cnt += len([x for x in A if x < a]) 

kC2 = (K*(K-1))//2
ans = (cnt*K)+(cmb_cnt*kC2)
print(ans%(10**9+7))


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  string S; cin >> S;
  int N = S.size();
  vector<int> res(N);
  fill(ALL(res), 0);

  int idx = 0;
  while (idx < N) {
    int first_idx = idx;
    int r_cnt = 0,l_cnt = 0;
    while (S[idx] == 'R') {
      r_cnt++;
      idx++;
    }
    while (S[idx] == 'L') {
      l_cnt++;
      idx++;
    }
    res[first_idx+r_cnt-1] = (r_cnt+1)/2+l_cnt/2;
    res[first_idx+r_cnt] = r_cnt/2+(l_cnt+1)/2;
  }

  REP(i,N) cout << res[i] << ' ';

  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
 
#define ll                 long long
#define endl               "\n"
#define loop(n)            for(int i=0;i<n;i++)
#define pb                 push_back
#define mp                 make_pare
#define all(a)             a.begin(),a.end()
 
 
 
using namespace std;
int main(){
    vector<int>v;
    int n=5,ans;
    loop(n){int x;cin>>x;v.pb(x);}
    loop(n){
        if(v[i]==0)ans=(i+1);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int MAX = 55555;
int main() {
  int n;
  cin >> n;
  
  vector<int> f(MAX+1), ans;
  for (int i = 2; i <= MAX; ++i) {
    if (f[i]) continue;
    if(i%5==1) ans.push_back(i);
    if(ans.size()==n) break;
    f[i] = i;
    for (int j = i*i; j <= MAX; j += i) {
      if (!f[j]) f[j] = i;
    }
  }
  rep(i,n) cout << ans[i] << " "; cout << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = INF;
    rep(div,1<<(h-1)) {     // 2**(h-1)パターンの横分割を全探索
        int g = 0;          // 横分割されるgroup数
        vector<int> id(h);  // 各行がどのgroupに入るか
        rep(i,h) {
            id[i] = g;
            if (div>>i&1) ++g;
        }
        ++g;
        vector<vector<int>> c(g, vector<int>(w));   // group毎の白の数
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');

        int num = g-1;
        vector<int> now(g); // group毎の白の累計
        auto add = [&](int j) {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if(now[i] > k) return false;
            return true;
        };
        rep(j,w) {
            if (!add(j)) {  // これまでの累計に加算してkを超えた場合
                num++;      // 縦に分割
                now = vector<int>(g);   // nowを初期化
                if (!add(j)) {          // nowを初期化後、1列だけでk以上の時はダメ
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
	cout << ans << endl;
	return 0;
}


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

int bubbleSort(int A[],int N)
{
        int sw=0;
        bool flag=1;
        for(int i=0;flag;i++)
        {
                flag=0;
                for(int j=N-1;j>=i+1;j--)
                {
                        if(A[j]<A[j-1])
                        {
                                swap(A[j],A[j-1]);
                                flag=1;
                                sw++;
                        }
                }
        }  
        return sw;      
}
int main()
{
        int A[100],N,sw;
        cin>>N;
        for(int i=0;i<N;i++)
                cin>>A[i];
        sw=bubbleSort(A,N);
        for(int i=0;i<N;i++)
        {
                if(i) cout<<" ";
                cout<<A[i];
        }
        cout<<endl;
        cout<<sw<<endl;
        return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll W,H,x,y;
string S;
vector<ll> vec;

void solve() {
	cin >> W >> H >> x >> y;
	cout << (double(W)*H) / 2 << " ";
	if (W % 2 == 0 && H % 2 == 0) {
		if (W / 2 == x && H / 2 == y) {
			cout << 1;
		}
		else {
			cout << 0;
		}
	}
	else {
		cout << 0;
	}

}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x;
	cin >> x;
	int n = 100010;
	vector<bool> prime(n);
	FOR (i, 2, n) {
	  bool ok = true;
	  for (int j = 2; j * j <= i; ++j) {
		if (i % j == 0) {
		  ok = false;
		  break;
		}
	  }
	  if (ok) prime[i] = true;
	}
	FOR (i, x, n) {
	  if (prime[i]) {
		cout << i << endl;
		return 0;
	  }
	}
    
    return 0;
}



Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int result = 1;
        for (int j = 0; j < N; j++) {
            if (result * 2 > result + K) {
                result = result + K;
            } else {
                result = result * 2;
            }
        }

        System.out.print(result);
    }
}

Measured memory_bytes: 21076
import numpy as np
N = (int(input())+1)
A = [int(i) for i in input().split()]
B = np.abs(A)
C = 0
for i in range(N-1):
  if A[i]<0 : C+=1

C %= 2
min = min(B)

if C==0: print(sum(B))
else : print(sum(B)-min*2)


Measured memory_bytes: 23376
from itertools import groupby
s = list(input())
k = int(input())

G = []
for key, group in groupby(s):
    G += [list(group)]

count = 0

if len(G)==1:
    print(len(s)*k//2)

elif s[0]!=s[-1]:
    for g in G:
        count += len(g)//2
    print(count*k)

else:
    d = len(G[0]+G[-1])//2-(len(G[0])//2)-(len(G[-1])//2)
    for g in G:
        count += len(g)//2
    print(count*k + d*(k-1))

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int N,T,A;
vector<int> al[MX_N];
int d[MX_N];
int pa[MX_N], fd[MX_N], sd[MX_N];

void dfs(int u, int p) {
    pa[u] = p;
    d[u] = d[p]+1;
    fd[u] = u; sd[u] = -1;
    //cout << "DFS " << u << " " << p << " :: " << fd[u] << " " << sd[u] << endl;
    for (auto v : al[u]) if (v != p) {
        dfs(v,u);
        if (sd[u] == -1 || d[fd[v]] > d[sd[u]]) sd[u] = fd[v];
        if (sd[u] != -1 && (fd[u] == -1 || d[sd[u]] > d[fd[u]])) swap(fd[u],sd[u]);
    }
    //cout << "DFS " << u << " " << p << " :: " << fd[u] << " " << sd[u] << endl;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> T >> A;
    FOR(i,1,N-1){
        int u, v; cin >> u >> v;
        al[u].push_back(v);
        al[v].push_back(u);
    }
    d[0] = -1;
    dfs(A,0);
    //FOR(i,1,N){ cout << fd[i] << " " << sd[i] << endl; }

    int ans = d[fd[T]]-1;
    for (int u = T; d[T]-d[pa[u]] <= d[pa[u]]; u = pa[u]) {
        //cout << u << endl;
        ans = max(ans, (fd[pa[u]] != fd[u] ? d[fd[pa[u]]]-1 : (sd[pa[u]] != -1 ? d[sd[pa[u]]]-1 : -1)));
    }
    cout << ans;
}



Measured memory_bytes: 12416
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

alias T = Tuple!(long, "value", long, "time");

class Segtree
{
private:
    long size;
    T[] xs;
public:
    this(long size)
    {
        long i = 1;
        while (i <= size)
        {
            i *= 2;
        }
        this.size = size;
        this.xs = new T[](i * 2);
    }

    this(long size, T value)
    {
        this(size);
        this.xs.fill(value);
    }

    void update(long l, long r, T x)
    {
        l += this.size;
        r += this.size;
        while (l < r)
        {
            if (l % 2 == 1)
            {
                this.xs[l] = x;
                l++;
            }
            l /= 2;
            if (r % 2 == 1)
            {
                this.xs[r - 1] = x;
                r--;
            }
            r /= 2;
        }
    }

    T find(long i)
    {
        i += this.size;
        T ans = this.xs[i];
        while (true)
        {
            i /= 2;
            if (i == 0)
            {
                break;
            }
            if (ans.time < this.xs[i].time)
            {
                ans = this.xs[i];
            }
        }
        return ans;
    }
}

void main(string[] args)
{
    long n, q;
    readf("%d %d\n", &n, &q);
    auto seg = new Segtree(n, T((1 << 31) - 1, -1));
    foreach (i; 0 .. q)
    {
        long cmd, s, t, x;
        readf("%d ", &cmd);
        if (cmd == 0)
        {
            readf("%d %d %d\n", &s, &t, &x);
            seg.update(s, t + 1, T(x, i));
        }
        else
        {
            readf("%d\n", &x);
            auto val = seg.find(x);
            writeln(val.value);
        }

    }

}



Measured memory_bytes: 6416
import Data.List
import Text.Printf

main = do
  getLine
  t <- map (read :: String -> Double) . words <$> getLine
  v <- map (read :: String -> Double) . words <$> getLine
  let table = timeTable 0 t
      end = snd . last $ table
  putStrLn . printf "%.3f" . integral . solve [0, 0.5..end] $ makeConditions end table v

timeTable :: Double -> [Double] -> [(Double, Double)]
timeTable _ [] = []
timeTable n (t:ts) = (n, n+t) : timeTable (n+t) ts

condition :: Double -> (Double, Double) -> Double -> Double -> Double
condition t (l, r) v x
  | 0 <= x && x <= l = v + l - x
  | l <= x && x <= r = v
  | otherwise        = v + x - r

makeConditions :: Double -> [(Double, Double)] -> [Double] -> [Double -> Double]
makeConditions t tt v = (condition t (0, 0) 0) :
                        zipWith (condition t) tt v
                        ++ [condition t (t, t) 0]

solve :: [Double] -> [Double -> Double] -> [Double]
solve time cond = map (\x -> minimum $ map (\f -> f x) cond) time

integral :: [Double] -> Double
integral (_:[]) = 0
integral (x:y:ys) = ((x + y) / 4) + integral (y:ys)


Measured memory_bytes: 2044
#include <iostream>
#include <set>
#include <string>

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

  std::set<std::string> S;

  for (int i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    S.insert(s);
  }

  std::cout << S.size() << std::endl;
  return 0;
}

Measured memory_bytes: 19224
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	s := nextLine()
	first := s[0:1]
	last := s[len(s)-1:]
	num := strconv.Itoa(len(s) - 2)


	slice := []string{first, num, last}

	fmt.Println(strings.Join(slice, ""))
}


Measured memory_bytes: 640
e = list(map(int,input().split()))
K = e[0]
N = e[1]
a = list(map(int,input().split()))
c = [a[i+1] - a[i] for i in range(N-1)]
f = a[0]+ K - a[N-1]
c.append(f)
d = max(c)
print(K - d)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 2e5 + 20;
const int mod = 1e9 + 7;
set<pair<int,pii> >  s[maxn];
vector<int> g[maxn];
vector<pii> mp[maxn];
int p2[maxn],depth[maxn],st[maxn];
int cc = 1;
int dfs(int u,int d){
    depth[u] = d;
    int maxv = -1,mv = 0;
    for (int v : g[u]){
        dfs(v,d + 1);

        if ((int)s[st[v]].size() > maxv){
         //   cout << v << ' '  << s[st[v]].size() << endl;
            maxv = s[st[v]].size();
            mv = v;
        }
    }
    if (g[u].size() == 0){
       st[u] = cc;cc++;
       s[st[u]].insert({d,{1,1}});
       return 0;
    }
    st[u] = st[mv];
    set<int> st1;
    for (int v : g[u]){
        if (v == mv) continue;
        for (pair<int,pii> p : s[st[v]]){
            if (st1.find(p.F) == st1.end()) mp[p.F].clear();
            st1.insert(p.F);
            mp[p.F].pb(p.S);
            auto it = s[st[u]].lower_bound(make_pair(p.F,make_pair(-1,-1)));
            if (it == s[st[u]].end() || it->F != p.F) continue;
            pair<int,pii> p1 = *it;
            s[st[u]].erase(p1);
            mp[p1.F].pb(p1.S);
        }
    }
    for (int a1 : st1){
        vector<pii> v = mp[a1];
        int mul = 1;
        int a = 0;
        int s1 = 0;
        for (pii p : v){
            s1 +=p.S;
            a = (a * (p2[p.S] - p.F) ) % mod;
            a = (a + (mul * p.F)) % mod;
            a %= mod;
            a += mod;
            a %= mod;
            mul = (mul * (p2[p.S] - p.F)) % mod;
            mul += mod;
            mul %= mod;
        }
        s[st[u]].insert({a1,{a,s1}});

    }
    s[st[u]].insert({d,{1,1}});
    //cout << u << "?" << endl;
    //for (pair<int,pii> p : s[st[u]]){
    //        cout << p.F << ' ' << p.S.F << ' ' << p.S.S << endl;
  //      }
//    cout << u << "!" << endl;
}
int32_t main(){
    //freopen("in.in","r",stdin);
    p2[0] = 1;
    for (int i = 1;i < maxn;i++){
        p2[i] = (p2[i - 1] * 2) % mod;
    }
    int n;
    cin >> n;
    for (int i = 1;i <= n;i++){
        int p;
        cin >> p;
        g[p].pb(i);
    }
    dfs(0,0);
    int sum = 0;
    for (pair<int,pii> p : s[st[0]]){
       // if (p.F < 10)
       // cout << p.F << ' '<< p.S.F << endl;
        sum = (sum + (p.S.F * p2[n + 1 - p.S.S])) % mod;
        sum %= mod;
    }
    sum %= mod;
    sum += mod;
    cout << sum % mod << endl;
    return 0;
}


Measured memory_bytes: 89344
#!/snap/bin/pypy3

def main():
    A, B, K = map(int, input().split())

    cookies = [A, B]
    for i in range(K):
        if cookies[i%2] % 2:
            cookies[i%2] -= 1

        cookies[(i+1)%2] += cookies[i%2] // 2
        cookies[i%2] //= 2

    print(*cookies)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }

    let mut heap = BinaryHeap::new();

    for i in 0..n {
        heap.push(a[i]);
    }

    for i in 0..m {
        let v = heap.pop().unwrap();
        heap.push(v / 2);
    }
    let mut ans = 0;
    while !heap.is_empty() {
        ans += heap.pop().unwrap();
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
#include <cctype>

bool cond_1(const std::string& s)
{
	return s[0] == 'A';
}

bool cond_2(const std::string& s)
{
	const auto start = s.begin()+2, end = s.end()-1;
	return std::count(start, end, 'C') == 1;
}

bool cond_3(const std::string& s)
{
	const auto start = s.begin(), end = s.end();
	return std::count_if(start, end, [](const char& c){return std::isupper(c);}) == 2;
}

int main(int argc, char *argv[])
{
	std::string S;
	std::cin >> S;
	std::cout << ( cond_1(S)&&cond_2(S)&&cond_3(S) ? "AC" : "WA" ) << std::endl;
	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef long double ld;

int main()
 {
    ll n,m,i,p,c=0;
   ld b;
     cin>>n>>m;
    ll a[n];
     for(i=0;i<n;i++){
        cin>>a[i];
     }
   ll sum=0;
    for(i=0;i<n;i++){

        sum=sum+a[i];
   }
 b=((double)sum / (m*4));
 b=ceil(b);
for(i=0;i<n;i++){
    if(a[i]>=b)c++;
}
if(c>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

 }



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
   int N,K;
   cin>>N>>K;
   int a[N];
   
   for(int i=0;i<N;i++){
       cin>>a[i];
   }
   int p=N-K;
   int s=p/(K-1);
   if(p%(K-1)!=0){
       s+=1;
   }
   cout<<s+1<<endl;
    return 0;
    
}


Measured memory_bytes: 640
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N, M, X = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(N)]
res = float("inf")
for t in range(N + 1):
  for c in combi([x for x in range(N)], t):
    xs = [0] * M
    cc = 0
    for i in c:
      cc += a[i][0]
      for j in range(1, M + 1): xs[j - 1] += a[i][j]
    #print(xs, c)
    if min(xs) >= X: res = min(res, cc)
if res != float("inf"): print(res)
else: print(-1)

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  int odd = 0;
  REP(i, N)
  {
    int A;
    cin >> A;
    if (A % 2)
      odd++;
  }
  if (odd % 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+7
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef pair<char, pair<int, int>> pcii;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
int a[105], b[105]; 

int main() {
	int n;
	cin >> n;
	for(int i = 0; i <= 100; i++)
		a[i] = INF;
	for(int i = 0; i < n-1; i++)
		cin >> b[i];
	ll ans = 0;
	if(n == 2) {
		cout << 2*b[0] << endl;
		return 0;
	}
	
	
	for(int i = 0; i < n-1; i++) {
		a[i] = min(a[i], b[i]);
		a[i+1] = b[i];
		ans += a[i];
	}
	
	cout << ans+a[n-1] << endl;
}


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

int main(void)
{
	int n, a, b;
	int mx, mn;

	cin >> n >> a >> b;
	mx = min(a, b);
	mn = (a + b) - n;
	if (mn < 0)
		mn = 0;
	cout << mx << " " << mn << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s, t, s2=1, s1=0, t2=0, t1=1;
void exeu(int x, int y)
{
    int q, r;
    if(x%y==0)
        return ;
    q = x/y;
    r = x%y;
    s = s2 - q*s1;
    t = t2 - q*t1;
    s2=s1;
    t2=t1;
    s1=s;
    t1=t;
    exeu(y, r);
}
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    exeu(a, b);
    printf("%d %d\n", s1, t1);
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple



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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

ll d, n;

cin >> d >> n;


ll temp = 1;

rep(i, 1, d){
temp = temp*100;
}

if(n==100){
cout << (n+1)*temp << endl;
}
else cout << n*temp << endl;




return 0;}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat,sum; //区間の和,区間に一様に足された値
    segtree()=default;
    segtree(int size,T x){ init(size,x); }
    void init(int size,T x){
        size_=size;
        n=1;
        while(n<size_) n*=2;
        dat.assign(2*n-1,0);
        sum.assign(2*n-1,0);
        add(0,size,x);
    }
    int size()const{ return size_; }
    void add(int a,int b,T x){ add(a,b,x,0,0,n); }
    T add(int a,int b,T x,int k,int l,int r){
        if(b<=l or r<=a) return dat[k];
        if(a<=l and r<=b){
            sum[k]+=x;
            return dat[k]+=x*(r-l);
        }
        int m=(l+r)/2;
        return dat[k]=add(a,b,x,2*k+1,l,m)+add(a,b,x,2*k+2,m,r)+sum[k]*(r-l);
    }
    T query(int a,int b){ return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r){
        if(b<=l or r<=a) return 0;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return query(a,b,2*k+1,l,m)+query(a,b,2*k+2,m,r)+sum[k]*(min(r,b)-max(l,a));
    }
};

void solve(){
    int N,M;
    cin >> N >> M;

    vector<vector<int>> l(M+1),r(M+1);
    rep(i,0,N){
        int L,R;
        cin >> L >> R;
        ++R;
        l[R-L].push_back(L);
        r[R-L].push_back(R);
    }

    segtree<int> seg(M+1,0);
    int x=N;
    rep(i,1,M+1){
        int ans=x;
        rep(j,1,M/i+1) ans+=seg.query(i*j,i*j+1);
        cout << ans << endl;
        
        rep(j,0,l[i].size()) seg.add(l[i][j],r[i][j],1);
        x-=l[i].size();
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 13952