akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

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

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<int, int>> xy(N);
    rep(i, N) { cin >> xy[i].first >> xy[i].second; }

    vector<int> vec(N);
    rep(i, N) { vec[i] = i; }

    double res = 0.;
    double counter=0.;
    do {
        rep(i, N - 1) {
            double l = sqrt(pow(abs(xy[vec[i]].first - xy[vec[i + 1]].first), 2) +
                 pow(abs(xy[vec[i]].second - xy[vec[i+1]].second), 2));
            res+=l;
        }
        counter++;
    } while (next_permutation(vec.begin(), vec.end()));
    cout <<  setprecision(20) << res/counter << endl;

    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    deque<int> b;
    int flag = 0;
    rep(i,n)
    {
        if(flag == 0)
        {
            b.push_back(a[i]);
        }else
        {
            b.push_front(a[i]);
        }
        flag = (flag+1)%2;
    }
    if(flag == 1)
    {
        reverse(b.begin(), b.end());
    }
    for (auto &i : b)
    {
        cout << i << " ";
    }
    cout << endl;
    
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int N;
    io >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++)
        io >> x[i] >> y[i];
    
    vector<int> s(N), t(N);
    for (int i = 0; i < N; i++)
    {
        s[i] = x[i] + y[i];
        t[i] = x[i] - y[i];
    }
    
    auto [min_it, max_it] = minmax_element(begin(s), end(s));
    int ans1 = *max_it - *min_it;
    
    auto [min_it2, max_it2] = minmax_element(begin(t), end(t));
    int ans2 = *max_it2 - *min_it2;

    int ans = max(ans1, ans2);
    io << ans << BR;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  char c[N][M];
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < M; j++) {
      c[i][j] = s[j];
    }
  }
  int a[N][3]{};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (c[i][j] == 'W') a[i][0]++;
      else if (c[i][j] == 'B') a[i][1]++;
      else a[i][2]++;
    }
  }
  int b[N + 1][3]{};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      b[i + 1][j] += b[i][j] + a[i][j];
    }
  }
  int ans = 10000000;
  for (int i = 1; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int v = M * i - b[i][0] + M * (j - i)- (b[j][1] - b[i][1])
            + M * (N - j) - (b[N][2] - b[j][2]);
      ans = min(ans, v);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3212
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int W, a, b;
  cin >> W >> a >> b;
  if (a < b) {
    cout << max(0, b - a - W) << endl;
  } else {
    cout << max(0, a - b - W) << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

int main() {
    ll N;
    cin >> N;
    vll A(N);
    vll B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    vll a(N);
    vll b(N);
    ll ans = 0;
    for (int i = 0; i < 30; ++i) {
        ll T2 = 1ll << (i + 1);
        ll T = 1ll << i;
        for (int j = 0; j < N; ++j) {
            a[j] = A[j] % T2;
            b[j] = B[j] % T2;
        }
        sort(b.begin(), b.end());
        ll cnt = 0;
        for (ll& x : a) {
            ll k1 = lower_bound(b.begin(), b.end(), T - x) - b.begin();
            ll k2 = lower_bound(b.begin(), b.end(), 2 * T - x) - b.begin();
            ll k3 = lower_bound(b.begin(), b.end(), 3 * T - x) - b.begin();
            cnt += k2 - k1 + N - k3;
        }
        if (cnt & 1) {
            ans += T;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8576
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        H: usize,
        W: usize,
        board: [chars; H],
    }
    for h in 1..H - 1 {
        for w in 1..W - 1 {
            if board[h][w] == '.' {
                continue;
            }
            if board[h - 1][w] == '.'
                && board[h][w - 1] == '.'
                && board[h + 1][w] == '.'
                && board[h][w + 1] == '.'
            {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
struct query{
	int a,b,c,d;
};
int ans=0;
int n,m,q;
query qry[55];
vector<int>v;
int getsum(){
	int cur=0;
	for(int i=0;i<q;i++){
		int a=qry[i].a;
		int b=qry[i].b;
		int c=qry[i].c;
		int d=qry[i].d;
		if(v[b]==v[a]+c)cur+=d;
	}
	return cur;
}
void rec(int i,int pre){
	if(i==n){
		ans=max(ans,getsum());
		return;
	}
	for(int j=pre;j<=m;j++){
		v.pb(j);
		rec(i+1,j);
		v.pop_back();
	}
}
void solve(){
	cin>>n>>m>>q;
	v.pb(0);
	rep(i,q){
		cin>>qry[i].a>>qry[i].b>>qry[i].c>>qry[i].d;
	}
	rec(0,1);
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch EnergyDrinkCollector | diff EnergyDrinkCollector.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address EnergyDrinkCollector.cpp && ./a.out

/*
 
 3/16/2019
 
 11:20-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N];
int N,M;

void solve() {
  vector<pair<LL,LL>> X;
  REP(i,N) X.emplace_back(A[i],B[i]);
  sort(ALL(X));
  
  LL res=0;
  int cur=0;
  REP(i,N) {
    LL x=min((LL)M-cur,X[i].second);
    res+=X[i].first*x;
    cur+=x;
    if(cur==M) break;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) cin>>A[i]>>B[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 7284
#include <stdio.h>
int main(void){
  int a[3];
  int i,sum;
  sum=0;
  for(i=0;i<=2;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  
  if(sum<=21)
    puts("win");
  else
    puts("bust");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;

    cin >> n;

    if(n % 2 == 0) {
        cout << n << endl;
    }
    else {
        cout << n*2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int sum=0,k;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0'+i%2) sum++;
	}
	k=s.size()-sum;
	sum>k?sum=k:sum=sum;
	cout<<sum;
	return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;


void solve(std::vector<long long> T, std::vector<long long> A, std::vector<long long> B){
    if(T[0] * A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]){
        cout << "infinity" << endl;
        return;
    }
    if(T[0] * A[0] + T[1] * A[1] <= T[0] * B[0] || T[0] * A[0] >= T[0] * B[0] + T[1] * B[1]){
        cout << 0 << endl;
        return;
    }
    if(A[0] < B[0]){
        if(T[0] * A[0] + T[1] * A[1] < T[0] * B[0] + T[1] * B[1]){
            cout << 0 << endl;
            return;
        }else if(T[0] * A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]){
            cout << 1 << endl;
            return;
        }
    }
    if(A[0] > B[0]){
        if(T[0] * A[0] + T[1] * A[1] > T[0] * B[0] + T[1] * B[1]){
            cout << 0 << endl;
            return;
        }else if(T[0] * A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]){
            cout << 1 << endl;
            return;
        }
    }
    i64 d1 = T[0] * (A[0] - B[0]);
    i64 d2 = T[1] * (A[1] - B[1]);
    if((d1 > 0 && d2 > 0) || (d1 < 0 && d2 < 0)){
        cout << 0 << endl;
        return;
    }
    d1 = abs(d1); d2 = abs(d2);
    if(d1 > d2) swap(d1, d2);
    i64 n = d1 / (d2 - d1);
    if(d1 == n * (d2 - d1)) cout << 2 * n << endl;
    else cout << 2 * n + 1 << endl;
}

int main(){
    std::vector<long long> T(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&T[i]);
    }
    std::vector<long long> A(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(std::move(T), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigInteger x = new BigInteger(sc.next()).abs();
    BigInteger k = new BigInteger(sc.next());
    BigInteger d = new BigInteger(sc.next());

    BigInteger[] bigIntegers = x.divideAndRemainder(d);
    BigInteger q = bigIntegers[0];
    BigInteger r = bigIntegers[1];
    if (q.compareTo(k) >= 0) {
      System.out.println(x.subtract(d.multiply(k)));
      return;
    }

    BigInteger remain = q.subtract(k);
    System.out.println(remain.remainder(BigInteger.valueOf(2)).compareTo(BigInteger.ZERO) == 0 ? r : d.subtract(r));
  }
}


Measured memory_bytes: 27172
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] input = sc.nextLine().split(" ");
		String[] num = new String[n];
		for(int i=0;i<input.length;i++){
			num[i]=input[n-i-1];
		}
		for(int i=0;i<n-1;i++){
			System.out.print(num[i]+" ");
		}
		System.out.println(num[n-1]);
	}
}

Measured memory_bytes: 26040
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,d; cin >> n >> d;
    ll ans = 0;
    rep(i, 0, n) {
        ll x,y; cin >> x >> y;
        if(d * d >= x * x + y * y) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3644
N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

from collections import defaultdict
d = defaultdict(lambda: 0)		#初期値を「-1」にする

for n in range(N):
  k, v = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
  d[k] += v

cnt=0
for k, v in sorted(d.items(), key=lambda x: x[0]):
  cnt += v
  if cnt >= K:
    print(k)
    exit(0)


Measured memory_bytes: 15336
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

double pdot(pair<double,double> a,pair<double,double> b){
	return a.first*b.first + a.second*b.second;
}

int main(){
	double a1,a2,b1,b2,c1,c2,p1,p2;
	while(cin>>a1>>a2>>b1>>b2>>c1>>c2>>p1>>p2){
	pair<double,double> v0 = make_pair(c1-a1,c2-a2);
	pair<double,double> v1 = make_pair(b1-a1,b2-a2);
       	pair<double,double> v2 = make_pair(p1-a1,p2-a2);
	double dot00 = pdot(v0,v0), dot01 = pdot(v0,v1), dot02 = pdot(v0,v2), dot11 = pdot(v1,v1);
	double dot12 = pdot(v1,v2);
	double id = 1.0 / (dot00 * dot11 - dot01 * dot01);
	double u = (dot11 * dot02 - dot01 * dot12) * id;
	double v = (dot00 * dot12 - dot01 * dot02) * id;
	//cout<<u<<":"<<v<<endl;
	if(u>=0 && v>=0 && u+v<1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;


const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b=10){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

struct unionFind{
  vector<int> par,sz;
  unionFind(int n):par(n),sz(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      sz[i]=1;
    }
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
    sz[ry]+=sz[rx];
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x){
    return sz[root(x)];
  }
};

int main(){
  int i,j,k,cnt=0;
  int n,m;
  cin>>n>>m;
  int a[m],b[m],c[m];
  for(i=0;i<m;i++){
    cin>>a[i]>>b[i];
    c[i]=0;
    for(j=0;j<b[i];j++){
      int x;
      cin>>x;
      c[i]+=pow1(2,x-1);
    }
  }
  int p=pow1(2,n);
  int d[p];
  for(i=0;i<p;i++){
    d[i]=MOD;
  }
  d[0]=0;
  for(i=0;i<m;i++){
    for(j=0;j<p;j++){
      d[j|c[i]]=min(d[j|c[i]],d[j]+a[i]);
    }
  }
  if(d[p-1]>=MOD)cout<<-1<<endl;
  else cout<<d[p-1]<<endl;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
//mleしなければぜんぶllでかく。

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int a[4];
      rep0(i,4) a[i]=0;
      rep0(i,6){
            int b;
            cin>>b;
            b--;
            a[b]++;
      }
      rep0(i,4){
            if(a[i]==3){
                  cout<<"NO"<<endl;
                  return 0;
            }
      }
      cout<<"YES"<<endl;
      return 0;
}

Measured memory_bytes: 256
import bisect

n, m = map(int, input().split())
f_1 = []
t_n = []
jedge = 0
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        f_1.append(b)
    if b == n:
        t_n.append(a)
f_1.sort()
t_n.sort()
for i in range(len(f_1)):
    p = bisect.bisect_left(t_n, f_1[i])
    if p < len(t_n)-1 and f_1[i] == t_n[p]:
        jedge = 1
        break
    elif p == len(t_n)-1 and f_1[i] == t_n[p]:
        jedge = 1
        break
if jedge == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 11464
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static List<ulong> Divisor(ulong input)
        {
            List<ulong> result = new List<ulong>();

            for (ulong i = 1; i * i <= input; i++)
            {
                if (0 == input % i)
                {
                    result.Add(i);
                    if (i * i != input)
                    {
                        result.Add(input / i);
                    }
                }
            }

            return result;
        }
        static void Main(string[] args)
        {
            ulong A = ulong.Parse(Console.ReadLine());

            List<ulong> d = Divisor(A);

            ulong ans = ulong.MaxValue;

            for (int i = 0; i < d.Count; i++)
            {
                ulong d0 = d[i];
                ans = (d0 + A / d0) - 2;
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int h, w;
int vcnt[2020][2020];
int hcnt[2020][2020];

int main() {
  cin >> h >> w;
  vector<vector<char>> v(h+2,vector<char>(w+2,'#'));
  rep(i,h)rep(j,w) cin >> v[i+1][j+1];
  rep(i,h) {
    int cnt = 0;
    rep(j,w+1) {
      if(v[i+1][j+1]=='.') cnt++;
      else if(v[i+1][j]=='.') {
        for(int k = j-cnt+1; k<=j; k++) hcnt[i+1][k] = cnt;
        cnt = 0;
      }
    }
  }
  rep(i,w) {
    int cnt = 0;
    rep(j,h+1) {
      if(v[j+1][i+1]=='.') cnt++;
      else if(v[j][i+1]=='.') {
        for(int k = j-cnt+1; k<=j; k++) vcnt[k][i+1] = cnt;
        cnt = 0;
      }
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w) {
    int tmp = hcnt[i+1][j+1] + vcnt[i+1][j+1] - 1;
    ans = max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

ll N, K;
vector<ll> A(500);

bool check(ll x) {
  vector<ll> L(N, 0);
  vector<ll> R(N, 0);
  vector<ll> sumL(N + 1, 0);
  vector<ll> sumR(N + 1, 0);
  
  for (int i = 0; i < N; i++) {
    L[i] = A[i] % x;
    R[i] = x - L[i];
  }
  sort(L.begin(), L.end());
  sort(R.rbegin(), R.rend());

  sumL[0] = 0;
  for (int i = 1; i <= N; i++) {
    if (L[i - 1] > 0) {
      sumL[i] = sumL[i - 1] + L[i - 1];
    } else {
      sumL[i] = sumL[i - 1];
    }
  }
  // cout << BR << x << BR;
  // SHOW(sumL);
  sumR[N] = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (L[i] > 0) {
      sumR[i] = sumR[i + 1] + R[i];
    } else {
      sumR[i] = sumR[i + 1];
    }
  }
  // SHOW(sumR);

  for (int i = 0; i <= N; i++) {
    if (max(sumL[i], sumR[i]) <= K) {
      return true;
    }
  }
  return false;
}

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

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  ll ans = 1;
  for (ll i = 1; i <= sqrt(sum); i++) {
    if (sum < i) break;

    ll t;
    if (sum % i == 0) {
      t = i;
      if (check(t)) ans = max(ans, t);

      t = sum / i;
      if (check(t)) ans = max(ans, t);
    }
  }

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

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    cout << (n*a>b?b:n*a) << endl;
}

Measured memory_bytes: 256
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.*;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        ArrayList<String> arr = new ArrayList<String>(n);
        HashMap<String,Integer> hm = new HashMap<String,Integer>(n);
        int max = 1;
        for(int i = 0; i<n; i++){
            String s = in.next();
            if(hm.get(s)==null){
                hm.put(s,1);
            }
            else{
                int val = hm.get(s);
                int temp = ++val;
                hm.put(s,temp);
                max = Math.max(max,temp);
            }
        }
        for(Map.Entry<String,Integer> entry : hm.entrySet()){
            if(entry.getValue()==max){
                arr.add(entry.getKey());
            }
        }
        Collections.sort(arr);
        for(String s : arr){
            out.println(s);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 65716
#include <iostream>
#include <vector>
#include <assert.h>
#include <math.h>
using namespace std;

uint64_t mutual_mod(uint64_t A, uint64_t B){
    assert(A >= B);
    uint64_t gcd;
    uint64_t modulo = 0;
    while(1){
        modulo = A % B;
        if(modulo == 0){
            gcd = B;
            break;
        }
        else{
            A = B;
            B = modulo;
        }
    }
    return gcd;
}

void prime_decompose3(vector<int>& cds, uint64_t gcd){
    cds.push_back(1);
    for(uint64_t i = 2; i*i <= gcd; i++){
        if(gcd % i == 0){
            cds.push_back(i);
        }
        while(gcd % i == 0){
            gcd /= i;
        }
    }
  	if(gcd > 1){
      cds.push_back(gcd);
    }
    return;
}

int main(){
    uint64_t A,B;
    cin >> A >> B;
    uint64_t gcd = 0;
    if(A > B){
        gcd = mutual_mod(A,B);
    }
    else{
        gcd = mutual_mod(B,A);
    }    
    vector<int> cd_vec;
    prime_decompose3(cd_vec,  gcd);

    cout << cd_vec.size();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int i,j,k,m,d;
 
   scanf("%d %d",&m,&d);
   k=0;
   for (i=4;i<=m;i++) 
      for (j=22;j<=d;j++)
         if (j/2>=2 && j%10>=2 && (j/10)*(j%10)==i) k++;
   printf("%d",k);
   return 0;
}


Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

class UnionFind {
public:
    vi par;    // x の親ノード
    vi rank;   // 木の高さ
    vi mem;    // メンバの数
    int sz;             // 集合の個数

    UnionFind(int n) :
        par(n, -1), rank(n, 0), mem(n, 1), sz(n) {
        REP(i,n) par[i] = i;
    }

    int size() { return sz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        sz++;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]){
            par[x] = y;
            mem[x] += mem[y];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            mem[y] += mem[x];
        }
        sz--;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int n,k,l,p,q;

int main(){
    I(n); I(k); I(l);
    UnionFind road = UnionFind(n);
    UnionFind rail = UnionFind(n);

    REP(i,k){
        I(p); I(q);
        p--; q--;
        road.unite(p,q);
    }
    REP(i,l){
        I(p); I(q);
        p--; q--;
        rail.unite(p,q);
    }
    map<pi,int> ret;
    vpi pars(n);
    REP(i,n){
        pars[i] = mp(road.find(i),rail.find(i)) ;
        ret[ pars[i] ]++;
    }
    REP(i,n){
        printf("%d ",ret[ pars[i] ]);
    }
    cout << endl;
}


Measured memory_bytes: 18048
#include<stdio.h>

int main(){
    int p,q,r;
    int max=0;
    scanf("%d %d %d",&p,&q,&r);
    max = p;
    if(max < q){
        max = q;
    }
    if(max < r){
        max = r;
    }
    printf("%d\n",p+q+r-max);
    return 0;
}

Measured memory_bytes: 128
package main

import (
  "fmt"
  _ "math"
)

func main() {
  var s, t string
  fmt.Scanf("%s\n%s\n", &s, &t)
  fmt.Println(string(solve([]byte(s), []byte(t))))
}

func solve(s, t []byte) []byte {
  // dp[i][j] 表示 s[:i]与t[:j]的maxLen LCS
  dp := make([][]int, len(s)+1)
  for i:=range dp {
    dp[i] = make([]int, len(t)+1)
  }
  // 
  for i:=1;i<=len(s);i++ {
    for j:=1;j<=len(t);j++ {
      if s[i-1] == t[j-1] {
        dp[i][j] = dp[i-1][j-1]+1
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1])
      }
    }
  }
  // 打印路径
  bs := make([]byte, dp[len(s)][len(t)])
  for i,j:=len(s),len(t);dp[i][j]>0; {
    if s[i-1]==t[j-1] {
      bs[dp[i][j]-1] = s[i-1]
      i--
      j--
    } else {
      if dp[i][j] == dp[i-1][j] {
        i--
      } else {
        j--
      }
    }
  }
  return bs
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}
// xxxx i
// yyyyy j


Measured memory_bytes: 75264
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
	int n, a, b;
	cin>>n>>a>>b;
	vi x(n);
	REP(i,0,n)cin>>x[i];
	int cur=x[0];
	int cost=0;
	for(int i=0;i<n;i++){
		// deb(i);
		// deb(cur);
		// deb(x[i]);
		int dis=x[i]-cur;
		if(dis*a>b){
			cost+=b;
			cur=cur+dis;
		}
		else{
			cost=cost+dis*a;
			cur+=dis;

		}
		// deb(cost);
	}
	cout<<cost<<"\n";



	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[2][111];

void MAIN() {
    scanf("%d", &N);
    REP (t, 2) REP (i, N) scanf("%d", A[t]+i);

    A[1][0] += A[0][0];
    for (int i=1; i<N; i++) {
	A[0][i] += A[0][i-1];
	A[1][i] += max(A[1][i-1], A[0][i]);
    }
    printf("%d\n", A[1][N-1]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int no, ne, i;
    string O, E;

    cin >> O;
    cin >> E;

    no = O.size();
    ne = E.size();

    if(no == ne){
        for(i=0; i<no; i++){
            cout << O[i] << E[i];
        }
        
        cout << endl;
    }

    else{
        for(i=0; i<ne; i++){
            cout << O[i] << E[i];
        }
        cout << O[no-1] << endl;
    }

    return 0;
}

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

int main(){
    char s;
    cin >> s;
    // scanf("%c", &s);
    s=s+1;
    printf("%c",s);
    // cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("hitachi2020/hitachi2020_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string h;
  cin >> h;

  if (h.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < h.size() - 1; i += 2) {
    if (h[i] != 'h' || h[i + 1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    for (int i = A; i <= B; i++) {
      if (check(i)) ans++;
    }
    System.out.println(ans);
  }
  
  private static boolean check(int num) {
    String s = String.valueOf(num);
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
        return false;
      }
    }
    return true;
  }
}

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

int main() {
  int n; cin >> n;
  int v[55], c[55];
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n; i++) cin >> c[i];
  int sum = 0;
  for(int i = 0; i < n; i++) {
    if(v[i] - c[i] >= 0) sum += (v[i] - c[i]);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  string s, t;
  scanf("%d", &n);
  cin >> s >> t;
  REP(i, n){
    cout << s.at(i) << t.at(i);
  }
  printf("\n");
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  string s;
  cin >> s;
  int diff = INT_MAX;
  for(int i = 0; i + 2< s.length(); i++){
    int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
    diff = min(diff, abs(x - 753));
  }
  cout << diff << endl;



  return 0;
}


Measured memory_bytes: 256