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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int cake_num[3];
VVL cake(3);
set<ll> visited_set;
ll cake_sum(ll index) {
    int i = index % 1000;
    int j = (index / 1000) % 1000;
    int k = index / 1000000;
    return cake[0][i] + cake[1][j] + cake[2][k];
}

VL cake_nexts(ll index) {
    int i = index % 1000;
    int j = (index / 1000) % 1000;
    int k = index / 1000000;
    VL res;
    if(i < cake_num[0] - 1) res.push_back(index + 1);
    if(j < cake_num[1] - 1) res.push_back(index + 1000);
    if(k < cake_num[2] - 1) res.push_back(index + 1000000);
    return res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    REP(i, 3) {
        cin >> cake_num[i];
        cake[i].resize(cake_num[i]);
    }
    cin >> k;
    REP(i, 3)REP(j, cake_num[i]) cin >> cake[i][j];
    REP(i, 3) sort(ALL(cake[i]), greater<ll>());

    priority_queue<PL> ans;
    int index = 0;
    ans.push(PL(cake_sum(index), index));
    visited_set.insert(index);
    REP(i, k) {
        for(auto cake_next : cake_nexts(index)) {
            if(visited_set.count(cake_next) > 0) continue;
            ans.push(PL(cake_sum(cake_next), cake_next));
            visited_set.insert(cake_next);
        }
        cout << ans.top().first << ln;
        index = ans.top().second;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         INT_MAX-100
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
//const int N;

void solve()
{
    ll n; cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    ll dp[n];
    memset(dp,0,sizeof dp);
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    rep(i,2,n) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1];
}
int main()
{
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;


int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int count=0;
    vector<int> ans;
    for(int i=1;i<=min(a,b);i++)
    {   
        if(a%i==0 && b%i==0)
        {
            ans.push_back(i);
        }
    }
    cout<<ans[ans.size()-k];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int g = 0;
    int gg = 0;
    rep(i, s.size()){
        if(i % 2 == 0){
            if(s[i] == '1') g ++;

        }else{
            if(s[i] == '0') g ++;
        }
    }
    rep(i, s.size()){
        if(i % 2 == 0){
            if(s[i] == '0') gg ++;

        }else{
            if(s[i] == '1') gg ++;
        }
    }
    if(g > gg) g = gg;
    cout << g << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.math.*;

public class Main{
	
	public static void main(String args[]){
		int n;
		int vet[] = new int[5010];
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		
		for (int i = 0; i < n; i++)
		{
			vet[i] = sc.nextInt();
		}
		
		
		BigInteger b = new BigInteger(String.valueOf(vet[0]));
		BigInteger aux = new BigInteger("0");
		BigInteger aux2 = new BigInteger("0");
		for (int i = 1; i < n; i++)
		{
			aux = b.multiply(BigInteger.valueOf(vet[i]));
			aux2 = b.gcd(BigInteger.valueOf(vet[i]));
			b = aux.divide(aux2);
		}
		//~ System.out.println(b);
		
		b = b.subtract(BigInteger.ONE);
		long ans = 0;
		for (int i = 0; i < n; i++)
		{
			//~ System.out.println(b.mod(BigInteger.valueOf(vet[i])));
			ans += b.mod(BigInteger.valueOf(vet[i])).longValue();
		}
		System.out.println(ans);
	}
	
}


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


int main() {
int N,K;
cin>>N>>K;
vector<int> p(N);
for(int i=0;i<N;i++) cin>>p[i];
sort(p.begin(),p.end());
long ans=0;
for(int i=0;i<K;i++){
ans+=p[i];
}
cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <iostream>
#define lowbit(i) (i&(-i))
using namespace std;
const int maxn = 2e5+5;
int readint(){
	int x=0,f=1;char s=getchar();
	#define sc (s=getchar())
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		sc;
	}
	while(s>='0'&&s<='9'){
		x=(x<<3)+(x<<1)+(s^48);
		sc;
	}
	#undef sc
	return x*f;
}
bool vis[105];
signed main (){
	int n=readint(),k=readint();
	for(int i=1;i<=k;i++){
		int x=readint();
		while(x--){
			vis[readint()]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i])
			ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int A, B, ans=10001, f=0;
    cin >> A >> B;

    REP(i, 10000){
        if(int(floor(i*0.1)) == B & int(floor(i*0.08)) == A){
            ans = min(ans, i);
            f = 1;
        } else {
            if(f == 1){
                break;
            }
        }
    }

    if(ans > 10000){
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

// t * 0.1  = B
// t * 0.08 = A

// t = (B+r1)/0.1
// t = (A+r2)/0.08


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
#define deb(x) cout<<(#x)<<" "<<x<<endl
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}




void solve(){

lli n , a;
cin>>n;
lli cnt = 0;
fo(i,n){
    cin>>a;
    cnt += (a%2==1 && (i%2==0));
}
cout<<cnt<<Endl;


}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;
}

 // #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

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


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

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

void purchace(long long* money, long long* kabu, int value)
{
    *kabu += (*money / value);
    *money -= *kabu * value;
 
    return;
}
 
void sell(long long* money, long long* kabu, int value)
{
    *money += *kabu * value;
    *kabu = 0;  // 全部売る 
 
    return;
}
 
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i=0; i<N; i++)  std::cin >> A[i];
	A.push_back(0);
 
	long long money = 1000;
	long long kabu = 0;
 
	// 1日のはじめに必ず全部売り、明日利益がでるなら買い戻し、利益がでないなら何もしない(お金のママ) 
	rep(i, N)
	{
		// 売る 	
		sell( &money, &kabu, A[i]);

		// 買い戻す? 
		if(A[i] > A[i+1])
		{
			continue;
		}
		else
		{
			purchace( &money, &kabu, A[i]);
		}
	}
    std::cout << money << std::endl;
 
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
	
	return 0;
}


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


