akhauriyash/Code-Regression huggingface dataset:
def sol():
    N = int(input())
    D = 0

    for d in range(1, int((2 * N)**0.5) + 100):
        if d * (d - 1) == 2 * N:
            D = d
            break

    if D == 0:
        print('No')
        return

    print('Yes')
    mx = 1
    ans = []
    for d in range(D):
        line = []
        for _ in range(D - d - 1):
            line.append(mx)
            mx += 1
        ans.append(line)
    for i in range(D):
        line = ans[i]
        for j in range(i):
            line.append(ans[j][-i])
    print(len(ans))
    for a in ans:
        print(len(a), end=' ')
        print(*a)

sol()

Measured memory_bytes: 9296
#include <iostream>
#include <stdio.h>

using namespace std;

void q54() {
	int a, b, n;
	for (; cin >> a >> b >> n;) {
		int ans = 0;
		a = a%b;
		for (int i = 0; i < n; i++) {
			ans += (int)(a * 10 / b);
			a = (a * 10) % b;
		}
		cout << ans << endl;
	}
}
int main() {
	q54();
	return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n;
int a[maxn];
vector<long long> acc_sum(maxn,0),acc_xor(maxn,0);
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		acc_sum[i+1]=acc_sum[i]+a[i];
		acc_xor[i+1]=acc_xor[i]^a[i];
	}
	int l=1;
	long long res=0;
	for(int r=1;r<=n;r++)
	{
		for(;(acc_sum[r]-acc_sum[l-1])!=(acc_xor[r]^acc_xor[l-1]);l++);
		res+=r-l+1;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <limits>

#define pf printf
// #define DEBUG true
#define DEBUG false
#define ifd if(DEBUG)
#define FOR(i,ii,n) for(int i=ii; i<n; i++)
#define FORREV(i,ii,n) for(int i=n-1; i>=ii; i--)
#define INF ((ll)1e15)

using namespace std;
typedef long long ll;

ll const NMAX = 3000000;
ll mod = 998244353;
ll fact[NMAX];
ll finv[NMAX];
ll comb(ll n,ll a){
	return fact[n] * finv[a] % mod * finv[n-a] % mod;
}
ll pow(ll a,ll n){
	ll prd = 1;
	ll exp = a;
	while(n > 0){
		if((n&1)==1){
			prd *= exp;
			prd %= mod;
		}
		exp *= exp;
		exp %= mod;
		n >>= 1;
	}
	return prd;
}

ll gcd(ll a,ll b){
	if(a<b){
		ll tmp = b;
		b = a;
		a = tmp;
	}
	ll r = a % b;
	if(r==0) return b;
	return gcd(b,r);
}
ll lcm(ll a,ll b){
	return a*b/gcd(a,b);
}

int main(){
	ll N,A,B,K;
	cin >> N >> A >> B >> K;
	// init
	fact[0] = 1;
	finv[0] = 1;
	FOR(i,1,N+1){
		fact[i] = fact[i-1] * i % mod;
		finv[i] = pow(fact[i], mod-2);
	}
	FOR(i,0,10){
		// ifd pf("fact[%d]=%lld\n",i,fact[i]);
		// ifd pf("finv[%d]=%lld\n",i,finv[i]);
	}
	ll cnt = 0;
	ll lcm_ = lcm(A,B);
	FOR(i,0,B){
		ll r = K-A*i;
		ifd if(i%100==0) pf("r = %lld\n", r);
		if(r < 0)
			break;
		if(r % B == 0){
			ifd pf("one solution found : a = %lld, b = %lld\n", i, r/B);
			// found a solution
			int j = i;
			while(K-A*j >= 0 && j <= N){
				// ifd pf("solution found : A, a = %lld, %lld, B, b = %lld, %lld, K = %lld\n", A, a, B, b, K);
				ll b = (K-A*j)/B;
				if(b <= N){
					cnt += comb(N,j) * comb(N,b) % mod;
					cnt %= mod;
				}
				j += lcm_/A;
			}
			break;
		}
	}
	cout << cnt;
}


Measured memory_bytes: 8448
#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>;

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    for (int i = 0; i < n; i++)
    {
        if (i == n-1 && p[i] == i + 1) {
            swap(p[i], p[i-1]);
            cnt++;
        }
        else if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            cnt++;
        }

    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main(void)
{
	long n,tai[2],tate,yoko;
	int m,cal[1000],c=0;
	int i,j;
	scanf("%d %d", &n, &m);
	for (i = 0;i < m;i++)
	{
		scanf("%d %d", &tai[1], &tai[0]);
		if (tai[0] < n - tai[0]+1)
		{
			tate = tai[0];
		}
		else
		{
			tate = n - tai[0]+1;
		}
		if (tai[1] < n - tai[1]+1)
		{
			yoko = tai[1];
		}
		else
		{
			yoko = n - tai[1]+1;
		}
		if (tate < yoko)
		{
			for (j = 1;j <= 3;j++)
			{
				if ((tate - j) % 3 == 0)
				{
					cal[c]=j;
					c++;
					break;
				}
			}
		}
		else
		{
			for (j = 1;j <= 3;j++)
			{
				if ((yoko - j) % 3 == 0)
				{
					cal[c] = j;
					c++;
					break;
				}
			}
		}
	}
	for (i = 0;i < m;i++)
	{
		printf("%d\n", cal[i]);
	}
	return 0;
}

Measured memory_bytes: 2708
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

	int n;
	cin >> n;
	vector<pair<int, int>> coords(n);
	for (int i = 0; i < n; ++i) cin >> coords[i].first >> coords[i].second;

	int res = n;
	for (int a = 0; a < n; ++a) {
		for (int b = a+1; b < n; ++b) {
			int dx = coords[a].first - coords[b].first;
			int dy = coords[a].second - coords[b].second;

			int off = n;
			for (int i = 0; i < n; ++i) {
				bool pre = false;
				for (int j = 0; j < n; ++j) {
					if (coords[j].first + dx == coords[i].first && coords[j].second + dy == coords[i].second) {
						pre = true;
					}
				}
				if (pre) --off;
			}
			res = min(res, off);
		}
	}
	cout << res << '\n';
}


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

