akhauriyash/Code-Regression huggingface dataset:
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  // var fline = inputs.split('\n')[0];
  var flines = inputs.split('\n')[0].split(' ').map(Number);
  var a = flines[0];
  var b = flines[1];
  var area = a * b;
  var periphery = 2 * (a + b);
  console.log(area,periphery);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> e(n, vector<int>(n, INF));
  rep(i, n) e[i][i] = 0;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    e[a - 1][b - 1] = c;
    e[b - 1][a - 1] = c;
  }

  vector<vector<int>> d(n, vector<int>(n));
  rep(i, n) {
    rep(j, n) {
      d[i][j] = e[i][j];
    }
  }
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 0;
  rep(i, n) {
    FOR(j, i + 1, n) {
      if (d[i][j] != e[i][j] && e[i][j] != INF) ans++;
    }
  }
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n),ord(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
    ord[a[i]]=i;
  }
  set<int>st;
  st.insert(-1);
  st.insert(n);
  ll ans=0;
  rep(i,n){
    st.insert(ord[i]);
    set<int>::iterator x=st.lower_bound(ord[i]);
    set<int>::iterator y,z;
    y=x;y--;
    z=x;z++;
    int left=*x-*y;
    int right=*z-*x;
    ans+=left*right*(i+1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12800
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::set<int> graph[10000];
std::multiset<std::pair<int,int>> edge_num;
int C[10000];
bool used[10000];
int resTree[10000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int i = 0; i < N-1; i++)
	{
		int a, b;
		in >> a >> b; --a; --b;
		graph[a].insert(b);
		graph[b].insert(a);
	}
	for (int i = 0; i < N; i++)
	{
		in >> C[i];
	}
	std::sort(C, C + N);
	for (int i = 0; i < N; i++)
	{
		edge_num.emplace(graph[i].size(), i);
	}

	int count = 0;
	int score = 0;
	{
		
		for (int i = 0;  i < N; i++)
		{
			auto top = edge_num.begin()->second;
			auto cou = edge_num.begin()->first;
			edge_num.erase(edge_num.begin());
			count += cou;
			score += cou * C[i];
			used[top] = true;
			resTree[top] = C[i];

			for (auto& n : graph[top]) {
				if (!used[n]) {
					edge_num.erase({ graph[n].size(), n });
					graph[n].erase(top);
					edge_num.emplace(graph[n].size(), n);
				}
			}
		}
	}
	assert(count == N - 1);
	out << score << endl;
	out << resTree[0];
	for (size_t i = 1; i < N; i++)
	{
		out << ' ' << resTree[i];
	}
	out << endl;

	return 0;
}
#endif


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  string S;
  cin >> S;

  long long int cnt = 0;

  for(int i=0; i<S.length()-1; i++){
    if(S[i] != S[i+1]){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	vi p(n);
	rep(i,n) cin >> p[i];

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(p[i] != i+1) cnt++;
	}

	if(cnt <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;		
}

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

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0)
    cout << (K / 2) * (K / 2) << endl;
  else
    cout << (K / 2) * (K / 2 + 1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int maxn = 1e4;
struct point{
	int x,y;
}u,v;
queue<int>que;
map<string,int>mp;
map<string,int>::iterator it;
#define m(a,b) memset(a,b,sizeof(a));
LL ans = 0;
int main(){
	int n,m;
	string str;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> str;
		mp[str]++;
	}
	cin >> m;
	while(m--){
		cin >> str;
		mp[str]--;
	}
	int ans = 0;
	for(it = mp.begin();it!=mp.end();it++){
		if(ans < it->second) 
			ans = it->second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c, k = map(int, input().split())
ans = -10 * 10 ** 10

if a > 0:
    if k > a:
        ans = a
        k -= a
    else:
        print(k)
        exit()

if b > 0:
    ans = max(ans, 0)
    if k > b:
        k -= b
    else:
        print(ans)
        exit()

if c > 0:
    ans = max(ans - k, -k)

print(ans)



Measured memory_bytes: 9196
n = STDIN.gets.to_i
input = STDIN.gets.split(" ")
numbers = input.map(&:to_i)
numbers = numbers.reverse
for i in 0 .. numbers.length - 1 do
  if numbers.length - 1 == i
    print numbers[i].to_s + "\n"
  else
    print numbers[i].to_s + " "
  end
end

Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  string s;
  cin>>s;
  cout << s.substr(0,4) <<" " << s.substr(4,8) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] height = new int[10];
		for(int i = 0; i<10;i++){
			height[i] = in.nextInt();
		}
		Arrays.sort(height);
		System.out.println(height[9]);
		System.out.println(height[8]);
		System.out.println(height[7]);
		in.close();
	}
}