using namespace std;

const int MAXN = 100 * 1000 + 23;





int n, m, d[MAXN], par[MAXN];
vector<int> g[MAXN];

void dfs(int v) {
    for (auto u : g[v])
        if (--d[u] == 0)
            par[u] = v;
    for (auto u : g[v])
        if (d[u] == 0)
            dfs(u);
}



int main() {
    cin >> n >> m;
    for (int i = 1; i < n + m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        d[v]++;
    }
    int st;
    for (int i = 1; i <= n; i++)
        if (d[i] == 0)
            st = i;
    dfs(st);
    for (int i = 1; i <= n; i++)
        cout << par[i] << '\n';
    return 0;
}

Measured memory_bytes: 10240
import scala.io.Source

object Main extends App {

  val input: Iterator[String] = for (l <- Source.stdin.getLines; if l != "0") yield l
  val content: List[String] = input.toList
  val index: List[Int] = List.range(1, content.length + 1)

  val output: List[(Int, String)] = index.zip(content)

  for {
      o <- output
  } println("Case " + o._1 + ": " + o._2)
}

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

void solve(){
    long long a, b, x; cin >> a >> b >> x;
    long long total = b/x+1;//0-bまでで割り切れるもの
    long long totala = (a-1)/x+1;//0~a-1までで割り切れるもの
    if(a == 0) totala = 0;
    cout << total-totala << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> d){
    set<ll> s;
    for (int i = 0; i < N; i++)
    {
        s.insert(d[i]);
    }
    cout << s.size() << endl;
    
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int cntt[100], cnt74,cnt24,cnt14,cnt4,cnt2;
signed main(){
	int n;
	cin>>n;
	vector<int> pr;
	for(int i=2;i<=n;i++){
		int cur = i;
		bool fl = true;
		for(int j=2;j*j<=cur;j++){
			if( i%j == 0)fl = false;
		}
		if( fl == true ){
			pr.pb(cur);
		}
	}
	for(int i=2;i<=n;i++){
		int cur = i;
		for(int j=0;j<pr.size();j++){
			while( cur % pr[j] == 0 ){
				cntt[ pr[j] ] ++;
				cur /= pr[j];
			}
		}
	}
	for(int i=0;i<pr.size();i++){
		if( cntt[pr[i]] >= 74 ) cnt74++;
		if( cntt[pr[i]] >= 24 ) cnt24++;
		if( cntt[pr[i]] >= 14 ) cnt14++;
		if( cntt[pr[i]] >= 4 ) cnt4++;
		if( cntt[pr[i]] >= 2 ) cnt2++;
	}
	int ans = 0;
	ans += cnt74;
	ans += cnt24*(cnt2-1);
	ans += cnt14*(cnt4-1);
	ans += cnt4*(cnt4-1)*(cnt2-2)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <typeinfo>
using namespace std;

typedef long long ll;
const int mod = 1000000007;
const int MAX_N = 100005;

ll fact[MAX_N];         // 階乗
ll ifact[MAX_N];        // 階乗の逆元

// x^nを求める繰り返し二乗法(累乗の高速化)
// フェルマーの小定理より、逆元を計算するときに用いる。
ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }

    return res;
}

