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

using namespace std;

#define all(x) begin(x), end(x)

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

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

    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        pq.push(x);
    }

    while (m-- > 0) {
        int x = pq.top();
        pq.pop();

        pq.push(x / 2);
    }

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

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


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

long long gcd (long long a, long long b) {
  if(a < b) {
    int foo = a;
    a = b;
    b = foo;
  }

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

int main() {
  long long a ,b;

  while (scanf("%lld %lld", &a, &b) == 2) {
    long long g = gcd(a, b);
    printf("%lld %lld\n", g, (a * b) / g);

  }

  return 0;
}

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

int main() {
    int n = 0;
    string s;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            n++;
        } else if (s[i] == '-') {
            n--;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let mut v: Vec<u32> = Vec::with_capacity(n);
    for _ in 0..n{
        v.push(read());
    }
    let mut ret = 0;
    for i in 0..n {
        let mut see = true;
        for j in 0..i {
            if v[j] > v[i] {
                see = false;
                break;
            }
        }
        if see {
            ret += 1;
        }
    }
    println!("{}", ret);
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// =================グラフテンプレート==================

// costの部分の型は指定できます
template <typename T>
struct edge {
  int from, to;
  T cost;

  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

  // 行き先を代入できる
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  // intにキャスト(?)するとかなんとか
  operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
using Matrix = vector<vector<T>>;

using UnWeightedGraph = vector<vector<int>>;

// =============ベルマン・フォード法=============
// 負の閉路を検出できます(空のvectorを返します)
// bellman<距離の型>(重み付き辺の集合,頂点数,始点)

template <typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);

  dist[s] = 0;
  for (int i = 0; i < V - 1; i++) {
    for (auto &e : edges) {
      if (dist[e.from] != INF)  // 遷移できるなら
        dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
    }
  }
  for (auto &e : edges) {  // 離島、負の閉路について
    if (dist[e.from] == INF) continue;
    if (dist[e.from] + e.cost < dist[e.to]) return vector<T>();
  }
  return dist;
}

// ====================================================================

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  Edges<ll> edges;
  for (int i = 0; i < m; i++) {
    int s, t;
    ll c;
    cin >> s >> t >> c;
    edges.push_back(edge<ll>{s, t, c});
  }

  vector<ll> ans = bellman_ford(edges, n, r);

  if (ans.size())
    for (auto x : ans)
      if (x >= INFL)
        cout << "INF" << endl;
      else
        cout << x << endl;
  else
    cout << "NEGATIVE CYCLE" << endl;
}



Measured memory_bytes: 3136
def bbb(x, y):
    return (x * y) // aaa(x, y)
 
 