Measured memory_bytes: 17168
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100


struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_cost,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		cost = arg_cost;
		rev_index = arg_rev_index;
	}

	int to,capacity,cost,rev_index;
};

int V;
vector<Edge> G[NUM];
int dist[NUM];
int pre_node[NUM],pre_edge[NUM];


void add_edge(int from,int to,int capacity,int cost){
	G[from].push_back(Edge(to,capacity,cost,G[to].size()));
	G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int source,int sink,int flow){
	int ret = 0;
	while(flow > 0){

		for(int i = 0; i < V; i++)dist[i] = BIG_NUM;
		dist[source] = 0;
		bool update = true;
		while(update){
			update = false;
			for(int node_id = 0; node_id < V; node_id++){
				if(dist[node_id] == BIG_NUM)continue;
				for(int i = 0; i < G[node_id].size(); i++){
					Edge &e = G[node_id][i];
					if(e.capacity > 0 && dist[e.to] > dist[node_id]+e.cost){
						dist[e.to] = dist[node_id]+e.cost;
						pre_node[e.to] = node_id;
						pre_edge[e.to] = i;
						update = true;
					}
				}
			}
		}

		if(dist[sink] == BIG_NUM){
			return -1;
		}

		int tmp_flow = flow;
		for(int node_id = sink; node_id != source; node_id = pre_node[node_id]){
			tmp_flow = min(tmp_flow,G[pre_node[node_id]][pre_edge[node_id]].capacity);
		}
		flow -= tmp_flow;
		ret += tmp_flow*dist[sink];
		for(int node_id = sink; node_id != source; node_id = pre_node[node_id]){
			Edge &e = G[pre_node[node_id]][pre_edge[node_id]];
			e.capacity -= tmp_flow;
			G[node_id][e.rev_index].capacity += tmp_flow;
		}
	}
	return ret;
}

int main(){

	int E,F;
	scanf("%d %d %d",&V,&E,&F);

	int from,to,capacity,cost;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d %d %d",&from,&to,&capacity,&cost);
		add_edge(from,to,capacity,cost);
	}

	printf("%d\n", min_cost_flow(0,V-1,F));

	return 0;
}




Measured memory_bytes: 3264
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  ll a[x], b[y], c[z];
  REP(p,x) cin >> a[p];
  REP(q,y) cin >> b[q];
  REP(r,z) cin >> c[r];
  vector<ll> sum_ab;
  REP(p,x) REP(q,y) sum_ab.push_back(a[p]+b[q]);
  sort(sum_ab.begin(),sum_ab.end(),greater<ll>());
  vector<ll> sum_ab_cut;
  REP(i,min(k,(ll)sum_ab.size())) sum_ab_cut.push_back(sum_ab[i]);
  vector<ll> sum_total;
  REP(p,sum_ab_cut.size()) REP(r,z) sum_total.push_back(sum_ab_cut[p]+c[r]);
  sort(sum_total.begin(),sum_total.end(),greater<ll>());
  REP(i,k) cout << sum_total[i] << endl;
  return 0;
}


Measured memory_bytes: 43396
import sys
input=sys.stdin.readline
mod=10**9+7
h,w=map(int,input().split())
wall='#'*(w+2)
MAP=[wall]
for _ in range(h):
    MAP.append('#'+input().strip()+'#')
MAP.append(wall)
DP=[[0]*(w+2) for _ in range(h+2)]
DP[1][1]=1
for i in range(1,h+1):
    for j in range(1,w+1):
        if MAP[i][j]=='.':
            DP[i][j]+=DP[i-1][j]+DP[i][j-1]
            DP[i][j]%=mod
print(DP[h][w])

Measured memory_bytes: 51184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;
template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;