// 階乗とその逆元テーブルを(0-n)まで埋める
void table(int n){
    fact[0] = 1;    // i^0 = 1;
    for(int i = 1; i <= n; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }

    // フェルマーの小定理を利用して、右端の逆元を求める
    // 階乗の(mod-2)乗
    ifact[n] = mod_pow(fact[n], mod - 2);

    // 逆元の性質を利用して、テーブルを埋める
    for(int i = n; i >= 1; --i){
        ifact[i - 1] = ifact[i] * i % mod;
    }
}

// nCrを求める
ll combination(int n, int r){
    if(n < 0 || r < 0 || n < r)     return 0;

    return (ll)fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, id1 = 0, id2 = 0;
    cin >> n;
    vector<int> a(n+1), cnt(n+1, 0);
    for(int i = 0; i < n+1; ++i){
        cin >> a[i];
        ++cnt[a[i]];
        
        if(cnt[a[i]] == 2)      id2 = i;   
    }
    for(int i = 0; i < n+1; ++i){
        if(a[i] == a[id2]){
            id1 = i;
            break;
        }
    }
    
    table(n+2);
    
    // 重複している数字をxとして、xの左にある数字の個数
    // a = [...x.....x...]
    int num1 = id1;
    // xの右側にある数字の個数
    int num2 = n - id2;

    // 重複している数字：x
    for(int i = 1; i <= n+1; ++i){        // 数字をi個取る
        ll res = (combination(n + 1, i) - combination(num1 + num2, i - 1) + 2 * mod) % mod;
        
        cout << res << "\n";
    }
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

class BIT {
public:
	BIT(ll N, ll v) :V_SIZE(N) {
		dat.resize(N);
		fill(dat.begin(), dat.end(), v);
	}

	ll query(ll i) {
		ll ret = 0;
		while (i > 0) {
			ret += dat[i];
			i -= (i & -i);
		}
		return ret;
	}

	void update(ll i, ll v) {
		while (i < V_SIZE) {
			dat[i] += v;
			i += (i & -i);
		}
	}

	ll V_SIZE;
	vector<ll> dat;
};

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<BIT> b(N+1, BIT(N+1, 0));//1-indexed

    for (int i = 0; i < M; i++) {
        int L, R;
        scanf("%d %d", &L, &R);
        for (int j = 1; j <= L; j++) {
            b[j].update(R, 1LL);
        }
    }

    for (int i = 0; i < Q; i++) {
        int p, q;
        scanf("%d %d", &p, &q);
        printf("%lld\n", b[p].query(q));
    }


    return 0;
}

Measured memory_bytes: 2944
while True:
    m, f, r = map(int, input().split())
    if m==f==r==-1:
        break
    elif m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65:
        print('B')
    elif m+f>=50:
        print('C')
    elif m+f>=30:
        if r>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
import numpy as np
mod = 1000000007

def init(inv, finv):
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, inv.shape[0]):
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def comb(n, r):
    a = 1
    for i in range(n - r + 1, n + 1):
        a = a * i % mod
    return (a * finv[r]) % mod


