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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dg(x) cerr << #x << ": " << (x) << endl;
#define dgv(v) cerr << #v << ": "; _shv(v);
#define dgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T> using v = vector<T>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void pt(T x) { cout << x << endl; }
template<typename T> inline void inv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int n, e, r;
    cin >> n >> e >> r;

    vv<pii> g(n);

    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].pb(mp(t, d));
    }

    pqg<pii> q;
    v<int> ans(n, -1);
    q.push(mp(0, r));

    while (!q.empty()) {
        auto t = q.top(); q.pop();
        if (ans[t.se] != -1) continue;
        ans[t.se] = t.fi;
        for (auto t1: g[t.se]) {
            q.push(mp(t.fi + t1.se, t1.fi));
        }
    }

    rep(i, n) {
        if (ans[i] == -1)
            pt("INF");
        else
            pt(ans[i]);
    }

    return 0;
}



Measured memory_bytes: 13956
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from collections import Counter

n,t = li()
a = li()

a_rev = a[::-1]
itv_max_rev = [0]
for i in range(n-1):
    itv_max_rev.append(max(itv_max_rev[-1], a_rev[i]))
    
itv_max = itv_max_rev[::-1]

cnt = Counter([])
for ai,ivmi in zip(a, itv_max):
    cnt[ivmi - ai] += 1
    
max_key = max(cnt.keys())
print(cnt[max_key])

Measured memory_bytes: 23328
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e6 + 3;

long long fexp(long long x, long long e = MOD - 2) {
	long long ans = 1;
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x % MOD;
		x = x * x % MOD;
	}
	return ans;
}

long long fat[MOD];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	fat[0] = 1;
	for(int i = 1; i < MOD; i++) {
		fat[i] = fat[i-1] * i % MOD;
	}
	int q;
	std::cin >> q;
	while(q--) {
		long long x, d, n, r;
		std::cin >> x  >> d >> n;
		if(d == 0) {
			std::cout << fexp(x, n) << '\n';
			continue;
		}
		r = fexp(d);
		x = x * r % MOD;
		if(x == 0 || x + n-1 >= MOD) {
			std::cout << "0\n";
			continue;
		}
		long long ans = fat[x+n-1] * fexp(fat[x-1]) % MOD * fexp(d, n) % MOD;
		std::cout << ans << '\n';
	}
}

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