def aaa(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return aaa(y, x % y)
 
 
a, b, c, d = map(int, input().split())
bc = b // c
bd = b // d
ac = (a-1) // c
ad = (a-1) // d
aw = (a-1) // bbb(c, d)
bw = b // bbb(c, d)
print((b - a + 1) - (bc - ac) - (bd - ad) + (bw - aw))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int t=sqrt(n),l,ans=2;
	FOR(i,2,t){
		l=n;
		while(l%i==0)l/=i;
		l%=i;
		ans+=(l==1);
		ans+=((n-1)%i==0);
	}
	ans-=(t*t==n-1);
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
参考:
https://webkaru.net/clang/find-lcm-of-two-number/
*/

int main(){
    ll a, b, r, x, tmp;
    cin >> a >> b;    
    x = a * b;
    
    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    
    ll ans = x/b;
    /* 最小公倍数を出力 */
    cout << x/b;

    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 1000003
#define INF 1e9
ll knapsack(ll W, ll weight[], ll  value[], ll n){
	ll i,w;
	ll k[n+1][W+1];
	for(i=0;i<=n;i++){
		for(w=0;w<=W;w++){
			if(i==0 or w==0)
			k[i][w]=0;
			else if (weight[i-1]<=w)
			k[i][w] = max(value[i-1]+k[i-1][w-weight[i-1]], k[i-1][w]);
		    else
		    k[i][w] = k[i-1][w];
		}
	}
	return k[n][W];
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,w,i,j,t,k,l,r;
   	cin>>n>>w;
   	ll weight[n],value[n];
   	for(i=0;i<n;i++) cin>>weight[i]>>value[i];
   	cout<<knapsack(w,weight,value,n);
 }

Measured memory_bytes: 79104
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;


static INF_I64 :i64 = 9223372036854775807;
static INF_I32 : i32 = 2147483647;




fn main() {

    input! { 
       n: usize,
       x: i64,
       a: [ i64;n],
    }

    let mut ans = vec![0;n];

    ans[0] = cmp::min(x,a[0]);
    let mut sum1= a[0];
    let mut sum2 = ans[0];
    

    for i in 1..n{
        ans[i] = if ans[i-1] + a[i] < x { a[i] } else { x - ans[i-1] };
        sum2+=ans[i];
        sum1+= a[i];
    }
    
    
    println!("{}",sum1-sum2);


}


Measured memory_bytes: 8444
n,m = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(n)]

from operator import itemgetter
ab = sorted(ab,key=itemgetter(0),reverse = False)

vl = 0
dr = 0

for i in range(n):
    if ab[i][1] + dr <= m:
        dr += ab[i][1]
        vl += ab[i][1] * ab[i][0]
    elif (ab[i][1] + dr > m) and dr < m :
        vl += (m-dr) * ab[i][0]
        dr += (m-dr)
        break
print(vl)


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      if (A % 2 == 1) A -= 1;
      B += A / 2;
      A /= 2;
    }
    else {
      if (B % 2 == 1) B -= 1;
      A += B / 2;
      B /= 2;
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 3580
program main
  implicit none
  character(200) :: s
  integer :: n, ed
  read(*, *) s
  n = len(trim(s))
  do ed = n - 2, 2, -2
    if (is_even(s(1:ed))) then
      write(*, "(i0)") ed
      exit
    end if
  end do

  contains

  function is_even(s)
    implicit none
    character(*), intent(in) :: s
    logical :: is_even
    integer :: n, i, j
    n = len(s)
    if (mod(n, 2) == 1) then
      is_even = .false.
      return
    end if
    do i = 1, n / 2
      j = i + n / 2
      if (s(i:i) /= s(j:j)) then
        is_even = .false.
        return
      end if
    end do
    is_even = .true.
  end function is_even
end program main


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

int main()
{
  int n;cin>>n;
  vector<int> p(n), q(n);
  for (auto &&i : p)
  {
    cin>>i;
  }
  for (auto &&i : q)
  {
    cin>>i;
  }
  vector<int> perm(n);
  for (size_t i = 0; i < n; i++)
  {
    perm[i] = i+1;
  }
  int tmp1,tmp2,cnt=1;
  do
  {
    if (q == perm)
    {
      tmp1 = cnt;
    }
    if (p == perm)
    {
      tmp2 = cnt;
    }
    cnt++;
    
  } while (next_permutation(perm.begin(),perm.end()));
  cout << abs(tmp2 - tmp1) << endl;
  
  
  
}

Measured memory_bytes: 3560
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, a, b = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

mod = 10 ** 9 + 7
def fast_nCk(n, k, mod):
    upper = 1
    for i in range(n - k + 1, n + 1):
        upper = upper * i % mod
    below = 1
    for i in range(1, k + 1):
        below = below * i % mod
    
    ans = upper * pow(below, mod - 2, mod) % mod
    ans %= mod
    return ans

A = fast_nCk(n, a, mod)
B = fast_nCk(n, b, mod)
total = (pow(2, n, mod) - 1) % mod
ans = (total - A - B) % mod
print(ans)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    int k, a, b; cin >> k >> a >> b;
    
    int x = (a/k)*k;
    
    if(x >= a && x <=b) cout << "OK";
    else if(x+k >= a && x+k <= b) cout << "OK";
    else cout << "NG";
    
    
    
    
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    vector<int> l(N);
    REP(i, N) cin>>l[i];
    int M = 256;
    int as, aa, ac;
    double ent = 1e32;
    REP(S, 16)REP(A, 16)REP(C, 16){
      vector<int> R(N + 1);
      R[0] = S;
      REP(i, N) R[i + 1] = (A * R[i] + C) % M;
      REP(i, N) R[i + 1] = (R[i + 1] + l[i]) % M;
      double cnt[256] = {};
      REP(i, N) cnt[R[i + 1]] += 1.0;
      double e = 0;
      REP(i, 256)if(cnt[i] != 0){
        double c = cnt[i];
        e += -c/N * log(c/N);
        if(!(e + EPS < ent)) goto END;
      }
      ent = e;
      as = S, aa = A, ac = C;
END:;
    }
    printf("%d %d %d\n", as, aa, ac);
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n,t;
    cin>>n>>t;
    vector<int> wei(n),val(n);
    rep(i,n) cin>>wei[i]>>val[i];
    
    auto dp1=make_vec<int>(n+10,4000);
    auto dp2=make_vec<int>(n+10,4000);
    
    rep(i,n) {
        rep(w,t+1) {
            if(w-wei[i]>=0) dp1[i+1][w]=max(dp1[i][w],dp1[i][w-wei[i]]+val[i]);
            else dp1[i+1][w]=dp1[i][w];
        }
    }
    
    reverse(all(wei));
    reverse(all(val));
    rep(i,n) {
        rep(w,t+1) {
            if(w-wei[i]>=0) dp2[i+1][w]=max(dp2[i][w],dp2[i][w-wei[i]]+val[i]);
            else dp2[i+1][w]=dp2[i][w];
        }
    }
    
    reverse(all(wei));
    reverse(all(val));
    int ans=0;
    FOR(i,1,n) {
        rep(j,t) {
            ans=max(ans,dp1[i-1][j]+dp2[n-i][t-1-j]+val[i-1]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 94592
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
// char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e5+5;
ll n , k;
ar<ll,2> a[maxN];
void solve(){
  cin>> n ;
  for(ll i=0;i<n ;i++){
      cin>>a[i][0]>>a[i][1];
  }
  bool ok=0;
  for(ll i=2;i<n ; i++){
      if(a[i][0]==a[i][1] && a[i-1][0]==a[i-1][1] && a[i-2][0]==a[i-2][1])ok=1;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

int main(){
// 	mahakal();
	fast;
	ll t =1 ;
// 	cin>> t ; 
	while(t--)solve();
// 	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}


Measured memory_bytes: 3648
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n; cin >> n;
    vll yp, yn;
    rep(i,n){
        int x,y; cin >> x >> y;
        yp.emplace_back(y+x);
        yn.emplace_back(y-x);
    }
    sort(all(yp));
    sort(all(yn));
    ll ans = max(yp.back()-yp.front(),yn.back()-yn.front());
    cout << ans << '\n';
    
    // vector<pi> pts;
    // rep(i,n){
    //     int x,y; cin >> x >> y;
    //     pts.emplace_back(x,y);
    // }
    // sort(all(pts));

}


Measured memory_bytes: 6692
package main

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

func main() {
	resolve(os.Stdin)
}

func resolve(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b := scanInt(sc), scanInt(sc)
	n := (b - 1) / (a - 1)
	if (b-1)%(a-1) != 0 {
		n++
	}
	fmt.Println(n)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;
using ll = long long;
int n,x[16],y[16],d[16],D[16],p[16];
ll ans[16];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    memset(ans , 0x3f , sizeof(ans));
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>p[i];
    }

    for(int i=0;i<n;i++){
        D[i] = min(abs(x[i]) , abs(y[i]));
    }
    ans[0] = 0;
    for(int i=0;i<n;i++){
        ans[0] += (ll)D[i]*p[i];
    }
    for(int i=1;i<(1<<n);i++){
        int j = i;
        do{
            memcpy(d,D,sizeof(D));
            for(int k=0;k<n;k++){
                if(i>>k&1){
                    if(j>>k&1){
                        for(int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(x[q] - x[k]));
                        }
                    }
                    else{
                        for(int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(y[q] - y[k]));
                        }
                    }
                }
            }
            ll tmp = 0;
            for(int i=0;i<n;i++) tmp += (ll)d[i] * p[i];
            ans[__builtin_popcount(i)] = min(ans[__builtin_popcount(i)] , tmp);
            j = (j-1) & i;
        }while(j != i);
    }
    for(int i=0;i<=n;i++) cout<<ans[i]<<endl;
    return 0;
}









Measured memory_bytes: 3628
# coding: utf-8 
n = int(input())
s = [input() for _ in range(n)]
a = 0
b = 0
ab = 0
ans = 0
for x in s:
    if x[0] == 'B':
        if x[len(x)-1] == 'A':
            ab += 1
        else:
            b += 1
    elif x[len(x)-1] == 'A':
        a += 1
    ans += x.count('AB')
if ab == 0:
    print(ans+min(a,b))
else:
    if a + b > 0:
        print(ans+ab+min(a,b))
    else:
        print(ans+ab-1)

Measured memory_bytes: 3700
n,m,k = map(int,input().split())
ans = 0
mod = 998244353
p = [0 for i in range(n)]
p[0] = 1
for i in range(n-1):
    p[i+1] = p[i]*(i+2)%mod
p.append(1)
for i in range(k+1):
    u = pow(m-1,n-1-i,mod)
    s = p[n-2]*pow(p[i-1],mod-2,mod)*pow(p[n-i-2],mod-2,mod)
    ans = (ans + m*u*s)%mod
print(ans)

Measured memory_bytes: 89552
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  int input(a);
  int input(b);
  cout << ((a * b) & 1 ? "Odd" : "Even") << endl;
}


Measured memory_bytes: 256
#include <string.h> 

#include <stdio.h> 

#include <stdlib.h> 

struct Node { 

    int key; 

    struct Node *prev, *next; 

}; 

 

struct Node *nil; 

 

void init() { 

    nil = (struct Node *)malloc(sizeof(struct Node)); 

    nil->next = nil; 

    nil->prev = nil; 

} 

 

void insert(int key) { 

    struct Node *x = (struct Node *)malloc(sizeof(struct Node)); 

    x->key = key; 

    x->next = nil->next; 

    nil->next->prev = x; 

    nil->next = x; 

    x->prev = nil; 

} 

 

struct Node* listSearch(int key) { 

    struct Node *cur = nil->next; 

    while(cur != nil && cur->key != key ) { 

        cur = cur-> next; 

    } 

    return cur; 

} 

 

void deleteNode(struct Node *t) { 

    if (t == nil) return; 

    t->prev->next = t->next; 

    t->next->prev = t->prev; 

    free(t); 

} 

 

void deleteFirst() { 

    deleteNode(nil->next); 

} 

 

void deleteLast() { 

    deleteNode(nil->prev); 

} 

void deleteKey(int key) { 

    deleteNode(listSearch(key)); 

} 

 

void printList() { 

    struct Node *cur; 

    cur = nil->next; 

    int isf = 0; 

 

    while(1) { 

        if (cur == nil) break; 

        if(isf++ > 0) printf(" "); 

        printf("%d", cur->key); 

        cur = cur->next; 

    } 

    printf("\n"); 

} 

 

 

int main(void) { 

    int key, n, i; 

    int size = 0; 

    char com[20]; 

    int np = 0, nd = 0; 

    scanf("%d", &n); 

    init(); 

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

        scanf("%s%d",com, &key); 

        if(com[0] == 'i') { 

            insert(key); 

            np ++; 

            size++; 

        }else if(com[0] == 'd') { 

            if(strlen(com) > 6) { 

                if( com[6] == 'F') { 

                    deleteFirst(); 

                }else if(com[6] == 'L') { 

                    deleteLast(); 

                } 

            }else { 

                deleteKey(key); 

                nd ++; 

            } 

            size --; 

        } 

    } 

    printList(); 

    return 0; 

 

} 


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

int main(){
  
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  vector<int> a(N, 0);
  for(int i=0; i<N; i++){
    if(S.at(i)=='A'){
      if(i==N-1) continue;
      
      if(S.at(i+1)=='C'){
        a.at(i) += 1;
      }
    }
  }

  vector<int> s(N+1, 0);
  for(int i=0; i<N; i++){
    s.at(i+1) = s.at(i) + a.at(i);
  }

  for(int q=0; q<Q; q++){
    int l, r;
    cin >> l >> r;

    l = l - 1;
    r = r - 1;

    cout << s.at(r) - s.at(l) << endl;
  }

  

  return 0;
}

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

using namespace std;

int main() {
  int n, k, i, j, x;
  cin >> n >> k;
  vector<int> h, c;
  h.push_back(0);
  c.push_back(0);
  for (i = 1; i<=n; i++) {
    cin >> x;
    h.push_back(x);
    c.push_back(0);
  }
  if (n<=k+1) {
    cout << abs(h[1]-h[n]) << endl;
    return 0;
  }
  if (k == 1) {
    x = 0;
    for (i = 2; i<=n; i++) {
      x+=abs(h[i]-h[i-1]);
    }
    cout << x << endl;
    return 0;
  }
  for (i = 2; i<=k+1; i++) {
    c[i] = abs(h[1]-h[i]);
  }
  for (i = k+2; i<=n; i++) {
    c[i] = abs(h[i]-h[i-1])+c[i-1];
    for (j = 2; j<=k && (i-j)>0; j++) {
      c[i] = min(c[i],abs(h[i]-h[i-j])+c[i-j]);
    }
  }
  cout << c[n] << endl;
  return 0;
}


Measured memory_bytes: 1276
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans[100001] = {};
    int tmp;
    
	int n;
	cin >> n;
	
	ans[0] = 0;
	REP1(i, 100000) ans[i] = 999999;
	REP1(i, 100000){
		ans[i] = min(ans[i-1] + 1, ans[i]);
		for(int j = 0; i - pow(6, j) >= 0; j++) ans[i] = min(ans[i-(int)pow(6,j)] + 1, ans[i]);
		for(int j = 0; i - pow(9, j) >= 0; j++) ans[i] = min(ans[i-(int)pow(9,j)] + 1, ans[i]); 
	}

    cout << ans[n] << endl;
}

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