ll mod = 1000000007;
#define NMAX 1000010
ll fac[NMAX];
ll inv[NMAX];

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

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

void mae_nck(){
    fac[0] = 1;
    inv[0] = 1;
    fac[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < NMAX; i++){
        fac[i] = (fac[i-1] * i)%mod;
        inv[i] = (inv[i-1] * mod_inv(i, mod))%mod;
    }
}

ll mod_nck(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k == 0 || k == n) return 1;
    ll ret = ((fac[n] * inv[k])%mod * inv[n-k])%mod;
    return ret;
}

int main() {
    mae_nck();
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    auto f = [&](ll i) {
        ll nCi = mod_nck(n, i);
        ll mPi = (fac[m] * inv[m-i]) % mod;
        ll m_iPn_i = (fac[m-i] * inv[m-n]) % mod;
        ll res = nCi * mPi % mod * mod_pow(m_iPn_i, 2LL, mod) % mod;
        return res;
    };
    rep(i, 0, n+1) {
        if(i % 2) ans -= f(i);
        else ans += f(i);
        ans %= mod;
    } 
    cout << (ans+mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 19224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const ll INF=100000000;
const ll max_x=100000;
ll x;
ll m[6],a[6];

ll dp[max_x+1];

void solve(){
    rep(i,6){
        a[i]=100+i;
    }
    fill(m,m+6,INF);
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<6;i++){
        for(int j=0;j<=x;j++){
            if(dp[j]>=0){
                dp[j]=m[i];
            }else if(j<a[i]||dp[j-a[i]]<=0){
                dp[j]=-1;
            }else{
                dp[j]=dp[j-a[i]]-1;
            }
        }
    }
    if(dp[x]>=0) cout<<1;
    else cout<<0;
}

int main(){
    cin>>x;
    solve();
}

Measured memory_bytes: 1024
h,w,k=map(int,input().split())
a=[[]*w for ii in range(h)]
for ii in range(h):
  a[ii][:]=list(input())
"""
for ii in range(h):
  print(a[ii])
"""
def func(a,bmh,bmw):
  rr=0
  for ii in range(h):
    for jj in range(w):
      if rr>k:
        return(0)
      #print(bin((2**ii)&bmh),bin((2**ii)&bmw))
      if ((2**ii)&bmh)!=0:
        if ((2**jj)&bmw)!=0:
          #print(ii,jj,a[ii][jj],a[ii][jj]=="#",rr)
          if a[ii][jj]=="#":
            rr+=1
  #print(rr,k)
  if rr==k:
    return(1)
  else:
    return(0)
  
bh=2**h
bw=2**w
r=0
#print(bh,bw)
for ii in range(bh):
  for jj in range(bw):
    #print(ii,jj,r)
    r+=func(a,ii,jj)
print(r)


Measured memory_bytes: 9232
// https://atcoder.jp/contests/abc082/tasks/abc082_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, ans = 0;
    cin >> n;
    map<int, int> mp;
    REP(i, n) {
        cin >> t;
        mp[t]++;
    }
    for (auto &x : mp) {
        if (x.second >= x.first) {
            ans += x.second - x.first;
        } else {
            ans += x.second;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	h = readline() |> split |> parseMap
	k = 0
	q = 0
	for i in 2:n
		if h[i-1]>=h[i]
			q += 1
		else
			k = max(k,q)
	      q = 0
		end
	end
	k = max(k,q)
	println(k)
end

main()

Measured memory_bytes: 166796
n = gets.to_i
p = []
n.times{|i|
  p[i] = gets.split.map(&:to_f)
}
p << p[0]
p << p[1]

n.times{|i|
  a = [p[i+1][0]-p[i][0], p[i+1][1]-p[i][1]]
  b = [p[i+2][0]-p[i][0], p[i+2][1]-p[i][1]]
  if a[0]*b[1]-a[1]*b[0] < 0
    puts 0
    exit
  end
}
puts 1

Measured memory_bytes: 8636
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    a, b, c = A[i], B[i], C[i]
    
    
    if a == b and b == c and c == a:
        ()
    elif a == b or b == c or c == a:
        ans += 1
    else:
        ans += 2
print(ans)
        



Measured memory_bytes: 3060
#include<ios>
#include<iostream>
using namespace std;
int n,a[11][11];
main()
{
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
        for(int i=0;i<n;i++)
        {
            int sum=0;
            for(int j=0;j<n;j++)sum+=a[i][j];
            a[i][n]=sum;
        }
        for(int j=0;j<=n;j++)
        {
            int sum=0;
            for(int i=0;i<n;i++)sum+=a[i][j];
            a[n][j]=sum;
        }
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)printf("%5d",a[i][j]);
            puts("");
        }
    }
}