signed main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    cin >> A;
    vector<modint> dp(S + 1, 0);
    modint ans = 0;
    for (int i = 0; i < N; i++) {
        dp[0] += 1;
        vector<modint> temp(S + 1, 0);
        for (int j = 0; j <= S; j++) {
            temp[j] += dp[j];
            if (j + A[i] <= S) temp[j + A[i]] += dp[j];
        }
        dp = temp;
        ans += dp[S];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef long long Int;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef list<int> lii;
typedef list<ll> lil;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
#define MOD 1000000007
int main(){
	int n,m;cin>>n>>m;
	vector<bool> b(n+1);
	rep(i,m){
		int a;
		cin>>a;
		b[a]=true;
	}
	vector<int>dp(n+2);
	dp[n]=1;
	for(int i = n-1;i>=0;i--){
		if(b[i]){
			dp[i]=0;
			continue;
		}
		dp[i]=(dp[i+1]+dp[i+2])%MOD;
	}
	cout<<dp[0]<<endl;
}








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

#define mo 1000000007

int n;
int e[33][33];
int f[21][1<<21];

int add(int a, int b) { return (a+=b)>=mo ? a-mo : a; }

int dfs(int got, int mask) {
	if (got>=n) return 1;
	
	int &t = f[got][mask];
	if (t>=0) return t;
	
	t = 0;
	for(int i=0;i<n;i++) {
		if (!e[got][i] || (mask & (1<<i))) continue;
		t = add(t, dfs(got+1, mask + (1<<i)));
	}
	return t;
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++) scanf("%d", &e[i][j]);

	memset(f, -1, sizeof f);
	printf("%d\n", dfs(0, 0));
	
	return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

int pws[] = {10, 100, 1000, 10 * 1000, 100 * 1000, 1000 * 1000,
             10 * 1000 * 1000, 100 * 1000 * 1000};

int len(int x) {
    int i = 0;
    while (x >= pws[i]) {
        i++;
    }
    
    return i + 1;
}

ll expo(ll a, ll n, ll mod) {
    ll ans = 1;

    while (n) {
        if (n & 1LL) ans = (ans * a) % mod;

        n >>= 1;
        a = (a * a) % mod;
    }

    return ans;
}

int withDigits(int k) {
    return (expo(10, k, MOD) + MOD - expo(10, k-1, MOD)) % MOD;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int s;
    cin >> s;
    
    int l = 1;
    int sum = 0, ans = 0;
    
    for (int r = 1; ; r++) {
        int rLen = len(r);
        if (rLen > s) {
            break;
        }
    
        sum += rLen;
        while (sum > s) {
            sum -= len(l++);
        }
        
        if (l >= 10 * 1000 * 1000) {
            break;
        }
        
        if (sum == s) {
            ans++;
        }
    }
    
    FOR(k,8,s) {
        int ub = (s - k) / (k + 1);
        int rem = s % k;
        
        if (rem == 0) {
            int window = s / k;
            int whole = withDigits(k);
            
            ans = (ans + whole - window + 1) % MOD;
        }
        
        if (ub < rem) continue;
        if (ub < k && rem == 0) continue;
        
        ans += (ub - rem) / k + 1 - (rem == 0);
        
        if (ans >= MOD) {
            ans -= MOD;
        }
    }
    
    cout << ans;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
   ll a,b;cin >> a>> b;
   vl v{1,2,3};
   rep(i,3){
       if(v[i]!=a&&v[i]!=b){
           cout << v[i] <<endl;
       }
   }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int x,y,id;
	friend bool operator <(node a,node b)
	{
		if (a.x<b.x) return true;
		if (a.x>b.x) return false;
		return a.y<b.y;
	}
}dt[1000100];
int n,u,v;
int sum[1000100],vis[1000100],ad[1000100];
vector <int> des[1000100];
void work(int dx,int dy)
{
	sort(dt+1,dt+n+1);
	for (int i=0;i<=n;i++) ad[i]=0;
	for (int i=1;i<=n;i++)
	{
		int l=lower_bound(dt+1,dt+n+1,(node){dt[i].x-dx,dt[i].y-dy,-1})-dt;
		int r=upper_bound(dt+1,dt+n+1,(node){dt[i].x-dx,dt[i].y+dy,-1})-dt;
		sum[dt[i].id]+=r-l;
		if ((l<=n)&&(l>=1)&&(l<r)) {des[dt[i].id].push_back(dt[l].id);des[dt[l].id].push_back(dt[i].id);ad[l]++;ad[r-1]--;}
	
	}
	for(int i=1;i<n;i++)
	{
		ad[i]+=ad[i-1];
		if(ad[i]==0)continue;
		des[dt[i].id].push_back(dt[i+1].id);des[dt[i+1].id].push_back(dt[i].id);
	}
}
void dfs(int s)
{//cerr<<s<<endl;
	vis[s]=true;
	for (int k=0;k<des[s].size();k++) if (!vis[des[s][k]]) dfs(des[s][k]);
}
int main()
{
	scanf("%d%d%d",&n,&u,&v);
	for (int i=1;i<=n;i++)
	{
		int xx,yy;scanf("%d%d",&xx,&yy);
		dt[i]=(node){xx+yy,xx-yy,i};
	}
	int d=max(abs(dt[u].x-dt[v].x),abs(dt[u].y-dt[v].y));
	work(d,d);
	for (int i=1;i<=n;i++) swap(dt[i].x,dt[i].y);
	work(d,d-1);
	dfs(u);if (!vis[v]) assert(0);
	long long ans=0;
	for (int i=1;i<=n;i++) if (vis[i]) ans+=sum[i];
	printf("%lld\n",ans);
}

Measured memory_bytes: 39936
import sys
sys.setrecursionlimit(10 ** 7)
ans = []
def solve(x, n, s):
    if len(s) == n:
        ans.append(s)
        return
    for i in range(x+2):
        solve(max(x, i), n, s + chr(ord("a") + i))

def main():
    n = int(input())
    solve(0, n, "a")
    ans.sort()
    for s in ans:
        print(s)

if __name__ == "__main__":
    main()

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

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

    int A[n];
    int i,j,tmp;

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

    int flag = 1;
    int counter = 0;

    while(flag){
        flag=0;
        for(j=n-1; j>0; j--){
            if(A[j]<A[j-1]){
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                counter++;
            }
        }
    }

    for(i=0; i<n-1; i++){
        cout << A[i] <<' ';
    }
    cout << A[n-1] << endl;
    cout << counter << endl;

}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,a[N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	if (a[n]-a[1]>=2) printf("No\n");
	if (a[n]-a[1]==1){
		int t=upper_bound(a+1,a+n+1,a[1])-a-1;
		printf((a[n]>=t+1&&a[n]<=t+(n-t)/2)?"Yes\n":"No\n");
	}
	if (a[n]-a[1]==0)
		printf((a[n]<=n/2||a[n]==n-1)?"Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long



signed main(){
    int N,M;
    int ans=1;
    cin >> N >>M;
    vector<bool>ok(N+1,true);
    REP(i,M){
        int a;
        cin >>a;
        ok[a] = false;
    }
    vector<int>dp(N+1);
    dp[0]=1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(N,now+2);next++){
            if(ok[next]){
                dp[next]+=dp[now];
                dp[next] %=1000000007;
            }
        }
    }
    cout <<dp[N] <<endl;   
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int H, W, A, B; cin >> H >> W >> A >> B;
    // 行:0が A, 1がW-A個 or 0が W-A, 1がA個 列: 0がB, 1がH-B個 or 0がH-B, 1がB個
    int ans[H][W];
    rep(i, H){
        rep(j, W){
            if(i % 2 == 0){
                if(j < A) ans[i][j] = 0;
                else ans[i][j] = 1;
            }
            else{
                if(j < A) ans[i][j] = 1;
                else ans[i][j] = 0;
            }
        }
    }
    int need_to_change;
    if(H % 2 == 0) need_to_change = H/2 - B;
    else need_to_change = H/2 - B + 1;
    rep(i, H){
        if(i % 2 == 0 && need_to_change > 0){
            need_to_change--;
            rep(j, W){
                if(ans[i][j] == 1) cout << 0;
                else cout << 1;
            }
        }
        else{
            rep(j, W) cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,n;cin >>a  >>b  >> n;
    ll d=min(n,b-1);
    
    cout << a*d/b;
    }

Measured memory_bytes: 3656
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i , j in enumerate(a):
    b[i]=j+i+1
c=[0]*n
q=[]
ans=0
for i , j in enumerate(a):
    c[i]=1+i-j
from collections import Counter
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
cc=Counter(c)
bb=Counter(b)
f=bb&cc
for i in f.keys():
    ans+=bb[i]*cc[i]

print(ans)

Measured memory_bytes: 127200
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mi d + 1, r
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
struct EE{int v, nx;}E[M * 2 + N * 2]; int hd[N], EN;
void init_edge(int num){EN = 0; memset(hd, -1, (num + 2) << 2);}
void add_edge(int u, int v){
    E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
    E[EN].v = u; E[EN].nx = hd[v]; hd[v] = EN++;
}
vector<int> G[N];
int go(int u){
    int s = 0;
    for(int i = 0; i < G[u].size(); ++i){
        int v = G[u][i];
        s ^= (go(v) + 1);
    }
    return s;
}
int dis[N];
int p[N][2], n, u, v;
int main(){
    //IN;
    SC(n);
    init_edge(n + 3);
    FF(i, 1, n - 1){
        SCC(u, v);
        add_edge(u, v);
     //   add_edge(v, u);
        p[i][0] = u;
        p[i][1] = v;
    }
    queue<int>q;
    q.push(1);
    dis[1] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int k = hd[u]; ~k; k = E[k].nx){
            int v = E[k].v;
            if(dis[v] == 0){
                dis[v] = dis[u] + 1;
                q.push(v);
            }
        }
    }
    FF(i, 1, n - 1){
        if(dis[p[i][0]] > dis[p[i][1]]) G[p[i][1]].push_back(p[i][0]);
        else  G[p[i][0]].push_back(p[i][1]);
    }
    int s = go(1);
    puts(s ? "Alice" : "Bob");
}


