akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<vector<int>> solve(int H, int W, int h, int w)
{
    if (H % h == 0 && W % w == 0) return {};
    auto ans = vector<vector<int>>(H, vector<int>(W));
    if (W % w) {
        int a = 1e6;
        int X = -1e6*(w-1)-1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                ans[i][j] = j % w == w - 1 ? X : a;
            }
        }
    } else {
        int a = 1e6;
        int X = -1e6*(h-1)-1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                ans[i][j] = i % h == h - 1 ? X : a;
            }
        }
    }
    return ans;
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int H, W, h, w; cin >> H >> W >> h >> w;
    vector<vector<int>> ans = solve(H, W, h, w);
    if (ans.empty()) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << ans[i][j] << " \n"[j == W-1];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int mul = -1;
    if ( 1 <= A && A <= 9 ){
        if ( 1 <= B && B <= 9 ){
            mul = A*B;
        }
    }
    
    cout << mul << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
bool check(string s){
    bool other = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') continue;
        else other = true;
    }
    return (other == false);
}
int main(){
    Hello
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
        for(int j = i + 1; j <= s.size(); j++)
            if(check(s.substr(i, j - i))) ans = max(ans, j - i);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		double x=0;
		double y=0;
		double r=0;
		double w=90;
		double t;
		String s;
		String[] sp=new String[2];

		while(true){
		s=scan.nextLine();
		sp=s.split(",");
		r=Double.valueOf(sp[0]);
		t=Double.valueOf(sp[1]);
		x+=r*Math.cos(w/180*Math.PI);
		y+=r*Math.sin(w/180*Math.PI);
		w-=t;
		if(r==0&&t==0){
			break;
		}
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    bool can = true;
    for (int i = 0; i < N - 1; i++)
    {
        
        if (H[i] - H[i + 1] > 1)
        {
            cerr << i << endl;
            cout << "No" << endl;
            return 0;
        }

        if (H[i] - H[i + 1] == 1)
        {
            if (can)
            {
                can = false;
                continue;
            }
            
            for (int j = i - 1; j > 0; j--)
            {
                if (H[j] - H[i + 1] == 2)
                {
                    cout << "No" << endl;
                    return 0;
                }
                
            }
            
        }
        
        
    }
    
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[200000], b[200000];
int d[4005][2005];
int f[20005], rf[20005];
const int MOD = 1e9 + 7;

int binPow(LL x, int p) {
    LL res = 1;
    while (p) {
        if (p & 1) res = res * x % MOD;
        p >>= 1;
        if (p) x = x * x % MOD;
    }
    return (int)res;
}

int c(int n, int k) {
    if (k > n) return 0;
    return (LL)f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

inline void modAdd(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

int main() {
    f[0] = rf[0] = 1;
    for (int i = 1; i < 20005; ++i) {
        f[i] = (LL)f[i - 1] * i % MOD;
        rf[i] = binPow(f[i], MOD - 2);
    }
    scanf("%d", &n);
    REP(i, n) {
        scanf("%d%d", a + i, b + i);
        ++d[a[i] + b[i]][a[i]];
    }
    for (int i = 4000; i > 0; --i) for (int j = 2000; j > 0; --j) {
        modAdd(d[i - 1][j - 1], d[i][j]);
        modAdd(d[i - 1][j], d[i][j]);
        d[i][j] = 0;
    }
    int ans = 0;
    REP(i, 4001) if (d[i][0]) {
        ans = (ans + (LL)d[i][0] * d[i][0]) % MOD;
        REP(j, i) if (d[j][0]) {
            ans = (ans + 2ll * d[i][0] * d[j][0]) % MOD;
        }
        REP(j, 2001) if (j && d[0][j]) {
            ans = (ans + 2ll * d[i][0] * d[0][j] % MOD * c(i, j)) % MOD;
        }
    }
    REP(i, n) ans = (ans - c(2 * (a[i] + b[i]), 2 * b[i])) % MOD;
    if (ans < 0) ans += MOD;
    ans = (LL)ans * (MOD / 2 + 1) % MOD;
    printf("%d\n", ans);
    return 0;
}


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

// Order statistics tree (if supported by judge!):
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// template<class TK, class TM> using order_tree = tree<TK, TM, less<TK>, rb_tree_tag, tree_order_statistics_node_update>;
// iterator	find_by_order(int r) (zero based)
// int		order_of_key(TK v)
// template<class TV> using order_set = order_tree<TV, null_type>;

#define x first
#define y second
#define rs resize
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<ii> vii;
template<class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;

template<class T1, class T2>
ostream& operator<<(ostream &out, const pair<T1,T2> &a) { return out << '(' << a.x << ", " << a.y << ')'; }
template<class T1, class T2>
istream& operator>>(istream &in, pair<T1,T2> &a) { return in >> a.x >> a.y; }

template<class T> int sz(const vector<T> &v) { return (int) v.size(); }

template<class T> ostream& operator<<(ostream &os, vector<T> v) {
	os << "\n[";
	for(T &x : v) os << x << ',';
	return os << "]\n";
}

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

void run() {
	int a, b, m;
	cin >> a >> b >> m;
	vi pa(a), pb(b);
	for (int &x : pa) cin >> x;
	for (int &x : pb) cin >> x;
	int ret = INT_MAX;
	for (int i=0; i<m; i++) {
		int x,y,c;
		cin >> x >> y >> c;
		int opt = pa[x-1] + pb[y-1] - c;
		ret = min(ret, opt);
	}
	ret = min(ret, *min_element(all(pa)) + *min_element(all(pb)));
	cout << ret << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

vector < pair <ll, ll> > v(L);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, K;
    cin >> N >> K;

    for(ll i=0; i<N; i++)
    {
        cin >> v[i].ff >> v[i].ss;
    }

    sort(v.begin(), v.begin()+N);

    ll cur = 0;
    ll j = 0;

    while(cur < K)
    {
        cur+=v[j].ss;

        if(cur>=K)
        {
            cout << v[j].ff << endl;
            return 0;
        }

        j++;
    }

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<list>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<limits>
#include<cctype>
#include<unordered_map>
#include<complex>
#pragma warning(disable:4996)
using namespace std;

#define debug(i) cout<<"<debug> "<<#i<<" "<<i<<" <\\debug>"<<endl
#define mfor(i,a,b) for(int i=(a);i<=(b);i++)
#define mrep(i,a,b) for(int i=(a);i>=(b);i--)
#define lll __int128
#define Re register
#define mem(a,b) memset(a,(b),sizeof(a))
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
typedef pair<int, int> intpair;
typedef pair<long long int, long long int> llpair;
typedef long long int ll;
const double pi = acos(-1);
const double eps = 1e-5;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;

const int maxn = 2000010;

int main()
{
	Design;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({ b * d,a * d,b * c,a * c });
}

Measured memory_bytes: 3596
n, K = map(int, input().split())
r, s, p = map(int, input().split())
T = input()

win = {"r": p, "s": r, "p": s}

ans = 0
for x in range(K):
    Tx = list(T[x::K])

    tmp = 0
    for i in range(len(Tx)):
        if i == 0:
            tmp += win[Tx[i]]
            continue
        if Tx[i] != Tx[i - 1]:
            tmp += win[Tx[i]]
        else:
            Tx[i] = "?"

    ans += tmp

print(ans)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

signed main() {
	IOS;	
	int N,ans;
	ans=0;
	cin>>N;
	rep(i,N){
		int j=i+1;
		if(j%3==0 || j%5==0){
			continue;
		}
		else{
			ans+=j;
		}
		
	}
	cout<<ans<<endl;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

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

    bool ans = true;
    int n;
    cin >> n;
    unordered_set<int> s;
    rep(i, 0, n) {
        int x;
        cin >> x;
        if (s.find(x) != s.end())
            ans = false;
        else
            s.insert(x);
    }
    cout << (ans ? "YES\n" : "NO\n");
    

    return 0;
}

Measured memory_bytes: 8520
#include <stdio.h>

int main(void){
	int N;
	int H;
	int highest=-1;
	int count=0;

	scanf("%d",&N);
	for(int i=0; i<N; i++){
		scanf("%d",&H);
		if(highest<=H){
			count++;
			highest = H;
		}
	}

	printf("%d\n",count );
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

struct UnionFind {
  vector<int> par; // 親の番号

  // n要素で初期化する
  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; ++i) par[i] = i;
  }

  // 木の根を求める
  int root(int x) {
    if(par[x] == x) {
      return x; // 根
    } else {
      return par[x] = root(par[x]); // 経路圧縮(根っこを再帰で探る)    
    }
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return; // xとyの根が同じ場合はすでに併合している
    par[rx] = ry;
  }

  bool same(int x, int y) { // x と y が同じ集合に属するか否か
    return root(x) == root(y);
  }
};

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M); REP(i, M) cin >> a[i] >> b[i];
  ll ans = 0;
  REP(i, M) {
    UnionFind uf(N);
    REP(k, M) {
      if(i == k) continue;
      uf.unite(a[k] - 1, b[k] - 1);
    }
    if(!uf.same(a[i] - 1, b[i] - 1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import fractions
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: #前提条件
        ans = "No"
    elif D < B: #前提条件
        ans = "No"
    elif B - C <= 1: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []



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

using namespace std;

#define MAX_N 100000

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

using Pi = pair<int, int>;

int N;
vector<edge> graph[MAX_N];

Pi dfs(int u, int p) {
  Pi res = Pi(0, u);
  for(edge& e : graph[u]) {
    if(e.to == p) continue;
    Pi tmp = dfs(e.to, u);
    tmp.first += e.cost;
    res = max(res, tmp);
  }
  return res;
}
Pi diameter() {
  Pi p = dfs(0, -1);
  Pi q = dfs(p.second, -1);
  return Pi(p.second, q.second);
}

int bi[MAX_N], ei[MAX_N];
int idx;
void euler(int u, int p) {
  bi[u] = idx++;
  for(edge& e : graph[u]) {
    if(e.to == p) continue;
    euler(e.to, u);
  }
  ei[u] = idx;
}

struct SegmentTree {
  vector<int> data;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz *= 2;
    data.resize(2*sz-1, 0);
  }
  void set(int k, int x) {
    k += sz-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = max(data[2*k+1], data[2*k+2]);
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return data[k];
    int vl = query(a, b, 2*k+1, l, (l+r)/2);
    int vr = query(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

int cost[MAX_N];
void dfs2(int u, int p, int d) {
  cost[u] = d;
  for(edge& e : graph[u]) {
    if(e.to == p) continue;
    dfs2(e.to, u, d+e.cost);
  }
}

int solve(int root) {
  idx = 0;
  dfs2(root, -1, 0);
  euler(root, -1);
  SegmentTree seg(N);
  for(int i = 0; i < N; i++) {
    seg.set(bi[i], cost[i]);
  }
  int res = 0;
  for(int i = 0; i < N; i++) {
    for(edge& e : graph[i]) {
      int u = (cost[i] < cost[e.to] ? e.to : i);
      //cout << bi[u] << " " << ei[u] << endl;
      int c = max(seg.query(0, bi[u]), seg.query(ei[u], N));
      res = max(res, c+e.cost);
      //cout << root << " "<<i << " " << u << " " << c << " " << c+e.cost << endl;
    }
  }
  return res;
}

int main() {
  cin >> N;
  for(int i = 0; i < N-1; i++) {
    int p, w;
    cin >> p >> w;
    graph[p].emplace_back(i+1, w);
    graph[i+1].emplace_back(p, w);
  }
  Pi p = diameter();
  int ans1 = solve(p.first);
  int ans2 = solve(p.second);
  //cout << p.first << " "<<p.second << endl;
  //cout << ans1 << " " << ans2 << endl;
  cout << max(ans1, ans2) << endl;
  return 0;
}

Measured memory_bytes: 18572
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
--
local N = read.n()
local A = read.N(N)
local m = 1000
local s = 0
local function buy(a)
    s = s + m // a
    m = m % a
end
local function sell(a)
    m = m + s * a
    s = 0
end
for i=1,N-1 do
    if A[i+1] < A[i] then
        sell(A[i])
    elseif A[i+1] > A[i] then
        buy(A[i])
    end
end
sell(A[N])
print(m)

Measured memory_bytes: 2776
#include<iostream>

using namespace std;

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

    int X[d][n];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> X[j][i];
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int sum = 0;

            for(int k = 0; k < d; k++){
                int diff = abs(X[k][i] - X[k][j]);
                sum += diff * diff;
            }

            for(int k = 0; k <= sum; k++){
                if(k * k == sum){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            if(ret != null) Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var s = long.Parse(input.ReadLine());

        //test(12);
        //return 0;

        if(s < 3) return 0;

        long size = s / 3;

        long y = 0;

        for(int i=1; i<=size; i++) {
            long amari = s - i * 3;
            long x = 1;
            x = ModCombination(amari + i - 1, i-1);

            //Debug.WriteLine($"{i}:{x}");

            y += x;
            y %= Mod;
        }

        return y;
    }

    static void test(long s) {
        int c = 0;
        for(int i1=0; i1<s; i1++) {
            for (int i2 = 0; i2 < s; i2++) {
                for (int i3 = 0; i3 < s; i3++) {
                    if(i1+i2+i3 == s && i1 >= 3 && i2 >= 3 && i3 >= 3) {
                        Debug.WriteLine($"{i1}:{i2}:{i3}");
                        c++;
                    }
                }
            }
        }

        Debug.WriteLine($"count={c}");
    }

    static long ModSub(long x1, long x2) {
        long v = x1 - x2;
        if(v < 0) v += Mod;
        return v % Mod;
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % Mod;
            }
            x1 = (x1 * x1) % Mod;
            x2 /= 2;
        }
        return ans % Mod;
    }

    static long ModDiv(long x1, long x2) {
        long bb = ModPow(x2, Mod - 2);
        return (x1 * bb) % Mod;
    }

    static long ModCombination(long m, long n) {
        var a = 1L;
        var b = 1L;
        for (long i = 1; i <= n; i++) {
            a = (a * (m - i + 1)) % Mod;
            b = (b * i) % Mod;
        }

        return ModDiv(a, b) % Mod;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27420
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int N = Integer.parseInt(lines[0]);
		int K = Integer.parseInt(lines[1]);

		line = sc.nextLine();
		String[] chars = line.split("");
		for(int i = 0; i < chars.length; i++) {
			if(i == K-1) {
				chars[i] = chars[i].toLowerCase();
			}
			System.out.print(chars[i]);
		}
		System.out.println();
	}

}


Measured memory_bytes: 35604
N,M = map(int,input().split())

if N%2==1:
    for i in range(1,M+1):
        print(i,2*M+1-i)
else:
    used = {N//2}
    j = 1
    for i in range(M,0,-1):
        while j in used:
            j += 1
        print(i,i+j)
        used.add(j)
        used.add(N-j)
        j += 2

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

public class Main {
	
	static PrintWriter out;
	
	final static int INF = (int) 1e9;
	final static int MOD = (int) 1e9 + 7;
	final static long LINF = (long) 1e18;
	final static double PI = (double) Math.acos(-1.0);
	final static double EPS = (double) 1e-9;
	
	void solve() {
		int n = Input.nextInt();
		final int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Input.nextInt() - 1;
		}
		int[] res = new int[n * n];
		for (int i = 0; i < n; i++) {
			res[x[i]] = i + 1;
		}
		ArrayList<Integer> v = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			v.add(i);
		}
		Collections.sort(v, new Comparator<Integer>() {
			public int compare(Integer i, Integer j) {
				return Integer.compare(x[i], x[j]);
			}
		});
		for (int j = 0; j < n; j++) {
			int i = v.get(j);
			int cnt = i;
			for (int k = 0; k < x[i] && cnt > 0; k++) {
				if (res[k] == 0) {
					res[k] = i + 1;
					cnt--;
				}
			}
			if (cnt > 0) {
				out.println("No");
				return;
			}
		}
		Collections.sort(v, new Comparator<Integer>() {
			public int compare(Integer i, Integer j) {
				return Integer.compare(x[j], x[i]);
			}
		});
		for (int j = 0; j < n; j++) {
			int i = v.get(j);
			int cnt = n - i - 1;
			for (int k = n * n - 1; k > x[i] && cnt > 0; k--) {
				if (res[k] == 0) {
					res[k] = i + 1;
					cnt--;
				}
			}
			if (cnt > 0) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
		for (int i = 0; i < n * n; i++) {
			out.printf("%d%c", res[i], " \n".charAt(i == n * n - 1 ? 1 : 0));
		}
	}
	
	public static void main(String[] args) {
		try {
			out = new PrintWriter(System.out);
			//out = new PrintWriter(new FileWriter("a.out"));
		}
		catch (Exception ex) {
		}
		long stime = System.currentTimeMillis();
		Main practice = new Main();
		practice.solve();
		if (System.getProperty("_LOCAL_") != null) {
			out.println("\nTime elapsed: " + (System.currentTimeMillis() - stime) + "ms");
		}
		out.close();
	}
	
	static class Input {
		static StringTokenizer token = null;
		static BufferedReader in;
		static {
			try {
				if (System.getProperty("_LOCAL_") != null) {
					//in = new BufferedReader(new FileReader("in.txt"));
					in = new BufferedReader(new InputStreamReader(System.in));
				}
				else {
					in = new BufferedReader(new InputStreamReader(System.in));
				}
			}
			catch (Exception ex) {
			}
		}
		static int nextInt() {
			return Integer.parseInt(nextString());
		}
		static long nextLong() {
			return Long.parseLong(nextString());
		}
		static double nextDouble() {
			return Double.parseDouble(nextString());
		}
		static String nextString() {
			try {
				while (token == null || !token.hasMoreTokens()) {
					token = new StringTokenizer(in.readLine());
				}
			}
			catch (IOException e) {
			}
			return token.nextToken();
		}
	}
}

Measured memory_bytes: 81636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL << 60;

//input
ll h[100010];

//DP Table
ll dp[100010];

int main() {

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

    //initialize
    for (int i = 0; i < 100010; ++i) {
       dp[i] = INF;
    }

    //First Condition
    dp[0] = 0;

    //loop
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
n,a,b,c = map(int, input().split())
a,b,c = sorted([a,b,c])
l = [int(input()) for i in range(n)]
ans = 10 ** 18
for i in range(4 ** n):
  LEN = [0,0,0,0]
  num = [0,0,0,0]
  for j,v in enumerate(l):
    index = (i >> (j * 2)) & 3
    LEN[index] += v
    num[index] += 1
  if num[0] and num[1] and num[2]:
    mp = (sum(num[:3])-3) * 10
    d = sorted(LEN[:3])
    mp += abs(d[0]-a) + abs(d[1]-b) + abs(d[2]-c)
    ans = min(ans, mp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct trie{
	int to[2];
	int val;
	trie(){
		val=0;
	}
};

int size=1;
trie t[1<<23];

int n;
ll l;
void pushTrie(string str){
	int node=0;
	vector<int> ro;
	for(int i=0;i<(int)str.size();i++){
		int b=(str[i]-'0');
		if(t[node].to[b]==0){
			t[node].to[b]=size++;
		}
		ro.push_back(node);
		node=t[node].to[b];
	}
	t[node].val=2;
	for(int i=0;i<ro.size();i++){
		t[ro[i]].val=max(1,t[ro[i]].val);
	}
}

vector<ll> a;

void getValue(int v,ll dep){
	//printf("%d\n",v);
	if(t[v].val==0){
		a.push_back(l-dep);
	}else if(t[v].val==1){
		if(t[v].to[0]!=0){
			getValue(t[v].to[0],dep+1LL);
		}else{
			a.push_back(l-dep);
		}
		if(t[v].to[1]!=0){
			getValue(t[v].to[1],dep+1LL);
		}else{
			a.push_back(l-dep);
		}
	}
}

int main(void){
	scanf("%d%lld",&n,&l);
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		pushTrie(str);		
	}
	getValue(0,0);
	for(int i=0;i<a.size();i++){
		//printf("%lld\n",a[i]);
	}
	ll gr=0;
	for(int i=0;i<a.size();i++){
		ll v=a[i];
		int ct=0;
		while(v%2LL==0){
			v/=2LL;
			ct++;
		}
		gr^=1LL<<ct;
	}
	printf("%s\n",gr==0LL?"Bob":"Alice");
	return 0;
}

Measured memory_bytes: 104816
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int n, W;
	cin >> n >> W;
	vector<int>v(n);
	vector<int>w(n);
	for (int i = 0; i < n; i++)cin >> w[i] >> v[i];
	vector<vector<int>>dp(n, vector<int>(W+1));
	for (int i = w[0]; i <= W; i++)dp[0][i] = v[0];
	for (int i = 1; i <n; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if (j >= w[i])dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
	cout << dp[n - 1][W];
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;
 
int a[12][12];
 
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
 
  int ans = INF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine().trim();
		int n=Integer.parseInt(s);

		String[] s1=br.readLine().split(" ");
		long sum=0;
		HashMap<Integer,Integer> hm=new HashMap<>();
		for(int i=0;i<n;i++)
		{
			int x=Integer.parseInt(s1[i].trim());
			sum+=x;
			if(hm.containsKey(x)) {
				hm.replace(x, hm.get(x)+1);
			}
			else {
				hm.put(x,1);
			}
			
		}


		String s3=br.readLine().trim();
		int q=Integer.parseInt(s3);
//		System.out.println(hm);
//		System.out.println(get_sum(segment,0,n-1,0,a.length-1,0));
		while(q-->0) {
			
			String[] s4=br.readLine().split(" ");
			int l=Integer.parseInt(s4[0].trim());
			int r=Integer.parseInt(s4[1].trim());
			
			if(hm.containsKey(l)) {
				int sum1=hm.get(l);
				if(hm.containsKey(r)) {
					hm.replace(r,sum1+hm.get(r));
				}
				else {
					hm.put(r,hm.get(l));
				}
				hm.remove(l);
				int diff=Math.abs(l-r);
				if(l>r)
				{
				sum-=(sum1*diff);	
				}
				else {
				sum+=(sum1*diff);	
				}
			}
//			System.out.println(hm);
//				
			System.out.println(sum);
			
			
		}
			
		
		
		
		
		
		
	}
}

Measured memory_bytes: 70776
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned int uint;


int main(int argc, char const *argv[])
{
    bool buf[4] = {false,false,false,false};

    int x,y;
    cin >> x;
    cin >> y;

    buf[x] = buf[y] = true;

    for(int i = 1;i <=3;i++)
    {
        if(buf[i]== false)
        {
            cout << i <<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.annotation.tailrec

object Main {

  case class Gate(left: Int, right: Int)

  def read() = {
    val sc = new Scanner(System.in)
    val nCard, nGate = sc.nextInt()
    val gates = IndexedSeq.fill(nGate)(Gate(sc.nextInt(), sc.nextInt()))
    (nCard, nGate, gates)
  }


  def solve(nCard: Int, nGate: Int, gates: IndexedSeq[Gate]): Int = {
    val maxL = gates.map(_.left).max
    val minR = gates.map(_.right).min
    if(minR < maxL) 0
    else minR - maxL + 1
  }

  def main(args: Array[String]): Unit = {
    val (nCard, nGate, gates) = read()
    val result = solve(nCard, nGate, gates)
    println(result)
  }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(63)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

PI p[55];
vector<li> xs, ys;
li n, k;

inline li count(li x1, li x2, li y1, li y2) {
    li res = 0;
    rep(i, n) {
        if (p[i].F >= x1 && p[i].F <= x2
                && p[i].S >= y1 && p[i].S <= y2) {
            ++res;
        }
    }
    return res;
}

int main() {
    cin >> n >> k;
    rin{
        cin >> p[i].F >> p[i].S;
        xs.pb(p[i].F);
        ys.pb(p[i].S);
    }
    sort(allof(xs));
    sort(allof(ys));
    unsigned li res = INF;
    rep(xi, n - 1) {
        repp(xii, xi + 1, n) {
            rep(yi, n - 1) {
                repp(yii, yi + 1, n) {
                    if (count(xs[xi], xs[xii], ys[yi], ys[yii]) >= k) {
                        res = min(res, (unsigned li)((xs[xii] - xs[xi]) * (ys[yii] - ys[yi])));
                    }
                }
            }
        }
    }
    cout << res << endl;

    return 0;
}

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

const function<int(int, int)> minQ = [](int l, int r) { return min(l, r); };

int data[1 << 23];
int v[1 << 20];

template <typename T>
class SegmentTree2 {
	using func_t = function<T(T, T)>;
	const int h, w;
	const T id;
	func_t merge;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
	T Find(int i, int lj, int rj) {
		lj += w, rj += w + 1;
		T res = id;
		while (lj < rj) {
			if (lj & 1) res = merge(res, data[i * w * 2 + lj++]);
			if (rj & 1) res = merge(res, data[i * w * 2 + --rj]);
			lj >>= 1, rj >>= 1;
		}
		return res;
	}
public:
	SegmentTree2(int h_, int w_, T id_, func_t merge_) :
		h(size(h_)), w(size(w_)), id(id_), merge(merge_) {
		fill(data, data + (1 << 23), id);
		for (int i = 0; i < h_; i++)
			for (int j = 0; j < w_; j++)
				data[(h + i) * w * 2 + w + j] = v[i * w_ + j];
		for (int i = h * 2 - 1; i >= h; i--)
			for (int j = w - 1; j > 0; j--)
				data[i * w * 2 + j] = merge(data[i * w * 2 + j * 2], data[i * w * 2 + j * 2 + 1]);
		for (int i = h - 1; i > 0; i--)
			for (int j = 1; j < w * 2; j++)
				data[i * w * 2 + j] = merge(data[i * 2 * w * 2 + j], data[(i * 2 + 1) * w * 2 + j]);
	}
	void Update(int pi, int pj, T val) {
		pi += h;
		pj += w;
		data[pi * w * 2 + pj] = val;
		int tj = pj;
		while (tj >>= 1) {
			data[pi * w * 2 + tj] = merge(data[pi * w * 2 + tj * 2], data[pi * w * 2 + tj * 2 + 1]);
		}
		while (pi >>= 1) {
			data[pi * w * 2 + pj] = merge(data[(pi * 2) * w * 2 + pj], data[(pi * 2 + 1) * w * 2 + pj]);
			tj = pj;
			while (tj >>= 1) {
				data[pi * w * 2 + tj] = merge(data[pi * w * 2 + tj * 2], data[pi * w * 2 + tj * 2 + 1]);
			}
		}
	}
	T Find(int li, int lj, int ri, int rj) {
		li += h, ri += h + 1;
		T res = id;
		while (li < ri) {
			if (li & 1) res = merge(res, Find(li++, lj, rj));
			if (ri & 1) res = merge(res, Find(--ri, lj, rj));
			li >>= 1, ri >>= 1;
		}
		return res;
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int r, c, q, r1, r2, c1, c2;
	while (cin >> r >> c >> q, r | c | q) {
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				cin >> v[i * c + j];
			}
		}
		SegmentTree2<int> st(r, c, INT_MAX, minQ);
		while (q--) {
			cin >> r1 >> c1 >> r2 >> c2;
			printf("%d\n", st.Find(r1, c1, r2, c2));
		}
	}
	return 0;
}

Measured memory_bytes: 39896
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 100005;
const int MOD = 1000000007;


int n,m;
int x[N],y[N],tmp[N];
int tot=0;
PII a[N];
LL dp[N],sum[N];

inline void ins(int x,LL val) {while (x<=tot) {sum[x]+=val; x+=x&-x;}}
inline LL query(int x) {LL ret=0; while (x) {ret+=sum[x]; x-=x&-x;} return ret%MOD;}

inline bool cmp(const PII &a,const PII &b) {return (a.first==b.first)?(a.second>b.second):(a.first<b.first);}

int main() {

	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	n=read(),m=read();
	rep(i,1,n) x[i]=read(); rep(i,1,m) y[i]=read();
	sort(x+1,x+n+1); sort(y+1,y+m+1);
	rep(i,1,n) {
		if (x[i]<y[1]||x[i]>y[m]) continue;
		int pos=lower_bound(y+1,y+m+1,x[i])-y;
		a[++tot]=PII(x[i]-y[pos-1],y[pos]-x[i]);
	}
	sort(a+1,a+tot+1,cmp); tot=unique(a+1,a+tot+1)-a-1;
	rep(i,1,tot) tmp[i]=a[i].second; sort(tmp+1,tmp+tot+1);
	int num=unique(tmp+1,tmp+tot+1)-tmp-1;
	rep(i,1,tot) {
		a[i].second=lower_bound(tmp+1,tmp+num+1,a[i].second)-tmp;
		dp[i]=query(a[i].second-1)+1;
		ins(a[i].second,dp[i]);
	}
	LL ans=0; rep(i,1,tot) ans+=dp[i];
	printf("%lld\n",(ans+1)%MOD);

	return 0;
	
}


Measured memory_bytes: 3328
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int a[3];
	rep(i, 3) {
		cin >> a[i];
	}
	if (a[0]==a[1] && a[1]==a[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int count = 0;
		boolean flag = false;
		StringBuilder s = new StringBuilder(in.nextLine());
		StringBuilder front = new StringBuilder("");
		StringBuilder back = new StringBuilder("");
		int q = in.nextInt();
		for(int i=0; i<q; i++) {
			int op = in.nextInt();
			if(op==1) {
				count++;
				flag = !flag;
			}else if(op==2) {
				int position = in.nextInt();
				char c = in.next().charAt(0);
				if(flag) {
					if(position==1) position=2;
					else if(position==2) position=1;
				}
				if(position==1) {
					front.append(c);
				}else if(position==2) {
					back.append(c);
				}
			}
		}
		if(count%2!=0) {
			System.out.print(back.reverse().append(s.reverse()).append(front));
		}else {
		    System.out.print(front.reverse().append(s).append(back));
		}
	}
	
}


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

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

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



int main() 
{
    int n;
    cin >> n;
    vector<double> a(n);
    double ans = 0.0;
    rep(i, n) cin >> a[i];
    rep(i, n) ans += 1 / a[i];
    printf("%.6lf\n", 1 / ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int F[102][102];
  
void DFS(int Y,int X,int c){
  if(F[Y][X] != c){
    return;
  }
  
  F[Y][X] = -1;
  DFS(Y-1,X  ,c);
  DFS(Y  ,X+1,c);
  DFS(Y+1,X  ,c);
  DFS(Y  ,X-1,c);
}
  
  
int main(){
  int w,h,xs,ys,xg,yg,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;

    for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j]=0;
      }
    }
      
    cin >> xs >> ys >> xg >> yg >> n;
  
  
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }

  if(F[xs][ys] == 0){
    cout << "NG" << endl;
  } else {
    DFS(xs,ys,F[xs][ys]);
  
    if(F[xg][yg] == -1){
      cout << "OK" << endl;
    } else {
      cout << "NG" <<endl;
    }
  }

}
}


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

using namespace std;

using ll = long long;

int main(){
  string S;
  cin >> S;
  
  int number = atoi(S.c_str());
  
  int f_half = (int)number/100;
  int s_half = (int)number%100;
  
  
  
  if((0<f_half && f_half<13) && (0<s_half && s_half<13)){
    cout << "AMBIGUOUS" << endl;
  }else if((0<f_half && f_half<13)){
    cout << "MMYY" << endl;
  }else if((0<s_half && s_half<13)){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3624
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

flag = 1

aa=[]
aa.append(a)
aa.append(b)
aa.append(c)
aa.append(d)
aa.append(e)

for i in range(5):
    for j in range(5):
        if (aa[i]-aa[j]>k) or (aa[i]-aa[j]<-1*(k)):
            flag = 0

if(flag):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int a[100001], b[100001];
int main() {
  a[1] = 1;
  for (int i = 2; i <= 100000; i++) 
    for (int j = 2*i; j <= 100000; j += i)
      a[j] = 1;
  for (int i = 1; i <= 100000; i++) {
    if (a[i] == 0 && a[(i+1)/2] == 0)
      b[i] = b[i-1] + 1;
    else
      b[i] = b[i-1];
  }
  int n, r, l;
  cin>>n;
  while (n--) {
    cin>>r>>l;
    cout<<b[l]-b[r-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int l=1;l<=n;l++){
		ans += (1-l)*(n-l+1) + (n+l)*(n-l+1)/2;
	}
	for(int i=1,a,b;i<n;i++){
		cin>>a>>b;
		if(b<a)swap(a,b);
		ans -= a*(n-b+1);//( (n-b+1)*(b-a) + a*(b-a) );
		// cout<<"ans = "<<ans<<" | "<<(n-b+1)*(b-a)<<" "<<a*(b-a)<<"\n";
	}
	cout<<ans<<"\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3516
import numpy as np
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(1000)

ten = 10 ** 6

def solve(N):
    # prime factor
    ans = 2000000000000 + 10
    for i in range(1,ten+1):
        if N % i == 0:
            a = i
            b = N // i
            ans = min( ans , a + b - 2)
        
        if i > N :
            break
    
    print(ans)

if __name__ == "__main__":
    N = int(input())
    solve(N) 





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

int main() {

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

  sort(n.begin(), n.end());

  int n1 = n[0] + n[1] + n[2];
  int n2 = n[2] * 3;
  int n3 = 0;
  
  if (n1 % 2 == n2 % 2) {
    n3 = n[2];
  } else {
    n3 = n[2] + 1;
  }

  int count = 0;

  if (n3 != n[2]) {
    n[2]++;
    if (n[0] % 2 == 0) {
      n[0]++;
    } else {
      n[1]++;
    }
    count++;
  }

  while (n[1] != n3){
    if (n3 - n[1] == 1) {
      n[1]++;
      n[0]++;
    } else {
      n[1] += 2;
    }
    count++;
  }

  while (n[0] != n3){
    n[0] += 2;
    count++;
  }

  cout << count << endl;

}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            if (a == 0 && b == 0) break;
            var m1000 = (b - a) / 1000;
            var m500 = ((b - a) % 1000) / 500;
            var m100 = (((b - a) % 1000) % 500) / 100;
            Console.WriteLine("{0} {1} {2}", m100, m500, m1000);
        }
    }
}

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

using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)
		cout << "Left" << endl;
	else if (a + b < c + d)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;

	return 0;
}

Measured memory_bytes: 256