Measured memory_bytes: 3208
#include <stdio.h>
#include <math.h>
typedef unsigned long long ULL;

int F(ULL a, ULL b);

int main(){
    ULL a, b, n, ans;
    scanf("%llu", &n);
    ans = n;

    for(int i = 1; i <= sqrt(n) + 1; i++){
        if(n % i == 0){
            ans = ((ans < F(i, n / i)) ? ans : F(i, n / i));
        }
    }
    printf("%llu\n", ans);
    return 0;
}

int F(ULL a, ULL b){
    int ret = 0;
    for(ULL i = ((a > b) ? a : b); i > 0; i /= 10){
        ret++;
    }
    return ret;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;



int main(){
    long long int n,k=0,ans=0;
    cin>>n;
    for(long long int i=1;i*i<=n;i++){
        if(n%i==0){
            k=n/i;
        }
    }
    for(int i=1;i<10000;i++){
        if(k<10){
            ans=i;
            break;
        }
        k=k/10;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : F - Playing Tag on Tree
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n,u,v;
vi g[N];
int du[N], dv[N];

void dfs(int u, int depth, int par, int *d){
    d[u] = depth;
    for(int i : g[u]){
        if(i != par) dfs(i,depth+1,u,d);
    }
}

void solve(){
    cin>>n>>u>>v;
    for(int i=0;i<n-1;i++){
        int u,v; cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(u,0,0,du);
    dfs(v,0,0,dv);
    int ans = du[v]/2;
    for(int i=1;i<=n;i++){
        if(du[i] < dv[i]) ans = max(ans,dv[i]-1);
    }
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 15904
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let s = iterator.next().unwrap();

    if a >= 3200 {
        return s.to_string();
    }

    return "red".to_string();
}


Measured memory_bytes: 2052
A,B,Q = map(int,input().split())
s,t,x = [],[],[]
for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    x.append(int(input()))


import bisect

mas = max(s)
mis = min(s)
mat = max(t)
mit = min(t)

for i in range(Q):
    ans = 10**20

    if mis <= x[i]:
        s_index = bisect.bisect_left(s,x[i])
        s_index -= 1
        if mat >= s[s_index]:
            t_index = bisect.bisect_left(t,s[s_index])
            ans = min(ans, abs(x[i] - s[s_index]) + abs(t[t_index] - s[s_index]))

    if mit <= x[i]:
        t_index = bisect.bisect_left(t,x[i])
        t_index -= 1
        if mas >= t[t_index]:
            s_index = bisect.bisect_left(s,t[t_index])
            ans = min(ans, abs(x[i] - t[t_index]) + abs(t[t_index] - s[s_index]))

    if mas >= x[i]:
        s_index = bisect.bisect_left(s,x[i])
        if mit <= s[s_index]:
            t_index = bisect.bisect_left(t,s[s_index])
            t_index -= 1
            ans = min(ans, abs(x[i] - s[s_index]) + abs(t[t_index] - s[s_index]))

    if mat >= x[i]:
        t_index = bisect.bisect_left(t,x[i])
        if mis <= t[t_index]:
            s_index = bisect.bisect_left(s,t[t_index])
            s_index -= 1
            ans = min(ans, abs(x[i] - t[t_index]) + abs(t[t_index] - s[s_index]))

    if mas >= x[i] and mat >= x[i]:
        s_index = bisect.bisect_left(s,x[i])
        t_index = bisect.bisect_left(t,x[i])
        ans = min(ans,abs(x[i] - max(s[s_index],t[t_index])))

    if mis <= x[i] and mit <= x[i]:
        s_index = bisect.bisect_left(s,x[i])
        s_index -= 1
        t_index = bisect.bisect_left(t,x[i])
        t_index -= 1
        ans = min(ans,abs(x[i] - min(s[s_index],t[t_index])))
    print(ans)


Measured memory_bytes: 16192
#include<bits/stdc++.h>
using namespace std;
long long int a[100000007];
int main()
{
    long long n,i,s=0,j;
    cin>>n;
    for(i=0,j=1;j<=n;i++,j++)
    {
        a[i]=j;
    }
    for(i=0;i<n;i++)
    {
        if(a[i]%3==0&&a[i]%5==0)
            a[i]=0;
        else if(a[i]%3==0)
            a[i]=0;
        else if(a[i]%5==0)
            a[i]=0;
    }
    for(i=0;i<n;i++)
    {
        s=s+a[i];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 11424
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,k;
    cin>>n>>k;
    lli a[10000]={0},c,i;
    
    while(k--)
    {
        lli d;
        cin>>d;
        
        for(i=0;i<d;i++)
        {
            cin>>c;
            a[c]++;
        }
    }
    
    lli ans=0;
    for(i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3720
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vi a(n, INT_MAX);
    int m = sqrt(n);
    vi b((n+m-1)/m, INT_MAX);
    //bool h = false;
    auto update = [&](int i, int x) {
        a[i] = x;
        b[i/m] = INT_MAX;
        for(int k = i/m*m; k != n and k != (i/m+1)*m; k++) {
            chmin(b[i/m], a[k]);
        }
    };
    auto find = [&](int i, int j) {
        int res = INT_MAX;
        if(i/m == j/m) {
            for(int k = i; k < j; k++) {
                chmin(res, a[k]);
            }
        } else {
            for(int &k = i; k%m; k++) {
                chmin(res, a[k]);
            }
            for(int &k = j; k%m; k--) {
                chmin(res, a[k-1]);
            }
            for(int k = i; k != j; k += m) {
                //if(h) cout << i << ' ' << j << ' ' << res << endl;
                chmin(res, b[k/m]);
            }
        }
        return res;
    };

    while(q--) {
        int t, x, y;
        cin >> t >> x >> y;
        
        if(t) {
            cout << find(x, y+1) << '\n';
        } else {
            update(x, y);
            //cout << endl;
        }
    }
}
/*

2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
8
2147483647
2147483647
2147483647
8
2147483647
2147483647
8
2147483647
8
8
8
2147483647
2147483647
8
8
8
8
8
8
8
8
8
2147483647
8
8
8
8
8
8
8
8
8
3
8
8
3
8
3
3
8
8
18
3
8
8
3
8
3
3
8
8
18
28
8
8
8
8
8
8
8
88
18
28
8
18
18
8
18
8
*/


Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <cstdio>
#include <unordered_map>
#include <vector>
#define task ""
using namespace std;
using ll = long long;
using ld = long double;

const int N = 5e3 + 2;
int h1, m1, h2, m2, k;

void Read(){
	cin >> h1 >> m1 >> h2 >> m2 >> k;
}

void Solve(){
	int t1 = h1 * 60 + m1, t2 = h2 * 60 + m2;
	if(t1 >= t2)
		t2 += 60 * 24;
	cout << (t2 - t1) - k;
}

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen(task".INP", "r", stdin);
//	freopen(task".OUT", "w", stdout);
	Read();
	Solve();
}


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

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

int p[N];
int q[N];

for(int i = 0; i<N;i++) {
    cin >> p[i];
    q[i] = p[i];
}
int count =0;
sort(q, q + N);

for (int i=0; i < N-1; i++) {
  if(q[i] - p[i] != 0) count++; 
} 

if (count < 3) cout << "YES" << endl;
else  cout << "NO" << endl;


  return 0;
}

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

void descending()
{
    int mountain;
    int count[10];
    
    for(int i=0; i<10; i++)
    {
        cin>>mountain;
        count[i]= mountain;
    }
    
     for (int i=0; i<9; i++)    
    {
          for(int j=(i+1); j<10; j++)   
         {
                if (count[i] < count[j])          
               {
                        int temp = count[i];          //swap
                        count[i] = count[j];
                        count[j] = temp;
               }
          }
     }
    
    for(int i=0; i<3; i++)
    {
        cout<<count[i]<<endl;
    }
    
    return;
}


int main(){

    descending();
    return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
time = N // 7
bl = False

for x in range(time+1):
    y = N - x * 7
    if y % 4 == 0:
        bl = True; break

print('Yes' if bl else 'No')


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

using namespace std ;

int n, T ;

const int MAXN = 100010 ;

int a[MAXN] ;

int main() {
#ifdef YJQ_LOCAL
		freopen(".in", "r", stdin) ;
#endif
		scanf("%d%d", &n, &T) ; 
		for (int i = 1; i <= n; i ++) scanf("%d", &a[i]) ; 
		int ans = 0, curmx = 0, curmin = a[1]; 
		for (int i = 2; i <= n; i ++) {
				if (a[i] > curmin) {
						if (a[i] - curmin > curmx) curmx = a[i] - curmin, ans = 1;  
						else if (a[i] - curmin == curmx) ans ++ ; 
				}
				else curmin = a[i] ; 
		}
		printf("%d\n", ans) ;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if(i % 2 == 0 && a % 2) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;
const int PLUS = 8000;
vector <int> dx, dy;
int p[8005];
bool visx[3][16005], visy[3][16005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = (int) s.length();

    int kol = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'T') kol++;
        else
        {
            if (kol % 2 == 0)
                p[i] = 1;
            else
                p[i] = 2;
        }
    }

    int dl = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] == 1) dl++;
        else
        {
            if (dl == 0) continue;
            dx.push_back(dl);
            dl = 0;
        }
    }
    if (dl > 0) dx.push_back(dl);
    dl = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] == 2) dl++;
        else
        {
            if (dl == 0) continue;
            dy.push_back(dl);
            dl = 0;
        }
    }
    if (dl > 0) dy.push_back(dl);

    visx[0][PLUS] = true;
    for (int i = 0; i < (int) dx.size(); i++)
    {
        for (int j = 0; j <= 2 * PLUS; j++)
        {
            if (i == 0 && s[i] == 'F')
            {
                if (visx[0][j] && j + dx[i] <= 2 * PLUS) visx[1][j + dx[i]] = true;
            }
            else
            {
                if (visx[0][j])
                {
                    if (j + dx[i] <= 2 * PLUS) visx[1][j + dx[i]] = true;
                    if (j - dx[i] >= 0) visx[1][j - dx[i]] = true;
                }
            }
        }
        for (int j = 0; j <= 2 * PLUS; j++)
        {
            visx[0][j] = visx[1][j];
            visx[1][j] = false;
        }
    }
    visy[0][PLUS] = true;
    for (int i = 0; i < (int) dy.size(); i++)
    {
        for (int j = 0; j <= 2 * PLUS; j++)
            if (visy[0][j])
            {
                if (j + dy[i] <= 2 * PLUS) visy[1][j + dy[i]] = true;
                if (j - dy[i] >= 0) visy[1][j - dy[i]] = true;
            }
        for (int j = 0; j <= 2 * PLUS; j++)
        {
            visy[0][j] = visy[1][j];
            visy[1][j] = false;
        }
    }
    if (visx[0][x + PLUS] && visy[0][y + PLUS]) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<long long int, long long int> P;