Measured memory_bytes: 17408
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str, T: str):
    print(''.join([T,S]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


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

public class Main {
   public static void main(String[] args) throws Exception {
      try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

         String[] tmp = br.readLine().split(" ");
         int n = Integer.parseInt(tmp[0]);
         int m = Integer.parseInt(tmp[1]);

         List<List<Integer>> g = new ArrayList<>(n);
         for (int i = 0; i < n; i++) {
            g.add(new ArrayList<>());
         }

         for (int i = 0; i < m; i++) {
            tmp = br.readLine().split(" ");
            int a = Integer.parseInt(tmp[0]) - 1;
            int b = Integer.parseInt(tmp[1]) - 1;
            g.get(a).add(b);
            g.get(b).add(a);
         }

         int[] ans = new int[n];

         Queue<Integer> q = new ArrayDeque<>();
         q.offer(0);
         while (!q.isEmpty()) {
            int p = q.poll();
            for (int v : g.get(p)) {
               if (ans[v] == 0) {
                  ans[v] = p + 1;
                  q.add(v);
               }
            }
         }

         PrintWriter pw = new PrintWriter(System.out);
         pw.println("Yes");
         for (int i = 1; i < n; i++) {
            pw.println(ans[i]);
         }
         pw.flush();

      }
   }
}

Measured memory_bytes: 72796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    string a;
    cin >> a;
    bool d = false;
    for (int i = 0; i < 3; i++) {
        if (a.at(i) == '7')d = true;
    }
    if (d)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
// Practice AtCoder
// author:Leonardone @ NEETSDKASU

// 解説PDF読後

fn main() {
  let mut stdin = String::new();
  std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin). unwrap ();
  let mut stdin = stdin.split_whitespace();
  let mut get = || stdin.next(). unwrap ();
  macro_rules! get {
    ($t:ty) => (get().parse::<$t>(). unwrap ());
    () => (get!(i64));
  }
  let a = get!();
  let b = get!();

  let fa = factors(a);
  let fb = factors(b);
  let mut ans = 0;
  for f in fb {
      if fa.binary_search(&f).is_ok() { ans+=1;}
  }
  println!("{}", ans);
}