using namespace std;

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 1);
  vector<bool> b(n);
  b[0] = true;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    a[x]--;
    if (b[x]) {
      b[y] = true;
    }
    if (!a[x]) {
      b[x] = false;
    }
    a[y]++;
  }
  int ans = 0;
  for (const auto &q : b) {
    if (q)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}

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

int main() {
  int a,b; cin >>a >>b;
  if ((a+b)%2) cout <<(a+b)/2+1 <<endl;
  else cout <<(a+b)/2 <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;


int main() {
	int N,W;
	cin >> N >> W;
	vector<long long>dp(100001, mod*100000LL);//価値ごとのテーブル。
	vector<pair <long long,long long>> wv(N);//weightがsecond,valueがfirst
	for (size_t i = 0; i < N; i++)
	{
		cin >> wv.at(i).second >> wv.at(i).first;
		
	}
	sort(wv.begin(), wv.end());
	dp.at(0) = 0;
	for (size_t i = 0; i < N; i++)
	{

		for (long long j = 100000; j >= wv.at(i).first;  j--)
		{
			dp.at(j) = min(dp.at(j - wv.at(i).first) + wv.at(i).second, dp.at(j));
		}
	}

	for (int i = 100000; i >= 0; i--)
	{
		if (dp.at(i) <= W) {
			cout << i; return 0;
		}
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++){
		cout<<i<<" ";
	}
	cout<<endl;
	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007;

typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

// Print fn to print array

int main(){
	long long n;
	cin >> n;
	long long res = 0;
	for(long long i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0) res+=i;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> grid(H, vector<char>(W, '0'));
  char c;
  for (int h = 0; h != H; ++h) {
    for (int w = 0; w != W; ++w) {
      cin >> c;
      if (c == '#') {
        grid[h][w] -= 10;
        for (int i = max(0, h - 1), m = min(H, h + 2); i != m; ++i) {
          for (int j = max(0, w - 1), n = min(W, w + 2); j != n; ++j) {
            ++grid[i][j];
          }
        }
      }
    }
  }

  for (auto &r : grid) {
    for (auto c : r) {
      cout << (c >= '0' ? c : '#');
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	vi in(5);
	rep(i,5)cin>>in[i];
	sort(all(in),[](int a,int b){
		return (a-1)%10>(b-1)%10;
	});
	rep(i,4)if(in[i]%10)in[i]=in[i]-in[i]%10+10;
	int s=0;
	rep(i,5)s+=in[i];
	cout<<s<<endl;
}







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

int main() {
    int n;
    cin >> n;
    set<string> st;
    string temp;
    cin >> temp;
    st.insert(temp);
    bool ok = true;
    rep(i,n-1){
        string s;
        cin >> s;
        st.insert(s);
        if(s.front() != temp.back()) ok = false;
        temp = s;
    }

    if(st.size()!=n || !ok) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
/*input
2 3 3
2 2
1 1
1 3
*/

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

// antbook p155
const int INF = 1001001001;
struct SegmentTree {
    int n; // size/2
    vector<int> dat; // a segment tree
    // n: num of elements
    SegmentTree(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        // set all elements at INF
        dat.resize(2*n-1, INF);
    }
    // update k-th element by a
    void update(int k, int a) {
        k += n-1;
        dat[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // returns min[a, b)
    // k-th node is [l, r)
    // use like query(a, b)
    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if  (r < 0) r = n;
        // INF if intersection of [a, b) and [l, r) is empty
        if (r <= a || b <= l) return INF;
        // val of this node if [a, b) includes [l, r)
        if (a <= l && r <= b) return dat[k];
        // min of 2 children
        int vl = query(a, b, k*2+1, l, (l+r)/2);
        int vr = query(a, b, k*2+2, (l+r)/2, r);
        return min(vl, vr);
    } 
};

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> ch(h), cw(w);
    vector<int> bom[h];
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        ch[x]++; cw[y]++;
        bom[x].push_back(y);
    }

    int ans = 0;
    SegmentTree st(w);
    rep(i, w) st.update(i, -cw[i]);
    rep(i, h) {
        for (auto y: bom[i]) st.update(y, -cw[y]+1);
        ans = max(ans, ch[i]-st.query(0, w));
        for (auto y: bom[i]) st.update(y, -cw[y]);
    }
    cout << ans << endl;
}

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

#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define clr(x) memset((x), 0, sizeof((x)));
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
typedef unsigned long long ull;

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

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

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

typedef ll ptdata;

struct pt {
    ptdata x, y;

    pt() {}

    pt(ptdata x, ptdata y) : x(x), y(y) {}

    inline pt operator-(const pt &r) const {
        return pt(x - r.x, y - r.y);
    }

    inline pt operator+(const pt &r) const {
        return pt(x + r.x, y + r.y);
    }

    inline pt operator*(const ld &r) const {
        return pt(x * r, y * r);
    }

    inline ptdata sqlen() const {
        return abs(x * x + y * y);
    }

    inline bool operator<(const pt &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }

    inline bool operator==(const pt &r) const {
        return x == r.x && y == r.y;
    }
};

ostream &operator<<(ostream &os, const pt &p) {
    return os << "(" << p.x << "," << p.y << ")";
}

inline ptdata cross(const pt &l, const pt &r) {
    return l.x * r.y - l.y * r.x;
}

inline ptdata dot(const pt &l, const pt &r) {
    return l.x * r.x + l.y * r.y;
}


ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

template<typename T>
inline T sqr(T x) {
    return x * x;
}



void solve() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = (int)s.length();
    forn(i, n) {
        int cnt = ('z' - s[i] + 1) % 26;
        if (cnt <= k) {
            s[i] = 'a';
            k -= cnt;
        }
    }
    s.back() = char((s.back() - 'a' + k) % 26 + 'a');
    cout << s << "\n";
}

void prepare() {

}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    prepare();

    int t = 1;
    //t = nxt();
    forn(i, t) {
        solve();
    }

    //cerr << "Time " << clock() / (double) CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int n;
    cin>>n;
    double sumj=0,sumb=0;
    rep(i,n){
        double x;
        cin>>x;
        string s;
        cin>>s;
        if(s[0]=='J')sumj+=x;
        else sumb+=x;
    }
    double ans=sumb*380000;
    ans+=sumj;
    cout<<fixed<<setprecision(6)<<ans<<endl;
}

Measured memory_bytes: 3704
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
using namespace std;
int main(){


    int n;
    cin>>n;
    double T,A;
    cin>>T>>A;
    double mi=100000;
    int ans=0;
    
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        double hh=T-h*0.006;
       double u=fabs(hh-A);
        if(mi>u){
            ans=i+1;
            mi=u;
        }
    }
    cout<<ans<<endl;
    




return 0;
}

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

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int A = fs.nextInt(), B = fs.nextInt();
    System.out.println(lcm(A, B));
  }

  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

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