typedef pair<P, long long int> Q;

int main() {
    long long int n;
    cin >> n;
    
    vector< vector<P> > mp(n);

    long long int u, v, w;
    for (long long int i = 0; i < n-1; i++) {
        cin >> u >> v >> w;
        mp[u-1].push_back(P(v-1, w));
        mp[v-1].push_back(P(u-1, w));
    }

    vector<long long int> col(n, -1);
    col[0] = 0;
    queue<long long int> q;
    q.push(0);
    while(!q.empty()) {
        long long int p = q.front();
        //cout << p << endl;
        q.pop();
        for (long long int i = 0; i < mp[p].size(); i++) {
            P pp = mp[p][i];
            if (col[pp.first] == -1) {
                if (pp.second % 2 == 0) {
                    col[pp.first] = col[p];
                } else {
                    col[pp.first] = 1-col[p];
                }
                q.push(pp.first);
            }
        }
    }
    for (long long int i = 0; i < n; i++) {
        cout << col[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
typedef long long ll; typedef long double db;
const int N = 3e5 + 5, M = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  puts(n < 30 ? "No" : "Yes");
}


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

int main(void) {
  int r, g, b;
  cin >> r >> g >> b;
  
  if ((10 * g + b) % 4 == 0)
    cout << "YES"  << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=200;
int n;
int b[N];
int a[N];
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)cin>>b[i];
	a[1]=b[1];
	for(int i=2;i<n;i++)a[i]=min(b[i],b[i-1]);
	a[n]=b[n-1];
	int ans=0;
	for(int i=1;i<=n;i++)ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N = 8
H, W = 4, 4
X, Y = 0, 1

def dfs(board, position, depth)
  return 1 if depth == N
  for y in 0...H do
    for x in 0...W do
      break unless board[x][y]
    end
    break unless board[x][y]
  end
  count = 0
  position.each do |p|
    nx, ny = x+p[X], y+p[Y]
    next if nx < 0 || W <= nx || ny < 0 || H <= ny
    next if board[nx][ny]
    b = board.map(&:dup)
    b[x][y] = b[nx][ny] = true
    count += dfs(b, position, depth+1)
  end
  count
end

while (line=gets).include?(" ") do
  position = Array.new
  line.split.map(&:to_i).each_slice(2) do |x, y|
    position.push([x, y])
  end
  p dfs(Array.new(W){Array.new(H)}, position, 0)
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 18;

void solve() {
    long double a,b,c;
    cin>>a>>b>>c;
    if ((long double)sqrt(a/c)+(long double)sqrt(b/c) < (long double)1.00) {
        cout<<"Yes";
    }
    else cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,ptr,res,a[100000];
int main(void){
  scanf("%d",&n);
  for(int loop=0;loop<n;loop++){
    scanf("%d",&a[loop]);
  }
  sort(a,a+n);
  while(ptr<n){
    int cc=a[ptr],f=0;
    while(ptr<n && a[ptr]==cc){
      f++;
      ptr++;
    }
    res+=f%2;
  }
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
    
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    double res=double(arr[0]+arr[1]);
    res=res/2.00000;
    for(ll i=2;i<n;i++) 
    {
        res=(res+(double)arr[i])/2.00000;
    }
    cout<<fixed<<setprecision(8)<<res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
map<ll,ll> fact(ll m){//素因数-指数のmapを返す
    map<ll,ll> ret;
    for(ll i=2;i*i<=m;i++){
        if(m%i) continue;
        else{
            ll cnt=0;
            while(m%i==0){
                m/=i;
                cnt++;
            }
            ret[i]=cnt;
        }
    }
    if(m>1) ret[m]=1;
    return ret;
}
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    For(i,0,n) cin >> vec[i];
    bool flagp = true, flags = true;
    int g = vec[0];
    for(auto i:vec) g = gcd(g, i);
    flags = (g == 1);
    set<int> st;
    for(auto i:vec){
        auto mp = fact(i);
        for(auto pr:mp){
            if(st.count(pr.first) != 0){
                flagp = false;
                goto end;
            }
            else{
                st.insert(pr.first);
            }
        }
    }
    end:;
    if(flagp) cout << "pairwise coprime" << endl;
    else if(flags) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}


Measured memory_bytes: 7308
from collections import deque
from itertools import product

N = int(input())
dig = len(str(N))
s = ['3','5','7']
d = deque([''.join(x) for x in product(s,repeat=3)])
ans = 0
while d:
    temp = d.popleft()
    if len(temp) > dig:
        break
    else:
        if int(temp) <= N:
            if len(set(temp)) == 3:
                ans += 1
        d.append(''.join(('3',temp)))
        d.append(''.join(('5',temp)))
        d.append(''.join(('7',temp)))
print(ans)

Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 10100;

int a[maxn],b[maxn],n;
ll sa,sb,k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        sa+=a[i];
    }
    for (int i=1;i<=n;i++) {
        cin>>b[i];
        sb+=b[i];
    }
    if (sa>sb) cout<<"No";
    else {
        k = sb-sa;
        ll cnt=0;
        for (int i=1;i<=n;i++)
            if (a[i] < b[i]) cnt+=(b[i]-a[i])/2 + (b[i]-a[i])%2;
        if (cnt <= k) cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue

using namespace std;

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

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int N,x;
  pq<int> que;
  long ans;
  cin>>N;

  for (int i = 0; i < N; i++) {
    cin>>x;
    que.push(x);
  }
  
  while(!que.empty()){
    ans+=que.top();
    if(que.empty()) break;
    que.pop();
    if(que.empty()) break;
    ans-=que.top();
    if(que.empty()) break;
    que.pop();
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Count[86401], h, m, s;

int Solve(){
  fill(Count, Count + 86400, 0);
  for (int i = 0; i < N; i++){
    scanf("%d:%d:%d", &h, &m, &s);
    int now = h * 3600 + m * 60 + s;
    Count[now]++;
    scanf("%d:%d:%d", &h, &m, &s);
    now = h * 3600 + m * 60 + s;
    Count[now]--;
  }

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

  return 0;
}

int main(){
  while (cin >> N){
    if (N == 0) return 0;
    else Solve();
  }

  return 0;
}



Measured memory_bytes: 3540
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
using namespace std;

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

int main()
{
    int A, B, C, D, E;
    cin >> A >> B >> C >>D >> E;

    int onedig[5] ={0};
    int Time[5] = {0};
    int Syouhin[5];

    Syouhin[0] = A;
    Syouhin[1] = B;
    Syouhin[2] = C;
    Syouhin[3] = D;
    Syouhin[4] = E;

    REP(index, 5)
    {
        onedig[index] = Syouhin[index] % 10;
        if (onedig[index] != 0)
        {
            Time[index] = Syouhin[index] + (10 - onedig[index]);
        }
        else
        {
            Time[index] = Syouhin[index];
        }
        
        
    }

    int min_onedig = 10;
    int index_min_onedig;
    REP(index, 5)
    {
        if(min_onedig > onedig[index] and onedig[index] != 0)
        {
            min_onedig = onedig[index];
            index_min_onedig = index;
        }
    }

    int ans = 0;

    REP(index, 5)
    {
        if (index != index_min_onedig)
        {
            ans += Time[index];
        }
        else
        {
            if (onedig[index] != 0)
            {
                ans += Time[index] + onedig[index] - 10;
            }
            else
            {
                ans += Time[index];
            }
            
        }
        
    };

    cout << ans << endl;
}

Measured memory_bytes: 256
/**************************************************************
	File name: E.cpp
	Author: huhao
	Email: 826538400@qq.com
	Create time: 2019/8/17 下午9:24:40
**************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=200010;
int n,k,f[N];
int cmp(char *a,char *b,int k)//[a<b]
{
	fr(i,0,k-1)
		if(*(a+i)!=*(b+i))
			return *(a+i)<*(b+i);
	return 0;
}
char s[N];
int main()
{
	n=read();
	k=read();
	scanf("%s",s+1);
	fr(i,1,n)
		s[n+n-i+1]=s[i];
	if(k==1)
	{
		int ans=1;
		fr(i,2,n+1)
			if(cmp(s+i,s+ans,n))
				ans=i;
		fr(i,0,n-1)
			putchar(s[ans+i]);
		putchar(10);
		return 0;
	}
	char m='z';
	int M=0;
	int p=0;
	fr(i,1,n+n)
		m=min(m,s[i]);
	fr(i,1,n+n)
		if(s[i]==m)
			M=max(M,f[i]=f[i-1]+1);
	int _m=M;
	fr(i,2,k)
	{
		M=M*2;
		if(M>=n)
		{
			fr(i,1,n)
				putchar(m);
			putchar(10);
			return 0;
		}
	}
	fr(i,n,n+n)
		if(f[i]==_m)
		{
			if(!p||cmp(s+n+n+1-(i-_m),s+p,n-M))
				p=n+n+1-(i-_m);
		}
	fr(i,1,M)
		putchar(m);
	fr(i,1,n-M)
		putchar(s[p+i-1]);
	putchar(10);
//	fr(i,1,n+n)
//		printf("%d%c",f[i],i==n+n?'\n':' ');
//	printf("%d %d\n",M,p);
	return 0;
}

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

bool canAdd(vector<vector<int>>& edge) {
	using P = pair<int,int>;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(P(0, 0));
	vector<int> dp(edge.size(), 1e9+7), work(edge.size(), -1);

	while (q.size()) {
		auto p = q.top();
		q.pop();
		auto cost = p.first;
		auto now = p.second;

		if (dp[now] < cost) continue;
		dp[now] = cost;

		for (int i = 0; i < edge.size(); i++) {
			if (edge[now][i] && cost + 1 < dp[i]) {
				q.push(P(cost + edge[now][i], i));
				dp[i] = cost + edge[now][i];
				work[i] = now;
			}
		}
	}

	if (work[edge.size()-1] >= 0) {
		auto now = edge.size() - 1;
		while (now) {
			edge[now][work[now]] = true;
			edge[work[now]][now] = false;
			now = work[now];
		}

		return true;
	}

	return false;
}

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

	vector<int> a(N), b(N), c(N), d(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		a[i]++;
		b[i]++;
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> d[i];
		c[i]++;
		d[i]++;
	}

	vector<vector<int>> edge(2*N+2,vector<int>(2*N+2));
	for (int i = 1; i <= N; i++) {
		edge[0][i] = true;
		edge[N+i][2*N+1] = true;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				edge[i+1][N+j+1] = true;
			}
		}
	}

	int count = 0;
	auto used = vector<int>(edge.size());
	while (canAdd(edge)) {
		count++;
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;

int main(){
    int len; cin>>len;
    
    vector<int> arr(len);
    for(int& i:arr) cin>>i;
    
    vector<int> dp(len, INF);

    dp[0] = 0;
    
    for(int i=0;i<len;i++){
        for( int j:{i+1,i+2}){
            if( j<len ) dp[j] = min(dp[j],dp[i] + abs(arr[j]-arr[i]));
        }
    }
    
    cout<<dp[len-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import heapq


def dijkstra(s):
    dist[s] = 0
    que = []
    heapq.heappush(que, (0, s))
    while len(que) != 0:
        p = heapq.heappop(que)
        v = p[1]
        if (dist[v] < p[0]):
            continue
        for e in graph[v]:
            if dist[e[0]] > dist[v] + e[1]:
                dist[e[0]] = dist[v] + e[1]
                prev[e[0]] = v
                heapq.heappush(que, (dist[e[0]], e[0]))


def get_path(t):
    path = []
    while t != -1:
        path.append(t)
        t = prev[t]
    path = path[::-1]
    return path


N, W = map(int, input().split())
graph = [[] for i in range(N)]
edges = {}
for i in range(W):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    graph[x].append((y, z))
    graph[y].append((x, z))
    edges[(x, y)] = True

for st in range(N):
    dist = [float("inf")] * N
    prev = [-1] * N
    dijkstra(st)
    for i in range(N):
        gp = get_path(i)
        for i in range(1, len(gp)):
            edges[(gp[i-1], gp[i])] = False

print(sum(edges.values()))


Measured memory_bytes: 9320
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p =   998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W,R;
LL vals[SIZE], answer = zero;
int A[SIZE],B[SIZE];string s[SIZE];
Vpr edges[SIZE];
LL dist[SIZE];
LL solve(){
	cin >> N >>M;
	REP(i,M){
		LL a,b,c;
		cin >> a >> b >> c;
		edges[a].pb(b,c);
	}
	PQ qu;
	EFOR(i,2,N) dist[i]=INF;
	EFOR(i,1,N){
		while(!qu.empty()){
			if(qu.top().second<i) qu.pop();
			else{
				dist[i]=qu.top().first;
				break;
			}
		}
		for(auto next:edges[i]){
			qu.emplace(dist[i]+next.second,next.first);
		}

	}
	if(dist[N]>=INF) return -1;
	return dist[N];
}

signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	cout << solve() << endl;
 
 
	//cin >> N;
	return 0;
 
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n;
	cin >> n;
	
	for (int i = 0; i <= n; i += 4) {
		if ((n - i) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import math
k = int(input())
box = []
for i in range(1,k+1):
  for j in range(1,k+1):
    gap = math.gcd(i,j)
    if gap == 1:
      box.append(1*k)
    else:
      for l in range(1,k+1):
        gap2 = math.gcd(gap,l)
        box.append(gap2)        
print(sum(box))


Measured memory_bytes: 33320
import java.util.Scanner;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = Integer.parseInt(sc.next());
    int[] array = new int[size];
    for (int i = 0; i < size; i++) {
      array[i] = Integer.parseInt(sc.next());
    }
    int p = 0;
    int center = array[size-1];
    Partition(array, 0, size-1);
  }

  public static int Partition(int[] array, int p, int r) {
    int x = array[r];
    int i = p - 1;
    int tmp;
    for (int j = p; j < r; j++) {
      if (array[j] <= x) {
        tmp = array[++i];
        array[i] = array[j];
        array[j] = tmp;
      }
    }
    tmp = array[i + 1];
    array[i + 1] = array[r];
    array[r] = tmp;

    int size = array.length;
    for (int index = 0; index < size; index++) {
      if (index == i + 1) {
        System.out.print("[" + array[index] + "] ");
      } else if (index == size - 1) {
        System.out.println(array[index]);
      } else {
        System.out.print(array[index] + " ");
      }
    }

    return i + 1;
  }
}



Measured memory_bytes: 70104
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(l+1)+(j))

void run(void){
  int n,ma,mb;
  scanf("%d%d%d",&n,&ma,&mb);
  int l=400;
  int *dp=(int *)malloc(sizeof(int)*(l+1)*(l+1));
  const int inf=1000000;
  int i,j;
  for(i=0;i<=l;i++) for(j=0;j<=l;j++) dp[POS(i,j)]=inf;
  dp[POS(0,0)]=0;
  while(n--){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    for(i=l;i>=a;i--){
      for(j=l;j>=b;j--){
	if(dp[POS(i-a,j-b)]==inf) continue;
	dp[POS(i,j)]=MIN(dp[POS(i,j)],dp[POS(i-a,j-b)]+c);
      }
    }
  }
  int min=-1;
  for(i=1;i*ma<=l && i*mb<=l;i++){
    if(dp[POS(i*ma,i*mb)]==inf) continue;
    min=(min==-1?dp[POS(i*ma,i*mb)]:MIN(min,dp[POS(i*ma,i*mb)]));
  }
  printf("%d\n",min);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 768
import sys

n = int(input())
p = list(map(int, input().split()))

for i in range(n - 1):
    if p[i] > p[i + 1]:
        break
    if i == n - 2:
        print("YES")
        sys.exit()

for i in range(n):
    for j in range(i + 1, n):
        q = list(p)
        tmp = q[i]
        q[i] = q[j]
        q[j] = tmp
        for k in range(n - 1):
            if q[k] > q[k + 1]:
                break
            if k == n - 2:
                print("YES")
                sys.exit()

print("NO")


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n, k; cin >> n >> k;
	vi x(n);
	rep(i, n) {
		cin >> x.at(i);
	}
	int ans = 0;
	rep(i, n) {
		ans += min(x.at(i), k - x.at(i));
	}
	ans *= 2;
	cout << ans << endl;
	return 0;
}

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

std::string CheckWordScaler(std::string,std::string);

int main(int argc, char const *argv[])
{

    std::string word,otherWord;
    std::cin >> word >> otherWord;

    std::cout << CheckWordScaler(word,otherWord) << '\n';

    return 0;
}

std::string CheckWordScaler(std::string word,std::string otherWord)
{
    int wordInt = std::stoi(word,nullptr,16);
    int otherWordInt = std::stoi(otherWord,nullptr,16);

    if(wordInt == otherWordInt)
        return "=";
    else if(wordInt < otherWordInt)
        return "<";
    return ">";
}


Measured memory_bytes: 256