fn factors(v: i64) -> Vec<i64> {
  let mut ret = vec![1];
  let mut v = v;
  for i in 2.. {
     if i*i > v { break; }
     if v % i == 0 {
       ret.push(i);
       while  v % i == 0 { v /= i; }
     }
  }
  if v > 1 { ret.push(v); }
  ret
}

Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	int L = *min_element(A.begin(), A.end()) - 1, R = *max_element(A.begin(), A.end()) + 1;
	while (R - L > 1) {
		int M = (L + R) >> 1;
		vector<int> bit(2 * N + 2);
		int cur = N; long long sum = 0;
		for (int i = N + 1; i <= 2 * N + 1; i += i & (-i)) ++bit[i];
		for (int i = 0; i < N; ++i) {
			if (A[i] <= M) ++cur;
			else --cur;
			for (int j = cur; j >= 1; j -= j & (-j)) sum += bit[j];
			for (int j = cur + 1; j <= 2 * N + 1; j += j & (-j)) ++bit[j];
		}
		if (sum * 2 > 1LL * N * (N + 1) / 2) R = M;
		else L = M;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 1420
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int x; cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] list = new long[n];
		int count = n;
		int a = 0;
		if(n % 2 == 1) {
			a = 1;
		}

		for(int i = 0; i < n; i++) {
			list[i] = sc.nextLong();
		}

		for(int i = n - 1 ; i >= 0; i-=2) {
			System.out.print(list[i]);
			count--;
			if(count <= 0) {
				System.out.println();
			} else {
				System.out.print(" ");
			}
		}
		if(n > 1) {
			for(int i = a; i < n; i+=2) {
				System.out.print(list[i]);
				count--;
				if(count <= 0) {
					System.out.println();
				} else {
					System.out.print(" ");
				}
			}
		}

	}
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> F(N,vector<int>(10));
  vector<vector<int>> P(N,vector<int>(11));
  vector<int> ka(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin>>F.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin>>P.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    ka.at(i)=0;
  }
  int ma=-1000000010;
  for(int i=0;i<1023;i++){
    int a=i;
    int sum=0;
    for(int j=0;j<10;j++){
      if(a%2==0){
        for(int k=0;k<N;k++){
          if(F.at(k).at(j)==1){
            ka.at(k)++;
          }
        }
      }
      a=a/2;
    }
    for(int j=0;j<N;j++){
      sum+=P.at(j).at(ka.at(j));
      ka.at(j)=0;
    }
    ma=max(sum,ma);
  }
  cout<<ma<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
	string s;
	cin>>s;
	if(s.back()=='s') s+="es";
	else s.pb('s');
	cout<<s<<endl;
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3644
#encoding:utf-8 No.0077 2014.10.8
while gets
  str = $_.chomp.split("")

  str.length.times do |i|
    if str[i] == "@"
      str[i,3] = str[i+2]*str[i+1].to_i
    end
    print str[i]
  end
  print "\n"
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N, Y;
  cin >> N >> Y;

  rep(i, N+1) {
    rep(j, N+1-i) {
      if(10000*i+5000*j+1000*(N-i-j) == Y) {
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if (s==u) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, n, data[6];
  double length;

  for(i=0; i<6; i++)
    data[i] = 0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%lf", &length);

    if(length < 165) data[0]++;
    else if(length < 170) data[1]++;
    else if(length < 175) data[2]++;
    else if(length < 180) data[3]++;
    else if(length < 185) data[4]++;
    else data[5]++;
  }

  for(i=0; i<6; i++){
    printf("%d:", i+1);
    for(j=0; j<data[i]; j++)
      printf("*");
    printf("\n");
  }

  return 0;
}

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

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

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

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

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

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

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

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

const BIG_STACK_SIZE: bool = true;

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

fn solve() {
    let (a, b) =get!(usize, usize);
    let mx =max!(a,b);
    let mn = min!(a,b);
    if mx == mn {
        println!("{}",mx+mn);
    } else  {
        println!("{}", 2*mx-1);
    }
}


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

const int MAX_D = 365;
const int C_SIZE = 26;

typedef vector< vector<int> > State;

int decreaseSatisfaction(const vector<int>&vec_c, vector<vector<int> >&last,  int d) {
  int res = 0;
  for(int i = 0 ; i < C_SIZE ; i++){
    res += vec_c[i] * (d - last[d][i]);
  }
  return res;
}

void input(int& D, vector<int>&vec_c, vector<vector<int> >& vec_s){
  cin >> D;
  for(int i = 0 ; i <  C_SIZE ; i++){
    int c; cin >> c; vec_c.push_back(c);
  }
  for(int i = 0 ; i < D ; i++){
    vector<int>vec;
    for(int j = 0 ; j < C_SIZE ; j++){
      int s; cin >> s;
      vec.push_back(s);
    }
    vec_s.push_back(vec);
  }
}

void init(const int D, vector<int>& vec_last, State& state){
  for(int i = 0 ; i < C_SIZE ; i++){
    vec_last.push_back(0);
  }
  for(int i = 0 ; i < D ; i++){
    vector<int>vec;
    for(int j = 0 ; j < C_SIZE ; j++){
      if(i%C_SIZE == j){
        vec.push_back(1);
      }
      else {
        vec.push_back(0);
      }
    }
    state.push_back(vec);
  }
}

void output(const State& res){
  for(int i = 0 ; i < res.size() ; i++){
    for(int j = 0 ; j < res[i].size() ; j++){
      if(res[i][j]) {
        cout << (j+1) << endl;
      }
    }
  }
}

State solve(const int D, const vector<int>& vec_c, const vector<vector<int> >vec_s){
  vector<vector<int> > res;
  vector<int> vec_last;
  State state;
  init(D, vec_last, state);
  return state;
}

int main(){
  int D;
  vector<int>vec_c;
  vector<vector<int> >vec_s;
  input(D, vec_c, vec_s);
  output(solve(D, vec_c, vec_s));
  return 0;
}


Measured memory_bytes: 3792
from itertools import product
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(n)]
print(max([sum(sorted([i[0]*l[0]+i[1]*l[1]+i[2]*l[2] for l in xyz],reverse=True)[:m]) for i in product([-1,1],[-1,1],[-1,1])]))