Measured memory_bytes: 21332
#include<iostream>
#include<cstdlib>
using namespace std;
int ask(int x)
{
	char s[100];
	cout<<x<<endl;
	cin>>s;
	if(s[0]=='V')exit(0);
	return s[0]=='M';
}
int n;
int main()
{
	cin>>n;
	int l=1,r=n-1,f=ask(0);
	while(l<=r)
	{
		int m=(l+r)>>1;
		if(((m^f^ask(m))&1))r=m-1;
		else l=m+1;
	}
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;


void solve(long long r){
    cout << 3*r*r << endl;
}

int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------
var n, vmax int
var w int64
var items []item
var dp [][]int64

type item struct {
	w int64
	v int
}

func main() {
	n = readInt()
	w = readInt64()
	vmax = n * 1e3
	items = make([]item, n)
	for i := range items {
		items[i] = item{
			w: readInt64(),
			v: readInt(),
		}
	}
	dp = make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, vmax+1)
		for j := range dp[i] {
			dp[i][j] = math.MaxInt64
		}
	}
	dp[0][0] = 0

	for i := 1; i <= n; i++ {
		for j := 0; j <= vmax; j++ {
			dp[i][j] = math.MaxInt64
			if j-items[i-1].v >= 0 && dp[i-1][j-items[i-1].v] != math.MaxInt64 {
				dp[i][j] = minInt64(dp[i-1][j], dp[i-1][j-items[i-1].v]+items[i-1].w)
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}

	var ans int
	for i := range dp[0] {
		if dp[n][i] <= w {
			ans = i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 82432
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main() {

    int N, D;

    cin >> N >> D;

    vector<vector<int> > X(N, vector<int>(D));

    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            cin >> X.at(i).at(j);
        }
    }

    int cnt = 0;

    for (int i = 0; i < N; i++){
        for (int j = i + 1; j < N; j++){
            int S = 0;
            for (int k = 0; k < D; k++){
                S += pow(X.at(i).at(k) - X.at(j).at(k), 2);
            }
            for (int k = 0; k <= S; k++) {
                if(k * k == S) {
                    cnt++;
                    break;
                }
            }
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int t[540][540];
int d[1000005];

int h,w,x;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>h>>w;

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin>>x;
            t[i][j]+=x;
        }
    }
    x=0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(j==w && i==h){
                break;
            }
            if(t[i][j]%2!=0){
                if(j==w){
                    t[i+1][j]++;
                    d[x]=i; d[x+1]=j; d[x+2]=i+1; d[x+3]=j;
                    x+=4;
                }
                else{
                    t[i][j+1]++;
                    d[x]=i; d[x+1]=j; d[x+2]=i; d[x+3]=j+1;
                    x+=4;
                }
            }
        }
    }
    cout<<x/4<<endl;

    for(int i=0; i<x; i+=4){
        for(int j=0; j<4; j++){
            if(j==3){
                cout<<d[i+j]<<endl;
            }
            else
                cout<<d[i+j]<<' ';
        }
    }
    return 0;
}

Measured memory_bytes: 7040