int main() {
  string n;
  cin >> n;
  for(int i=0;i<n.size();i++){
    if(n[i]=='1'){
      n[i]='9';
    }else{
      n[i]='1';
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a[30],i;
	for(i=1;i<=30;i++) a[i]=0;
	for(i=1;i<=28;i++){
		scanf("%d",&n);
		a[n]=1;
	}
	for(i=1;i<=30;i++){
		if(a[i]!=1) printf("%d\n",i);
	}
	return 0;
}	

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

ll f(string s) {
  ll res = 0;
  int cnt = 0;
  per(i,sz(s)-1) {
    if(s[i] == 'A') res += cnt;
    else cnt++;
  }
  return res;
}

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

  string s;
  cin >> s;
  int n = sz(s);
  string t = "";
  s += "11";
  ll ans = 0;
  rep(i,n+1) {
    if(s[i] == 'A') t += 'A';
    else if(s[i] == 'B') {
      if(s[i+1] == 'C') t += 'D', i++;
      else {
        ans += f(t);
        t = "";
      }
    }
    else {
      ans += f(t);
      t = "";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
 
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値
 
ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}
 
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
 
 
int main(){
    ll x,y;
    cin >> x >> y;
    bool ans = false;
    rep(i,x+1){
        if (i*2 + (x-i)*4 == y) ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3668
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);
    let count = a.into_iter().filter(|e| e%2 == 1).count();
    if count % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 10492
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int n, a[N], b[N], c[N], sum;

void solve() {
	int n;
	cin >> n;

	for (int i = 1; i <= n; ++ i)
		cin >> a[i];

	for (int i = 1; i <= n; ++ i)
		cin >> b[i], sum += b[i];

	for (int i = 1; i < n; ++ i)
		cin >> c[i];

	for (int i = 1; i <= n; ++ i)
		if (a[i] == a[i + 1] - 1)
			sum += c[a[i]];

	cout << sum;
}

main () {
    to_pray();
    
    do {
    	solve();
    }while(false);
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cerr << '\n';
    
    return 0;
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INF INT_MAX
#define ll long long

int main()
{
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;

	int type = 0;
	int type_b = 0;
	ll res = 1;
	for (int i = 0; i < n; i++) {
		type_b = type;
		if (i == n - 1 || s1[i] != s1[i + 1]) {
			type = 1;
		}
		else {
			type = 2;
			i++;
		}

		if (type_b == 0) {
			if (type == 1) {
				res = 3;
			}
			if (type == 2) {
				res = 6;
			}
		}
		else {
			if (type_b == 1 && type == 1) {
				res = (res * 2) % MOD;
			}
			if (type_b == 1 && type == 2) {
				res = (res * 2) % MOD;
			}
			if (type_b == 2 && type == 1) {
				res = (res * 1) % MOD;
			}
			if (type_b == 2 && type == 2) {
				res = (res * 3) % MOD;
			}
		}
	}
	cout << res << endl;

	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  int N,M;
  cin >> N>>M;
  vll H(N);rep(i,N)cin>>H[i];
  vector<vector<int>> G(N);
  rep(i,M){
    int a,b;cin>>a>>b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll ans=0;
  rep(i,N){
    bool flag=true;
    rep(j,G[i].size()){
      //cout<<H[i]<<H[j]<<endl;
      if(H[i]<=H[G[i][j]]) flag=false;
    }
    if(flag) ans++;
    //cout <<"i " << i << "ans" << ans << endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9076
from math import factorial

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

n, m = map(int, input().split())
t = 100*(n-m) + m*1900 # 1回あたり
rs = [0.5**m * ( 1- 0.5**m)**i for i in range(int(1e4))]
ans = 0.0

for i,r in enumerate(rs):
    ans += ((i+1)*t)*r 
    
print(round(ans))

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

int main(){
	string s,t;
	cin>>s>>t;
  	int size=s.size();
	rep(i,s.size()){
		if(s.substr(0,i+1)==t.substr(size-i-1,size)&&s.substr(i+1,size)==t.substr(0,size-i-1)){
			puts("Yes");
			return 0;
		}
		
	}
	puts("No");
}


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

int main() {
  	//
  int a, b;
  cin >> a >> b;
  if( a*b % 2 == 0){
    cout << "Even" << endl;
  }
  if( a*b % 2 == 1){
    cout << "Odd" << endl;
  }
}
    

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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NY = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NY[0];
            var Y = NY[1];
            var num10000 = Math.Max(Math.Min((Y / 10000), N), 0);

            while (num10000 >= 0)
            {
                var m = N - num10000;
                for (var i = 0; i <= m; i++)
                {
                    var num5000 = i;
                    var num1000 = m - num5000;
                    var y = 10000 * num10000 + 5000 * num5000 + 1000 * num1000;

                    if (y == Y)
                    {
                        Console.WriteLine($"{num10000} {num5000} {num1000}");
                        return;
                    }
                }

                num10000--;
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  vector<ll> a(n),b(n);
  vector<pair<ll,ll>> p(n);
  rep(i,n){
    cin >> a[i] >> b[i];
    p[i] = m_p(b[i],a[i]);
  }
  sort(all(p));

  ll time = 0;
  rep(i,n){
    if(time+p[i].se<=p[i].fi){
      time += p[i].se;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>


using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi x(n+1), y(m+1);

		scanf("%d%d", &x[0], &y[0]);

		for(int i=1;i<=n;i++)
		{
			scanf("%d", &x[i]);
		}
		for(int i=1;i<=m;i++)
		{
			scanf("%d", &y[i]);
		}
		sort(x.rbegin(), x.rend());
		sort(y.begin(), y.end());
		printf("%s\n", x[0]<y[0]?"No War":"War");
	}

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, a; cin >> n >> a;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    // dp[i][j][k] := i 個あるうち j 個を選んで合計を k にする数
    // ans = ∑dp[n][j][j*a] (1 <= j <= n)
    ll dp[55][55][2525] = {};
    dp[0][0][0] = 1;
    rep(i, n) rep(j, n) rep(k, 2525) {
        // i+1 個目を選ばない
        dp[i+1][j][k] += dp[i][j][k];
        // i+1 個目を選ぶ
        if(k-x[i] >= 0) {
            dp[i+1][j+1][k] += dp[i][j][k-x[i]];
        }
    }
    ll ans = 0;
    REP(j, 1, n+1) {
        ans += dp[n][j][a*j];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 59904
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int W[4100][4100];
int B[4100][4100];
char in[2];
int cw(int a,int b,int c,int d){
	return W[c][d]+W[a][b]-W[a][d]-W[c][b];
}
int cb(int a,int b,int c,int d){
	return B[c][d]+B[a][b]-B[a][d]-B[c][b];
}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%d%s",&p,&q,in);
		if(in[0]=='W')W[p%(b*2)+1][q%(b*2)+1]++;
		if(in[0]=='B')B[p%(b*2)+1][q%(b*2)+1]++;
	}
	for(int i=1;i<=b*2;i++){
		for(int j=1;j<=b*2;j++){
			W[i+b*2][j]=W[i][j];
			W[i][j+b*2]=W[i][j];
			W[i+b*2][j+b*2]=W[i][j];
			B[i+b*2][j]=B[i][j];
			B[i][j+b*2]=B[i][j];
			B[i+b*2][j+b*2]=B[i][j];
		}
	}
	for(int i=0;i<b*4+1;i++){
		for(int j=0;j<b*4+1;j++){
			W[i][j+1]+=W[i][j];
			B[i][j+1]+=B[i][j];
		}
	}
	for(int i=0;i<b*4+1;i++){
		for(int j=0;j<b*4+1;j++){
			W[j+1][i]+=W[j][i];
			B[j+1][i]+=B[j][i];
		}
	}
	int ret=0;
	for(int i=0;i<2*b;i++){
		for(int j=0;j<2*b;j++){
			ret=max(ret,cw(i,j,i+b,j+b)+cw(i+b,j+b,i+2*b,j+2*b)+cb(i,j+b,i+b,j+2*b)+cb(i+b,j,i+b*2,j+b));
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 131200
n   = gets.chomp.to_i
ary = []

n.times do
  ary << gets.chomp.to_i
end

def maxof(x, y)
  x > y ? x : y
end

def minof(x, y)
  x > y ? y : x
end

i    = 1
maxv = -200_000_000_000
minv = ary[0]

while i < n
  maxv = maxof(maxv, ary[i] - minv)
  minv = minof(minv, ary[i])
  i    += 1
end

puts maxv

Measured memory_bytes: 10564
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long int ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define deb(x) cout<<"Debug\t"<<#x<<"="<<x<<endl;
#define deb2(x,y) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<endl;
#define deb4(x,y,z,w) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<"\t"<<#w<<"="<<w<<endl;
#define mod 1000000007
#define vi vector<ll>
#define pll pair<ll,ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define pb push_back 
#define pf push_front
#define pll pair<ll,ll>


int main()
{
    ios;    
    ll t,i,n,m,j,x,y,pos,ans,sum,mini,k,diff;string s;
    char ch;
    cin>>ch;
    
    if(ch>=97)
    cout<<"a"<<endl;
    else
    cout<<"A"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const int MOD=1e8;
const int N=13;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
vector<vector<int> >vec;
int n;
int dfs(int i, int j)
{
    if (i == 2 || j == n) return 0;
    else if (i == 1 && j == n-1) return vec[i][j];
    else return max(dfs(i+1,j),dfs(i,j+1))+vec[i][j];
}
int main()
{
    //fre;
    IO;
    vector<int>a;
    int x;
    while(cin >> n)
    {
        rep(i,0,2)
        {
            rep(j,0,n)
            {
                cin >> x;
                a.pb(x);
            }
            vec.pb(a);
            a.clear();
        }
        cout<<dfs(0,0)<<endl;
        vec.clear();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define inf 1000000000
#define ninf -1000000000
#define for0(n) for(int i=0;i<n;i++)
#define fori(a,n) for(int i=a;i<n;i++)
#define rev(n,d) for(int i=n;i>=d;i--)
#define mem(ar,x) memset(ar,x,sizeof ar)
inline long long  max2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  min3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007
constexpr int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int h,w;
long long black,white;
char p[405][405];

void dfs(int x, int y, int cnt)
{
    if(p[x][y]=='#')
        black++;
    else if(p[x][y]=='.')
        white++;
        
    p[x][y]='x';
    for0(4)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if(p[nx][ny]==((cnt%2==0)?'.':'#'))
        {
            dfs(nx,ny,cnt+1);
        }
    }
}
int main() {
   
    {
        int n,i,j;
        cin>>h>>w;
        
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
               cin>>p[i][j]; 
            }
        }
        long long ans;
         for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
               if(p[i][j]=='#')
               {
                   black=0;
                    white=0;
                   dfs(i,j,0);
                   ans+=black*white;
               }
            }
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  vi v(n); rep(i, n) cin >> v[i];
  int r = min(n,k);

  int ans = 0;
  for(int a = 0; a <= r; a++) for (int b = 0; a + b <= r; b++) {
    priority_queue<int, vi, greater<int>> pq;
    rep(i, a) pq.push(v[i]);
    rep(i, b) pq.push(v[n-1-i]);

    for (int i = 0; i < k-a-b; i++) {
      if(pq.size() > 0 && pq.top() < 0) pq.pop();
    }

    int sum = 0;
    while(pq.size() != 0){
      sum += pq.top();
      pq.pop();
    }
    chmax(ans,sum);
  }
  std::cout << ans << '\n';
}


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

int main(){
    ll m, k;
    cin >> m >> k;
    if(m <= 1) {
        if(k == 0) {
            rep(i, 0, 1LL<<(m+1)) cout << i/2 << " ";
            cout << endl;
        } else {
            cout << -1 << endl;
        }
    } else {
        if(k < 1LL<<(m)) {
            rep(i, 0, 1LL<<(m)) if(i != k) cout << i << " ";
            cout << k << " ";
            for(ll i = (1LL<<(m))-1; i >= 0; i--) if(i != k) cout << i << " ";
            cout << k << endl;
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int k,x;
  cin >> k >> x;
  bool f = true;
  for(int i=x-k+1;i<x+k;++i) {
    if( !f ) cout << " "; f = false;
    cout << i;
  } puts("");
  compute();
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int k = sc.nextInt();
                int n = sc.nextInt();
                int[] a = new int[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                int[] b = new int[n];
                for(int i = 0 ; i < n - 1 ; i++){
                        b[i] = a[i + 1] - a[i];
                }
                b[n - 1] = k - a[n - 1] + a[0];
                Arrays.sort(b);
                System.out.println(k - b[n - 1]);
        }
}
//地味に部屋が暑いです
//くだらないミスしていたので切腹します

Measured memory_bytes: 60408
#include <iostream>
#include <cmath>

int main(){
  long long a,b,c;
  std::cin >> a >> b >> c;
  
  auto t = c - a - b;
  if(t <= 0){
  	std::cout << "No" << std::endl;
    return 0;
  }
  
  std::cout << (4 * a * b < t*t ? "Yes" : "No") << std::endl;
  return 0;
}

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


int main() {
	
	int n,k;
	cin >> n >> k;
	int cnt=0;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		if(h>=k) cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
int n,ts;
const int MA=1000003;
char t[MA];
int cnt[MA];
int solve[MA];
int main(){
while(true){
	rep(j,MA)t[j]=solve[j]=cnt[j]=0;
	scanf("%d",&n);
	if(n==0)break;
	scanf("%d",&ts);
	scanf("%s",t);
	

	
	int i=2,ans=0;
	
	while(i<=ts){
		if(t[i]=='I'){
			if(t[i-1]=='O'&&t[i-2]=='I'){
				cnt[i]=cnt[i-2]+1;
			
			}
		}
		i++;
	}

	//rep(j,ts)cout<<cnt[j]<<" ";cout<<endl;
	rep(j,ts)if(cnt[j]>=n)ans++;

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


Measured memory_bytes: 11940
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
LL w[101010], d[101010];

int main(){
    
    // 1. 入力情報.
    int N;
    LL K;
    scanf("%d %lld", &N, &K);
    rep(i, N) scanf("%lld %lld", w + i, d + i);
    
    // 2. 二分探索.
    // l = 1 から 開始すると, 以下のテストケースで, 2が出力された.
    // ※ 1が正解のはず.
    // ex.
    // 1 1
    // 1 1
    // -> b04 で WA版 となった原因と推定.
    LL l = 0, h = 2e18, m, X;
    int debug = 0;
    while(l < h - 1 && debug < 100){
        // 花の本数をカウント.
        m = (l + h) / 2;
        X = 0;
        rep(i, N) if(w[i] <= m) X += (1 + (m - w[i]) / d[i]);
        
        // l, h 更新.
        if(X >= K) h = m;
        else       l = m;
        
        // 無限ループ防止用.
        debug++;
    }
    
    // 3. 出力.
    printf("%lld\n", h);
    return 0;
    
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll r;
    cin >> r;

    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set> 
#include <iterator> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int main()
{
    
    fastio();
    int n,m;
    cin>>n>>m;
    ll int a[n][m];
    char ch;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>ch;
            if(ch=='#')
                a[i][j]=-1;
            else
                a[i][j]=0;
        }
    }
    a[0][0]=1;
    ll c,d;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            c=0,d=0;
            if(a[i][j]!=-1)
            {
                if(i!=0 && a[i-1][j]!=-1)
                    c=a[i-1][j];
                if(j!=0 && a[i][j-1]!=-1)
                    d=a[i][j-1];
                a[i][j]=(c+d)%MOD;
                a[0][0]=1;
            }
        }
    }
    cout<<a[n-1][m-1]%MOD<<endl;
}


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

int main(){
    int N, a2;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(i, 2){
        rep(j, N) cin >> A[i][j];
    }
    rep(i, N) a2 += A[1][i];
    int ans = A[0][0]+a2;
    int su = ans;
    rep(i, N-1){
        su = su+A[0][i+1]-A[1][i];
        ans = max(ans, su);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

ll n;
ll memo[1020][20'020];

ll W[1020];
ll S[1020];
ll V[1020];

vi I;
ll comp(ll a, ll b) {
    return (W[a]+S[a]) > (W[b]+S[b]);
}

ll dp(ll at, ll can_put) {
    if(at >= n) return 0;
    if(can_put == 0) return 0;
    if(memo[at][can_put] != -1) return memo[at][can_put];

    ll mx = dp(at+1,can_put);

    if(W[I[at]] <= can_put) {
        mx = max(mx, dp(at+1,  min(can_put - W[I[at]], S[I[at]])) + V[I[at]]);
    }

    return memo[at][can_put] = mx;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n;
    rep(i,0,n) {
        cin >> W[i] >> S[i] >> V[i];
    }

    rep(i,0,n) I.pb(i);
    sort(I.begin(), I.end(), comp);
    cout << dp(0,20'000) << endl;
    return 0;
}




Measured memory_bytes: 159872
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j]!=s[k]:
            ans -= 1
print(ans)


Measured memory_bytes: 9192
import sys
def main():
    input = sys.stdin.readline
    N,S=map(int, input().split())
    *A,=map(int, input().split())

    ans = Mint()
    q = [Mint() for _ in range(S+1)]
    for a in A:
        q[0] += 1
        for i in range(S-a,-1,-1): q[i+a] += q[i]
        ans += q[S]
    print(ans)

MOD = 998244353
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value += Mint.get_value(other)
        if self.value >= MOD: self.value -= MOD
        return self
    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value -= Mint.get_value(other)
        if self.value < 0: self.value += MOD
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

if __name__ == '__main__':
    main()

Measured memory_bytes: 44656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m,k; cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  rep(i, n) cin >> a[i+1];
  rep(i, n) a[i+1] += a[i];
  rep(i,m) cin >> b[i+1];
  rep(i,m) b[i+1] += b[i];
  a.pop_back();
  b.pop_back();
  int ans = 0;
  rep (i,n+1) {
    if (a[i] > k) break;
    int now = i;
    int rest = k-a[i];
    auto it = lower_bound(b.begin(), b.end(), rest);
    now += it - b.begin();
    if (rest < *it) now--;
    chmax(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6276
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

# pが1-3のとき
for t in range(3):
    temp = [abs(a-b)**(t+1) for (a,b) in zip(x,y)]
    print(sum(temp)**(1/(1+t)))

# pが∞のとき
temp = [abs(a-b) for (a,b) in zip(x,y)]
print(max(temp))



Measured memory_bytes: 5648
#include <cstdio>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

int N;
string C;

bool input() {
    cin >> N;
    if (N == 0) return false;
    cin >> C;
    return true;
}

int main() {
    while (input()) {
        vector<int> p(N);
        int f = 0;
        for (int i = 0; i < 100; i++) {
            int x = i % N;
            if (C[i] == 'M') {
                p[x]++;
            } else if (C[i] == 'S') {
                f += p[x] + 1;
                p[x] = 0;
            } else { assert(C[i] == 'L');
                p[x] += f + 1;
                f = 0;
            }
        }
        sort(p.begin(), p.end());
        cout << p[0];
        for (int i = 1; i < N; i++) {
            cout << " " << p[i];
        }
        cout << " " << f;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
import sys
from collections import deque


def input():
    return sys.stdin.readline()[:-1]


def solve():
    N, P = map(int, input().split())
    S = input()
    if (10 % P == 0):
        ans = 0
        for i in range(N):
            if int(S[N - i - 1]) % P == 0:
                ans += N - i
        return ans
    ten = 1
    cur = 0
    val = [0] * P
    val[cur] += 1
    for i in range(N):
        cur = (cur + int(S[N - i - 1]) * ten) % P
        ten *= 10
        ten %= P
        val[cur] += 1
    ans = 0
    for p in range(P):
        ans += val[p] * (val[p] - 1) // 2
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3880
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	priority_queue<int> pq;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		pq.emplace(a);
	}

	while (M) {
		int now = pq.top();
		pq.pop();
		now /= 2;
		pq.emplace(now);
		M--;
	}

	lint ans = 0;
	while (!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

bool is_prime(int n){
  bool res=true;
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0) res=false;
  }
  return res;
}

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

  bool prime[250001];
  for(int i=1;i<250000;i++){
    prime[i]=is_prime(i);
  }
    
  int n;
    
  while(cin>>n,n){
    int ans=0;
    for(int i=n+1;i<=2*n;i++){
      if(prime[i]) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3360
s=input()
t=input()
v=0
for i in range(len(s)):
    u=s.find(t)
    
    s=s[u+1:]
    if u==-1:
        break
    else:
        
        print(u+v)
        v=v+u+1
    
    
    
    
      
    
    
    
    
    


Measured memory_bytes: 5572
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF 1e+18
#define MAX_V 100100
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Graph Start
struct edge {
    int from, to;
    long long cost;
};
/// Graph End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template



signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(n);
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(All(l),greater<int>());
    int sum = 0;
    rep(i,n-1) sum += l[i+1];
    if(l[0]<sum){
        cout << "Yes" << nn;
    }else{
        cout << "No" << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
    
int main(){
    double n;
    const double PI = (acos(-1));
    cin >> n;
    cout << fixed << setprecision(10) << 2*n*PI << endl;
    return 0;
}

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

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

  map<char, long long> mp;
  mp['M'] = 0, mp['A'] = 0, mp['R'] = 0, mp['C'] = 0, mp['H'] = 0;
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    char c = str.at(0);

    if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') mp.at(c)++;
  }

  long long ans = 0;
  ans += mp.at('M') * mp.at('A') * mp.at('R');
  ans += mp.at('M') * mp.at('A') * mp.at('C');
  ans += mp.at('M') * mp.at('A') * mp.at('H');
  ans += mp.at('M') * mp.at('R') * mp.at('C');
  ans += mp.at('M') * mp.at('R') * mp.at('H');
  ans += mp.at('M') * mp.at('C') * mp.at('H');
  ans += mp.at('A') * mp.at('R') * mp.at('C');
  ans += mp.at('A') * mp.at('R') * mp.at('H');
  ans += mp.at('A') * mp.at('C') * mp.at('H');
  ans += mp.at('R') * mp.at('C') * mp.at('H');
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int i=0, n,h,w,m=-1;
	int H[300], W[300];

	do {

		m = m + 1;
		cin >> H[m] >> W[m];

	} while (H[m] != 0 && W[m] != 0);

	do {

		h = H[i];
		w = W[i];

		if (h == 0 && w == 0) {
			break;
		}

		else {

			for (n = 0; n < h; n++) {

				for (int i = 0; i < w; i++) {

					cout << "#";

				}
				cout << endl;
			}

			cout << endl;

			i++;

		}
	} while (i);

}

Measured memory_bytes: 3084
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
        double x = scan.nextDouble();
        double y = scan.nextDouble();
        System.out.printf("%.8f%n", Math.hypot(scan.nextDouble()-x, scan.nextDouble()-y));
    }
}

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

using namespace std;

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

	long long n, m;
	cin >> n >> m;
	long long d = min(m, 2 * n);
	long long res = d / 2;
	m -= d;
	res += m / 4;
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();
        int X = nextInt();
        int T = nextInt();

        int factor = (int)Math.ceil((double)1 * N / X);
        System.out.println(factor * T);
    
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32600
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,n;
	while(true){
		cin>>a>>b>>n;
		if(a==0&&b==0&&n==0)
			break;
		int count=0,s=a;
		while(s<2)
			s+=b;
		while(true){
			bool t=true;
			for(int j=2;j*j<=s;j++){
				if(s%j==0)
					t=false;
			}
			if(t==true)
				count++;
			if(count==n)
				break;
			s+=b;
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160