n, a, b = [int(x) for x in input().split()]
m = max(a, b) + 1
inv = np.zeros(m, np.int64)
finv = np.zeros(m, np.int64)
init(inv, finv)
ans = (pow(2, n, mod) - comb(n, a) - comb(n, b) - 1) % mod
print(ans)

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

using namespace std;

int main(){
    long long x;
    cin >> x;
    long long happiness = 0;
    happiness = (x/500)*1000;
    x = x%500;
    happiness += (x/5)*5;
    x = x%100;
    x = x%50;
    x = x%10;
    cout << happiness << endl; 
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
pa = [0] * N
for i in range(N): pa[i] = a[i] * (a[i] > 0)
csp = [0] * (N + 1)
for i in range(N): csp[i + 1] = csp[i] + pa[i]
#print(csp, cs)
res = 0
for i in range(N - K + 1):
  x = cs[i + K] - cs[i]
  y = csp[-1] - (csp[i + K] - csp[i])
  t = max(0, x) + y
  res = max(res, t)
print(res)

Measured memory_bytes: 62880
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
LIM = 10 ** 18
ans = 1
if A[-1] == 0:
    print(0)
    exit()
for i in A:
    ans *= i
    if ans > LIM:
        print(-1)
        exit()
print(ans)


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

#define ll long long int
#define mk make_pair
#define ff first
#define ss second
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt")  
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007

ll gcd(ll x, ll y){ 
	if(x<y) 
		swap(x,y); 
	if(x%y==0)
		return y;
	return gcd(y, x%y);
}

ll pwm(ll a, ll n){
	ll ans = 1;
	while(n>0){
		if(n%2==1){
			ans = (ans * a)%mod;
		}
		a = (a*a)%mod;
		n /= 2;
	}
	return ans%mod;
}

const int pwn = 100010;
ll pw[pwn];
void pwtwo(){
	pw[0] = 1;
	for(int i=1; i<pwn; i++){
		pw[i] = (pw[i-1]*2)%mod;
	}
}


ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
ll modInverse(ll a, ll m) 
{ 	
	if(a==1)
		return 1;
	//cout<<"mi "<<a<<" "<<m<<" ";
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1){
        //cout << "Inverse doesn't exist"<<endl; 
        return -1;
    }
    else
    { 
        // m is added to handle negative x 
        ll res = (x%m + m) % m; 
        //cout<<res<<endl;
        return res;
        // cout << "modular multiplicative inverse is " << res; 
    } 
} 
  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

ll fact[1010];
ll init(){
	fact[0] = 1;
	for(int i=1; i<1010; i++)
		fact[i] = (fact[i-1]*i)%mod;
}

ll ncr(ll n, ll r){
	ll ans = fact[n];

	//if(r!=0)
	ans = (ans*modInverse(fact[r], mod))%mod;
	// if(n-r!=0)
	ans = (ans*modInverse(fact[n-r], mod))%mod;

	return ans;
}

int main(){
	// finput;
	// foutput;
	fast;

	int n, k, i, j, x, m;
	int ans;
	// string s;
	cin>>n;
	int a, b;
	a = b = 0;
	while(n>0){
		x = n%10;
		a += x/2;
		b += x-(x/2);
		n /= 10;
	}

	ans = a + b;

	if(a==0 && b==1){
		ans = 10;
	}

	cout<<ans;


	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int res = 0;
  for (int i = n-1; i >= 0; i--) {
    for (int j = i-1; j >= 0; j--) {
      auto itr = lower_bound(l.begin(),l.end(), l[i]+l[j]);
      int d = distance(itr, l.end());
      res += (n-1-i) - d;
    }
  }
  cout << res << endl;
  return 0;
}

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