Measured memory_bytes: 3396
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct edge { 
	int to, cost, money;
};
vector<edge> G[100];
int d[100][101];
void init() {
	rep(i, 100) {
	    G[i].clear();
	}
	rep(i, 100) {
		rep(j, 101) {
			d[i][j] = (int)mod;
		}
	}
	d[0][0] = 0;
}
struct point {
	int v, m, d; 
	bool operator>(const point &s) const {
		return d > s.d;
	}
};
int main() {
	int n, m, l;
	while (cin >> n >> m >> l, n) {
		init();
		rep(i, m) {
			int a, b, d, e; cin >> a >> b >> d >> e; a--; b--;
			G[a].push_back(edge{ b,e,d });
			G[b].push_back(edge{ a,e,d });
		}
		priority_queue<point,vector<point>,greater<point>> q;
		q.push({ 0,0,0 });
		while (!q.empty()) {
			point x = q.top(); q.pop();
			if (x.d > d[x.v][x.m])continue;
			int len = G[x.v].size();
			rep(j, len) {
				int v = G[x.v][j].to;
				int c = G[x.v][j].cost;
				int mon = G[x.v][j].money;
				if (d[v][x.m] > x.d + c) {
					d[v][x.m] = x.d + c;
					q.push({ v,x.m,x.d+c });
				}
				if (mon + x.m > l)continue;
				if (d[v][x.m + mon] > x.d) {
					d[v][x.m + mon] = x.d;
					q.push({ v,x.m + mon,d[v][x.m + mon] });
				}
			}
		}
		int out = (int)mod;
		rep(j, l + 1) {
			out = min(out, d[n - 1][j]);
		}
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 3464
def main():
    a, b, c , k = list(map(int, input().split(" ")))

    sum = 0
    rem_num = k

    if(a >= k):
        sum = sum + k
        print(sum)
        return
    
    if(k > a and k <= a + b):
        sum = sum + a
        print(sum)
        return
    
    if(k > a + b ):
        sum = sum + a - 1*(k - a - b)
        print(sum)
        return


if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M, X) = Read3Longs();
            var A = ReadLongs();

            return Math.Min(A.Count(x => x < X), A.Count(x => x > X));
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28332
def check(m, mid, A):
    tmp = abs(A[mid] - m)
    if mid > 0:
        tmp = min(tmp, abs(A[mid - 1] - m))
    if len(A) - 1 > mid:
        tmp = min(tmp, abs(A[mid + 1] - m))
    return tmp != abs(A[mid] - m)

def nbt(m, A):
    left = 0
    right = len(A)
    mid = (left + right) // 2
    while check(m, mid, A):
        if A[mid] > m:
            right = mid
        elif m > A[mid]:
            left = mid
        mid = (left + right) // 2
    return A[mid]

        
n = int(input())
A = list(map(int, input().split()))
A.sort()
print(A[-1], nbt(A[-1] / 2, A[:-1]))

Measured memory_bytes: 14052
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
#define Maxn 100010
int A[Maxn];
ll B[Maxn];
int main(){
	scanf("%d",&n);
	ll sum=0;
	for(register int i=1;i<=n;++i){
		scanf("%d",&A[i]);A[i]*=2;
		sum=A[i]-sum;
	}
	B[1]=sum/2;
	for(register int i=2;i<=n;++i)B[i]=A[i-1]-B[i-1];
	for(register int i=1;i<=n;++i)printf("%lld ",B[i]);
	return 0;
}

Measured memory_bytes: 2432