int main() {
    int n;
    int a;
    map<int, int> dic;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        if(dic.find(a) == dic.end()) {
            dic[a] = true;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
 }

Measured memory_bytes: 9728
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f [b,r,g,c,s,t] = 100 + 15 * (b + r) + 7 * g + 15 * bonus + 2 * c - 3 * (t - bonus - s) - 2 * bonus
  where bonus = 5 * b + 3 * r

main = do
    ds <- getInts
    unless (all (==0) ds) $ print (f ds) >> main


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int x;
    scanf("%d",&x);
    printf("%d",1-x);
    return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int cnt=0;
    int d[n][2];
    bool flag=false;
    for(int i=0;i<n;i++){
        cin>>d[i][0]>>d[i][1];
        if(d[i][0]==d[i][1])cnt++;
        else cnt=0;
        if(cnt>=3)flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

long gcd(long x, long y)
{
	return y ? gcd(y, x % y) : x;
}

long lcm(__int128 x, __int128 y)
{
	return x * y / gcd(x, y);
}

int main() {
	int N;
	long T[100];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> T[i];
	for (int i = 1; i < N; ++i) T[i] = lcm(T[i - 1], T[i]);
	cout << T[N - 1];
}

Measured memory_bytes: 256
//Prashant Tyagi
using namespace std;
#include <bits/stdc++.h>
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
typedef  long long                     LL;
typedef  vector < int >                VI;
typedef  pair< int, int >              II;
typedef  vector < II >                 VII;
#define SI(x)                          scanf ("%d", &x)
#define SLL(x)                         scanf ("%lld", &x)
#define PI(x)                          printf ("%d\n", x)
#define PLL(x)                         printf ("%lld\n", x)
#define MOD                            98765431
#define PB                             push_back
#define MP                             make_pair
#define ALL(v)                         v.begin(), v.end()
#define VIF(x,V)                       for(int x:V)
#define FILL(a,b)                      memset(a,b,sizeof(a))
#define REP(i,j,n)                     for(int i=j;i<n;i++)
#define FLD(i,j,n)                     for(int i=n-1;i>=j;i--)
#define F                              first  
#define S                              second
#define fast_io                        ios_base::sync_with_stdio(false);cin.tie(NULL)

int main ()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;SI(n);SI(m);
	PI((n-1)*(m-1));
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long n = long.Parse(Console.ReadLine());
            long[] d = ILongs();
            Array.Sort(d);
            Console.WriteLine(d[n/2]-d[(n-1)/2]);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = Console.ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return Console.ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return Console.ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = Console.ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = Console.ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 17504
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll n, k, ans;
vector<ll> sei, fu;
const ll INF = 1000000000000000;
int main(void){
    // Your code here!
    ans = INF;
    cin >> n >> k;
    sei.push_back(0);
    for (ll i = 0; i < n; i++){
        ll x;
        cin >> x;
        if (x < 0){
            fu.insert(fu.begin(), x);
        } else {
            sei.push_back(x);
        }
    }
    fu.insert(fu.begin(), 0);
    for (ll i = 0; i < sei.size(); i++){
        if (i + fu.size() - 1 < k || i > k) continue;
        ans = min(ans, sei[i] - fu[k - i] * 2);
        ans = min(ans, sei[i] * 2 - fu[k - i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1656
s = input()
ans = "Yes"

for i in range(len(s)):
    if i % 2 == 1:
        if s[i] != "L" and s[i] != "U" and s[i] != "D":
            ans = "No"
    if i % 2 == 0:
        if s[i] != "R" and s[i] != "U" and s[i] != "D":
            ans = "No"
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  Sieve s(1e6);
  map<int, int> mp;
  rep(i, n) {
    auto v = s.factor(a[i]);
    for(P p : v) {
      mp[p.first] = max(mp[p.first], p.second);
    }
  }
  mint lcm = 1;
  for(auto p : mp) {
    rep(i, p.second) {
      lcm *= p.first;
    }
  }
  mint ans = 0;
  rep(i, n) {
    mint b = lcm / a[i];
    ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4988
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 50+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<vector<ll>> mult(vector<vector<ll>> m1, const vector<vector<ll>> m2) {
    vector<vector<ll>> m(m1.size(), vector<ll>(m1.size()));
    for (int i = 0; i < m1.size(); ++i) {
        for (int j = 0; j < m1.size(); ++j) {
            for (int k = 0; k < m1.size(); ++k) {
                m[i][j] = add(m[i][j], mult(m1[i][k], m2[k][j]));
            }
        }
    }
    return m;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, k; cin >> n >> k;
    vector<vector<ll>> m(n, vector<ll>(n)), ans(n, vector<ll>(n));
    rep (i, 0, n) rep (j, 0, n) cin >> m[i][j];
    rep (i, 0, n) ans[i][i] = 1;
    while (k > 0) {
        if (k & 1) ans = mult(ans, m);
        m = mult(m, m);
        k >>= 1;
    }
    ll sum = 0;
    rep (i, 0, n) rep (j, 0, n) sum = add(sum, ans[i][j]);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// #include "segtree_push.h"

// del

i64 n, l;

i64 solve(i64 skip) {
    i64 R = 0;
    for (i64 i = 1; i <= n; i++) {
        if (i == skip) {
            continue;
        }
        R += l + i - 1;
    }
    return R;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> l;

    i64 v = 0;
    i64 d = inf;
    i64 e = solve(0);
    for (i64 i = 1; i <= n; i++) {
        i64 c = solve(i);
        i64 cd = abs(c - e);
        if (cd < d) {
            d = cd;
            v = c;
        }
    }

    cout << v << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

static unsigned min(unsigned a, unsigned b)
{
        return a < b ? a : b;
}

int main (void)
{
        int h[101];
        unsigned dp[101];
        unsigned n, k, i, j;

        if (scanf("%u%u%d", &n, &k, &h[0]) != 3 || k > 100)
                abort();
        if (k > n)
                k = n;
        dp[0] = 0;
        for (i = 1; i < k; ++i) {
                unsigned curmin = ~0U;
                scanf("%d", &h[i]);
                for (j = 1; j <= i; ++j)
                        curmin = min(curmin, dp[i - j] + abs(h[i] - h[i - j]));
                dp[i] = curmin;
        }
        n -= k;
        while (n--) {
                unsigned curmin = ~0U;
                i = i > k ? 0 : i;
                scanf("%d", &h[i]);
                for (j = 1; j <= k; ++j) {
                        const unsigned w = j <= i ? i - j : i - j + k + 1;
                        curmin = min(curmin, dp[w] + abs(h[i] - h[w]));
                }
                dp[i++] = curmin;
        }

        printf("%d\n", dp[i - 1 > k ? k : i - 1]);

        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define N 100000
int partition(int,int);

int A[N],n;

int main()
{
  int i,p;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&A[i]);
  }
  p = partition(0,n-1);
  for(i=0;i<n;i++)
  {
    if(i)
      printf(" ");
    if(i==p)
      printf("[");
    printf("%d",A[i]);
    if(i==p)
      printf("]");
  }
printf("\n");
return 0;
}
int partition(int p,int r)
{
  int i,j,x,y;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j] <= x)
    {
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[r];
  A[r]=y;
  return i+1;
}



Measured memory_bytes: 2244
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

int main()
{
	int a, b, c, d;
	int ans;
	
	cin >> a >> b >> c >> d;

	ans = min(a, b);
	ans += min(c, d);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int h, w; 
int c_h, d_h, c_w, d_w;
string MP[N];
bool vis[N][N];
int ans = -1;

struct P{
	int x, y;
	int cnt;
};

bool inside(int x, int y) {
	return x >= 0 and x < h and y >= 0 and y < w;
}

bool legal(int x, int y) {
	return inside(x, y) and MP[x][y] == '.';
}

void bfs() {
	deque<P> dque; 
	dque.push_front({c_h, c_w, 0});
	while (!dque.empty()) {
		auto [x, y, cnt] = dque.front();
		dque.pop_front();
		if (x == d_h and y == d_w) {
			ans = cnt;
			break;
		}
		if (vis[x][y]) continue;
		vis[x][y] = true;
		for (int i = 0; i < 4; i++) {
			int nx = x + dir[i][0];
			int ny = y + dir[i][1];
			if (legal(nx, ny))
				dque.push_front({nx, ny, cnt});
		}
		for (int nx = x - 2; nx <= x + 2; nx++) {
			for (int ny = y - 2; ny <= y + 2; ny++) {
				if (legal(nx, ny))
					dque.push_back({nx, ny, cnt + 1});
			}
		}
	}
}

int main() {
	cin >> h >> w;
	cin >> c_h >> c_w >> d_h >> d_w;
	--c_h, --c_w, --d_h, --d_w;
	for (int i = 0; i < h; i++)
		cin >> MP[i];
	bfs();
	cout << ans << "\n";
}

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

int main(int argc, char *argv[]) {
    std::string input;
	int count = 0;
	std::vector<std::string> all_strings;

    while (std::getline(std::cin, input)) {
		input.erase(input.find_last_not_of("\n") +1 );
		if (count != 0) {
			all_strings.push_back(input);
		}
		++count;
	}

	std::sort(all_strings.begin(), all_strings.end());
	std::string result;
	for (auto one_string: all_strings) {
		result += one_string;
	}
	std::cout << result << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

int H;

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

void IncreaseKey(int *S,int i,int key){
    S[i]=key;
    int temp;
    while(i>1 && S[parent(i)]<S[i]){
        temp=S[i];
        S[i]=S[parent(i)];
        S[parent(i)]=temp;
        i=parent(i);
    }
}

void insert(int *S,int k){
    H++;
    IncreaseKey(S,H,k);
}



void maxHeapify(int *A,int i){
    int l,r,largest,temp;
    l=left(i);
    r=right(i);
    if(l<=H && A[l]>A[i])largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest])largest=r;
    
    if(largest!=i){
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(A,largest);
    }
}

int extractMax(int *A){
    int max;
    max=A[1];
    A[1]=A[H];
    H--;
    maxHeapify(A,1);
    return max;
}


int main(){
    int n, i, x;
    int ans,S[MAX];
    char com[20];
    for ( i = 0;; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(S,x);
        } else if ( com[0] == 'e' && com[1] == 'x'){
            ans=extractMax(S);
            printf("%d\n",ans);
        } else if(com[1] == 'n'){
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 5680
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s1;
    string s2;
    long long int a, b, c;
    cin >> a >> b;

    if(a==0){
    	if(b==100){
    		cout << "101" << "\n";
    	}else{
    	cout << b << "\n";
    }
    	
    }else if(a==1){
    	if(b==100){
    		cout << "10100" << "\n";
    	}else{
    	cout << b * 100 << "\n";
    }
    }else if(a==2){
    	if(b==100){
    		cout << "1010000"<< "\n";
    	}else{
    	cout << b * 100*100 << "\n";
    }
    }
  


   bye;

}


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

int main(){
  int N;
  cin >> N;
  
  double Y = 0;
  for(int i = 0;i < N;i++){
    double x;
    string u;
    cin >> x >> u;
    
    if(u == "JPY") Y += x;
    if(u == "BTC") Y += x * 380000.0;
  }
  
  cout << Y << endl;
  
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int INF = 1e9 + 7;
  vector<int> h(N+1, 0);
  vector<int> dp(N+2, INF);
  REP(i, N){
    cin >> h[i+1];
  }
  dp[1] = 0;
  for(int i = 2; i <= N+1; i++){
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string lol;
	cin >> lol;
	if (lol == s)
		--a;
	else
		--b;
	cout << a << ' ' << b;
}   

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
h,w = map(int,input().split())
la = [list(map(int,input().split())) for i in range(h)]
for i in range(h):
    l = list(map(int,input().split()))
    for j,num in enumerate(l):
        la[i][j] = abs(la[i][j]-num)
dp = [[0 for i in range(w)] for j in range(h)]
k = (h+w)*80+2
dp[0][0] = 1 << (k+la[0][0]) | 1 << (k-la[0][0])

for i in range(h):
    for j in range(w):
        if i:
            dp[i][j] |= (dp[i-1][j] << la[i][j]) | dp[i-1][j] >> la[i][j]
        if j:
            dp[i][j] |= (dp[i][j-1] << la[i][j]) | dp[i][j-1] >> la[i][j]
        
s = bin(dp[-1][-1])[2:]
l = len(s)-1
ans = float('inf')
for i in range(l,-1,-1):
  if s[i]=='1':
    m = abs(l-i-k)
    if m<ans:
      ans = m
print(ans)


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

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

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

ll readint(){
	ll 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 ll inf=(1ull<<63)-1;
ll n,q,l,r;
ll a[200005],opt[200005],X[200005],S[200005],T[200005];

int main(){
	n=readint(); q=readint(); l=readint(); r=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	for(int i=1;i<=q;i++){
		opt[i]=readint(); X[i]=readint(); S[i]=readint(); T[i]=readint();
	}
	for(int i=q;i>=1;i--){
		ll s=S[i],t=T[i],x=X[i];
		if(opt[i]==1){
			ll tl=l/t-s,tr=r/t-s;
			if(l>x) l=max(tl,x),r=max(tr,x-1);
			else if(r<x);
			else r=max(tr,x-1);
		}
		else{
			ll tl,tr;
			if(l<0){
				if(-inf/(l-1)<=t) tl=-inf;
				else tl=t*(l-1)+s+1;
			}
			else{
				if((inf-s)/l<=t) tl=inf;
				else tl=t*l+s;
			}
			if(r<0){
				if(-inf/r<=t) tr=-inf;
				else tr=t*r+s;
			}
			else{
				if((inf-s+1)/(r+1)<=t) tr=inf;
				else tr=t*(r+1)+s-1;
			}
			if(l>x);
			else if(r<x) l=min(tl,x+1),r=min(tr,x);
			else l=min(tl,x+1);
		}
//		cout<<"test "<<i<<' '<<l<<' '<<r<<endl;
		if(l>r) return printf("0\n"),0;
	}
	int cnt=0;
//	cout<<"end "<<l<<' '<<r<<endl;
//	for(int i=1;i<=n;i++) cout<<a[i]<<' ';
//	cout<<endl;
	for(int i=1;i<=n;i++) if(l<=a[i]&&a[i]<=r) cnt++;
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 10776
#include <stdio.h>
#include <stdlib.h>

int cnt;
int G[100];

void insertionSort(int A[],int n,int g)
{
    int v,j;
    for(int i = g;i<n;i++)
    {
        v = A[i];
        j = i - g;
        while(j >= 0 && v < A[j])
        {
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[],int n)
{
    int m = 0,cnt = 0;
    G[0] = 1;
    while((3 * G[m] + 1) <= n)
    {
        m++;
        G[m] = 3 * G[m-1] + 1;
    }
    printf("%d\n", m+1);
    for(int i=m; i>0; i--){
        printf("%d ",G[i]);
    }
    printf("%d\n", G[0]);
    for(int i=m; i>=0; i--){
        insertionSort(A,n,G[i]);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    int *A = malloc(sizeof(int)*n);
    for(int i=0;i<n;i++)    scanf("%d",&A[i]);
    shellSort(A,n);
    printf("%d\n",cnt);
    for(int i=0;i<n;i++)
    printf("%d\n",A[i]);
    free(A);
    return 0;
}


Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
  int n;
  while(cin >> n, n != 0){
    vector<vector<int>> p(n);
    for(int range(i,0,n)){
      int m;
      cin >> m;
      p[i] = vector<int>(m);
      for(int range(j,0,m)){
        cin >> p[i][j];
      }
      sort(all(p[i]));
    }
    int k;
    cin >> k;
    vector<int> l(k);
    for(int range(j, 0, k)){
      cin >> l[j];
    }
    sort(all(l));
    int id = -2;

    for(int range(i,0,n)){

      if(includes(all(p[i]), all(l))){
        if(id==-2){
          id = i;
        }else{
          id = -3;
        }
      }
    }
    cout << max(-1ll, id+1) << endl;
  }
}

Measured memory_bytes: 3184