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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int a=1145141919,z=-1145141919;
		String in=s.next();
		for(int i=0;i<in.length();i++) {
			switch(in.charAt(i)){
			case 'A':
				a=Math.min(a,i);
				break;
			case 'Z':
				z=Math.max(z,i);
				break;
			}
		}
		System.out.println(z-a+1);
	}
}

Measured memory_bytes: 25812
#include<bits/stdc++.h>
using namespace std;
int n,q,answer;
int key;
vector<int> s(100005);

bool binarys(int KEY){
 int  left = 0;
 int  right = n;
 int  middle;

 while(left < right){
 middle = (left + right) / 2;

 if(s[middle] == KEY) return true;
 if(KEY > s[middle]) left = middle + 1;
 if(KEY < s[middle]) right  = middle ;
 }
 return 0;
}
int main(){
 scanf("%d",&n); 
 for(int i = 0;i < n;i++)scanf("%d",&s[i]);
 scanf("%d",&q);
 for(int i = 0;i < q;i++){
 scanf("%d",&key);
 if(binarys(key))  answer++; 
 };

 printf("%d\n",answer);
 return 0;
}



Measured memory_bytes: 3372
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

//const ll MOD_CONST = 1000000007;
const ll MOD_CONST = 998244353;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;

vector<int> to[200005];
ll dfs(int v) {
	ll res = 1;
	for (int u : to[v]) {
		res = (res * dfs(u))%MOD_CONST;
	}
	return res + 1;
}
int main() {
	int n;
	cin >> n;

	vector<pii> r(n);
	for (int i = 0; i < n; i++) {
		cin >> r[i].first >> r[i].second;
	}


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

	priority_queue<pii,vector<pii>,greater<pii>> pq;
	for (int i = n - 1; i >= 0; i--) {
		int x = r[i].first;
		int d = r[i].second;
		while (!pq.empty() && pq.top().first < x + d) {
			to[i].emplace_back(pq.top().second);
			pq.pop();
		}

		pq.push(make_pair(x,i));
	}

	ll ans = 1;
	while (!pq.empty()) {
		int v = pq.top().second;
		pq.pop();
		ans = (ans * dfs(v))%MOD_CONST;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 22144
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    int a,b,n;
    cin >> a >> b >> n;
    if(b>n){
    	int ans = floor((a*n)/b);
    	// I got it.. hihi
    	cout<<ans<<endl;
    }
    else if(b<=n) {
    	n=b-1;
    	int ans = floor((a*n)/b);
    	cout<<ans<<endl;
    }
    
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
char s[N][3];
int a[3], n;
int main() {
    scanf("%d%d%d%d", &n, &a[0], &a[1], &a[2]);
    for(int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    vector<char> ans;
    bool flag = true;
    for(int i = 0; i < n; i++) {
        int ta = s[i][0] - 'A', tb = s[i][1] - 'A';
        if(a[ta] > a[tb]) {
            ans.push_back(s[i][1]);
            a[tb]++, a[ta]--;
        }else if(a[tb] > a[ta]){
            ans.push_back(s[i][0]);
            a[ta]++, a[tb]--;
        }else {
            if(a[ta] == 0) {
                flag = false;
                break;
            }
            if(i + 1 >= n || s[i][0] == s[i + 1][0] || s[i][0] == s[i + 1][1]) {
                ans.push_back(s[i][0]);
                a[ta]++, a[tb]--;
            }else {
                ans.push_back(s[i][1]);
                a[tb]++, a[ta]--;
            }
        }
    }
    if(flag) {
        printf("Yes\n");
        for(int i = 0; i < n; i++) {
            printf("%c\n", ans[i]);
        }
    }else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

ll func(ll h)
{
    if(h==1)
        return 1;
    if(h==0)
        return 0;
    
    ll ans=func(h/2);
    return 1+2*ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll h;
    cin>>h;
    ll ans=0;
    cout<<func(h)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(ll i = 0; i < n; i++){cin >> a[i];}
using namespace std;
int main(){
    FAST
    ll a,b; cin >> a >> b;
    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 3616
from collections import deque
import sys
si = sys.stdin.readline


def BFS(g, s):
    d = 0
    dt = dict()
    visited = set()
    visited.add(s)
    Q = deque([s])

    while len(Q):
        d += 1
        Qs = len(Q)
        for _ in range(Qs):
            Qpop = Q.popleft()
            for node in g[Qpop]:
                if node not in visited:
                    Q.append(node)
                    visited.add(node)
                    dt[node] = d
    return dt


def main():
    l = [int(e) for e in si().split()]
    n, u, v = l[0], l[1], l[2]
    graph = [[] for _ in range(n+1)]
    for _ in range(n-1):
        l = [int(e) for e in si().split()]
        graph[l[0]].append(l[1])
        graph[l[1]].append(l[0])

    udt = BFS(graph, u)
    vdt = BFS(graph, v)
    udt[u], vdt[v] = 0, 0

    vdmax = 0
    for i in range(1, n+1):
        if (vdt[i]-udt[i]) > 0 and vdt[i] > vdmax:
            vdmax = vdt[i]
    print(vdmax-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51372
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define len(x) (int)x.length()
#define ac(x, i) get<i>(x)
#define trace(x) cerr << #x << ": " << x << "\n"
#define trav0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trav1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trap0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define trap1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define in insert
#define nl '\n'
#define ln cout << nl
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define pli pair<ll, int>
#define ff first
#define ss second
#define MOD 1000000007

const int infi = 1e9;
const ll infl = 1e18;

string to_string (const char& x) {
  string s(1, x);
  return s;
}

template <typename Map>
bool map_compare (Map const &lhs, Map const &rhs) {
  return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
}

const int N = 410;
ll dp[N][N][3];

int main() {
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  memset(dp, 0LL, sizeof(dp));
  int n;
  cin >> n;
  int a[n+1];
  for (int i = 1; i <= n ;i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    dp[i][i][2] = a[i];
    dp[i][i][1] = 0;
  }
  int diff = 1;
  while (diff <= n-1) {
    for (int i = 1; i <= n-diff; i++) {
      ll mi = infl;
      ll io = infl;
      int j = i + diff;
      for (int k = i + 1; k <= j; k++) {
        ll x = dp[i][k-1][1] + dp[k][j][1] + dp[i][k-1][2] + dp[k][j][2];
        ll y = dp[i][k-1][2] + dp[k][j][2];
        if (mi > x) {mi = x, io = y;}
      }
      dp[i][j][1] = mi;
      dp[i][j][2] = io;
    }
    ++diff;
  }
  cout << dp[1][n][1] << "\n";
  return 0;
}

Measured memory_bytes: 4352
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = ril()
ls2 = rils(m)
ls.sort()
ls2.sort(key=operator.itemgetter(1), reverse=True)
res = 0
index = 0
b, c = ls2[0]
for x in ls:
    res += x
    if x < c:
        res += c - x
        b -= 1
        if b == 0:
            index += 1
            if index < m:
                b, c = ls2[index]
            else:
                c = -1
print(res)

Measured memory_bytes: 32928
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
string s;
string la,ne;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	int n=s.size();
	la=s.substr(0,1);
	int j=1;
	int res=1;
	while(j<s.size()){
		ne=s.substr(j,1);
		while(j<(s.size()-1)&&ne==la){
			j++;
			ne+=s[j];
		}
		if(ne==la){
			cout<<res<<endl;
			return 0;
		}
		res++;
		j++;
		la=ne;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100010], b[100010], c[100010];
long long dp1[100010];
long long dp2[100010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i <= n; i++) scanf("%d", b + i);
	for (int i = 1; i <= n; i++) scanf("%d", c + i);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	int k = 1;
	for (int i = 1; i <= n; i++) {
		for (; k <= n && a[k] < b[i]; k++);
		dp1[i] = k - 1;
	}
	long long s = 0;
	long long ans = 0;
	k = 1;
	for (int i = 1; i <= n; i++) {
		for (; k <= n && b[k] < c[i]; k++)s += dp1[k];
		dp2[i] = s;
		ans += dp2[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define int long long
#define ll int 
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 2e5 + 10;
int n, a[N], sum = 0, Min_Num = -1 ;
int A, B;
inline int up(int a, int now) {
	if(a < 0) return 0;
	int rt = 0;
	int l = a - B * now;
	int r = A - B;
	return l % r == 0 ? l / r : l / r + 1;
}

inline bool check(int now) {
	#define during (start - now)
	int start = now;
	for(int i = 1; i <= n; i ++) {
		int two = up(a[i] - during * B, now);
		now -= two;
//		cout << now << ' ' << two << ' ' << during << "\n";
		if(now < 0) return 0;
	}
	return now >= 0;
}

main() {
    read(n), read(A), read(B);
    for(int i = 1; i <= n; i ++) {
        read(a[i]);
	}
	sort(a + 1, a + n + 1, greater<int>());
	int l = 1, r =(int) 1e9 + 10;
//	cout << check(800000000) << "\n";
	while(l < r) {
		int mid = l + (r - l) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << r << "\n";
    
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

int main() {
    int N; cin >> N;
    vint dp(N, INF);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == cnt + 1) cnt++;
    }
    if (cnt == 0) cout << -1 << endl;
    else cout << N - cnt << endl;
    return (0);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
using namespace std;
const int MAXN = 1e5 + 10;
inline void _read(int &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int n;
int deg[MAXN];
vector <int> G[MAXN];
int q[MAXN];
char s[MAXN];
bool del[MAXN];
#define tp(x) (deg[x]&1)^(s[x]=='W')
#define val(x) (tp(x)==1?-2:0)
inline void toposort()
{
	register int head(1), tail(0);
	for (register int i = 1; i <= n; ++i)
		if (s[i] == 'B' && deg[i] == 1) q[++tail] = i;
	while (head <= tail)
	{
		register int cur = q[head++];
		del[cur] = true;
		for (auto v : G[cur])
		{
			if (deg[v]) --deg[v];
			if (s[v] == 'B' && deg[v] == 1 && !del[v]) q[++tail] = v;
		}
	}
}
int minn = 2147483647;
int tot = -2;
int f[MAXN];
inline void dfs(int x, int fa)
{
	tot += (tp(x) == 1) + 2;
	f[x] = val(x);
	for (auto v : G[x])
	{
		if (v != fa && !del[v])
		{
			dfs(v, x);
			minn = min(minn, f[x] + f[v]);
			f[x] = min(f[x], f[v] + val(x));
		}
	}
}
int main(int argc, char **argv)
{
	_read(n);
	memset(deg, 0, sizeof deg);
	for (register int i = 1; i < n; ++i)
	{
		register int u, v;
		_read(u), _read(v);
		G[u].push_back(v);
		G[v].push_back(u);
		++deg[u], ++deg[v];
	}
	scanf("%s", s + 1);
	toposort();
	for (register int i = 1; i <= n; ++i)
	{
		if (!del[i])
		{
			dfs(i, 0);
			printf("%d\n", (minn == 2147483647 ? 0 : minn) + tot);
			return 0;
		}
	}
	puts("0");
	return 0;
}

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

#define int long long
#define pb push_back
#define mod 1000000007
#define w(x) int x;cin>>x; while(x-->0)

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

void mysol()
{
    int n; cin >> n;
    int arr[n];
    for (int &a : arr)
        cin >> a;
    int dp[n] {0};
    dp[0] = 0;
    // cout << dp[0] << ' ';
    dp[1] = abs(arr[1] - arr[0]);
    // cout << dp[1] << ' ';
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
        // cout << dp[i] << ' ';
    }
    cout << dp[n - 1];

}

int32_t main()
{
    fast();
    // w(t)
    {
        mysol();
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int N, Q;
Graph G;

void dfs(int v, int p, vector<ll> &res) {
    if (p != -1) res[v] += res[p];
    for (auto e : G[v]) {
        if (e == p) continue;
        dfs(e, v, res);
    }
}

int main() {
    cin >> N >> Q;
    G.assign(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> val(N, 0);
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        val[p] += x;
    }
    dfs(0, -1, val);
    for (auto v : val) cout << v << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 25084
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <set>
using namespace std;

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

int h, w;
vector<vector<bool> > check;

void dfs(int y, int x){
	check[y][x] = false;
	for(int i=0; i<4; ++i){
		int y1 = y + dy[i];
		int x1 = x + dx[i];
		if(0 <= y1 && y1 < h && 0 <= x1 && x1 < w && check[y1][x1]){
			dfs(y1, x1);
		}
	}
}

int main()
{
    for(;;){
	    int n;
	    cin >> w >> h >> n;
        if(w == 0)
            return 0;

	    map<int, int> my, mx;
	    my[0];
	    my[h];
	    mx[0];
	    mx[w];
	    vector<int> x1(n), y1(n), x2(n), y2(n);
	    for(int i=0; i<n; ++i){
		    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		    my[y1[i]];
		    my[y2[i]];
		    mx[x1[i]];
		    mx[x2[i]];
	    }

	    map<int, int>::iterator it;
	    h = -1;
	    for(it=my.begin(); it!=my.end(); ++it){
		    ++ h;
		    it->second = h;
	    }
	    w = -1;
	    for(it=mx.begin(); it!=mx.end(); ++it){
		    ++ w;
		    it->second = w;
	    }

	    for(int i=0; i<n; ++i){
		    y1[i] = my[y1[i]];
		    y2[i] = my[y2[i]];
		    x1[i] = mx[x1[i]];
		    x2[i] = mx[x2[i]];
	    }

	    check.assign(h, vector<bool>(w, true));
	    for(int i=0; i<n; ++i){
		    for(int j=y1[i]; j<y2[i]; ++j){
			    for(int k=x1[i]; k<x2[i]; ++k){
				    check[j][k] = false;
			    }
		    }
	    }

	    int ret = 0;
	    for(int i=0; i<h; ++i){
		    for(int j=0; j<w; ++j){
			    if(check[i][j]){
				    dfs(i, j);
				    ++ ret;
			    }
		    }
	    }
	    cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

const double EPS = 1e-10;

int main(){
    int x1,y1,x2,y2,x3,y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    double b = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    double c = sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    double S = (abs((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)))/2.0;
    double r = 2*S/(a+b+c);

    double ok = 0.0,ng = 1000.0;
    while(ng-ok > EPS){
        double mid = (ok+ng)/2.0;
        if(2*mid <= max({(1-mid/r)*a,(1-mid/r)*b,(1-mid/r)*c})) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<vector<ll>> G(n);
	int a, b;
	rep(i, m) {
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	queue<ll>que;
	vector<ll>len(n, -1);
	vector<ll>points(n);
	len[0] = 0;
	que.push(0);
	while (!que.empty()) {
		ll now = que.front();
		que.pop();
		
		for (ll next : G[now]) {
			if (len[next] != -1)continue;
			que.push(next);
			len[next] = len[now] + 1;
			points[next] = now+1;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; ++i) {
		cout << points[i] << endl;
	}
}

/*

*/


Measured memory_bytes: 13744
#include <iostream>

using namespace std;

using ll = long long;

constexpr ll M = 1000000007;

ll modpow(ll x, ll p = M - 2) {
  if (p == 0) return 1;
  ll half = modpow(x, p / 2),
     h2 = (half * half) % M;
  return (p % 2 == 0) ? h2 : ((h2 * x) % M);
}

ll comb(ll n, ll r) {
  ll res = 1;
  for (ll i = 0; i < r; i++) {
    res *= n - i;
    res %= M;
    res *= modpow(i + 1);
    res %= M;
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x, y;
  cin >> x >> y;
  for (int i = 0; i < 1000000; i++) {
    int j = x - 2 * i;
    if (2 * j != y - i) continue;
    cout << comb(i + j, i) << endl;
    return 0;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
/*
  Contest 115
  A - Christmas Eve Eve Eve
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    int d = 0;
    std::cin >> d;
    std::cout << "Christmas ";
    for (int i = 0; i < 25 - d; ++i)
        std::cout << "Eve ";
    std::cout << std::endl;


    return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> L;

// 再帰
int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return 100000000000000000; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
    }

    // 今ある竹を採用しない場合
    int res = rec(i+1, a, b, c);
    
    // A, B, C を使う場合。
    // (a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10 かかることを意味する
    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}

int main() {
    // 入力
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];
    
    // 再帰する
    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int N; cin >> N;
  ll A, B;
  cin >> A >> B;
  ll X[N];
  FOR(i,0,N) cin>>X[i];
  ll ans = 0;
  FOR(i,0,N-1) {
    ans += min((X[i+1]-X[i])*A, B);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

struct S
{
    int A, B;

    S(int A = 0, int B = 0) : A(A), B(B) {}

    bool isGood() const
    {
        return A <= B;
    }
};

bool operator < (const S& x, const S& y)
{
    if(x.isGood() != y.isGood())
        return x.isGood();

    if(x.isGood())
    {
        return x.A < y.A;
    }

    else
    {
        return x.B > y.B;
    }
}

const int N = 1000100;

char Buffer[N];

string Read()
{
    scanf("%s", Buffer);
    return Buffer;
}

S Get(string s)
{
    S Res;

    for(char c : s)
    {
        if(c == '(')
        {
            Res.B++;
        }

        else
        {
            if(Res.B)
            {
                Res.B--;
            }

            else
            {
                Res.A++;
            }
        }
    }

    return Res;
}

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

    vector <S> a(n);
    for(int i = 0; i < n; i++)  a[i] = Get(Read());
    sort(a.begin(), a.end());

    int Sum = 0;

    for(const S& x : a)
    {
        Sum -= x.A;
        if(Sum < 0) return 0 * puts("No");
        Sum += x.B;
    }

    puts(Sum ? "No" : "Yes");
}


Measured memory_bytes: 10980
import scala.io.StdIn._
 
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val a = sc.nextInt
  val b = sc.nextInt
  if(n*a<b){
    println(n*a)
  }
  else{
    println(b)
  }  
}

Measured memory_bytes: 27316
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

int main()
{
	int n, m;
	complex<double> w[100];
	int r[100];

	cin >> n;

	while (n > 0) {
		for (int i = 0; i < n; i++) {
			double x, y;

			cin >> x >> y >> r[i];
			w[i] = complex<double> (x, y);
		}

		cin >> m;

		for (int j = 0; j < m; j++) {
			double tx, ty, sx, sy;
			complex<double> t, s;
			bool f = 1;

			cin >> tx >> ty >> sx >> sy;
			t = complex<double>(tx, ty);
			s = complex<double>(sx, sy);

			for (int i = 0; i < n; i++) {
				if ((abs(t - w[i]) - r[i]) * (abs(s - w[i]) - r[i]) <= 0)
					f = 0;
				else if(abs(t - w[i]) > r[i] && abs(s - w[i]) > r[i]){

					if (abs(arg((t - s) / (w[i] - s))) <= asin(r[i] / abs(w[i] - s))
						&& abs(t - s) * abs(t - s) >= abs(w[i] - s) * abs(w[i] - s) - r[i] * r[i])
						f = 0;
				}
			}

			if (f)
				cout << "Danger" << endl;
			else
				cout << "Safe" << endl;
		}

		cin >> n;
	}

	return 0;
}



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

int n;
char s[1000001];
int O[1000000], I[1000000], a, b;
bool ok(int t) {
	if (a < t || b < t)return false;
	int p = n;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (s[p] == 'O' || (s[p] == 'I'&&p >= I[t - 1])))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	scanf("%d%s", &n, s);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I[a++] = i;
		if (s[i] == 'O'&&b < a)O[b++] = i;
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 7608
#include<iostream> //AA06( 19/ 04/ 20) If u see my code, Have a Good Day! (^_^)

using namespace std;

int main()
{
    int N, M, i, sum = 0, A;

    cin >> N >> M;


    for(i = 0; i < M; ++i) {
        cin >> A;

        sum = sum + A;

    }

    if(sum > N) {
        cout << -1 << endl;
    }

    else {
        cout << N - sum << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int64_t r=0,g=0,b=0;
  if(n<=2){
    cout << 0 << endl;
    return 0;
  }
  rep(i,n){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  int64_t ans=r*g*b;
  int64_t cnt=0;
  rep(i,n){
    rep(j,n){
      if(j<=i)continue;
      if(2*j-i>n-1)continue;
      if(s[i]!=s[j]&&s[i]!=s[2*j-i]&&s[j]!=s[2*j-i]){
        cnt++;
      }
    }
  }
  cout << ans-cnt << endl;
  
}


Measured memory_bytes: 3636
# AGC007A - Shik and Stone
def main():
    H, W, *A = open(0).read().split()
    H, W = int(H), int(W)
    flg = ("".join(A)).count("#") == H + W - 1
    print("Possible" if flg else "Impossible")


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char str[100005];
	scanf("%s",str);
	int a0=0,a1=0,len=strlen(str);
	for(int i=0;i<len;i++){
		if(str[i]=='0') a0++;
		else if(str[i]=='1') a1++;
	}
	int min=a0;
	if(min>a1) min=a1;
	printf("%d\n",min*2);
	return 0;
} 

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
I=2*N
D=[[-I]*(N+1)for _ in range(N+1)]
M=0
r=[-I]*(N+1)
def c(i,j,k):
    D[i][j]=max(k,D[i][j])
    D[j][i]=max(k,D[j][i])
    r[i]=max(r[i],D[i][j])
    r[j]=max(r[j],D[i][j])
    global M
    M=max(M,k)
a=0
X=A[0]
Y=A[1]
D[X][Y]=0
D[Y][X]=0
r[X]=0
r[Y]=0
for i in range(N-1):
    n=A[3*i+2:3*i+5]
    C=[]
    if len(set(n))==1:
        a+=1
        continue
    if len(set(n))==2:
        for j in range(3):
            if n.count(n[j])==2:
                X=n[j]
            else:
                Y=n[j]
        for j in range(1,N+1):
            C.append((j,Y,D[X][j]+1))
    X,Y,Z =n
    C.append((X,Y,max(M,D[Z][Z]+1)))
    C.append((Y,Z,max(M,D[X][X]+1)))
    C.append((X,Z,max(M,D[Y][Y]+1)))
    for j in range(1,N+1):
        for k in range(3):
            C.append((j,n[k],r[j]))
    for j,k,l in C:
        c(j,k,l)
M=max(M,D[A[-1]][A[-1]]+1)
print(a+M)

Measured memory_bytes: 223804
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m, x, at;

  cin >> n >> m >> x;

  vector<int> a;

  for (int i = 0; i < m; i++) {
    cin >> at;
    a.push_back(at);
  }

  int minc = 999;
  vector<int> kk;
  // for (int i=0; i < n; ++i) {
  //   if(i>)
  //       kk.push_back(0);
  // }

  int lc = 0;
  int rc = 0;
  bool fla = false;
  // if (a[0] >= x) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  // if (a[m - 1] <= x) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  int i;
  vector<int> lo;
  for (i = 0; i <= n; ++i) {
    lo.push_back(0);
  }

  for(auto q:a)
    lo[q]=1;

  for(int i=0;i<=n;i++){
    if(i<x)
      lc+=lo[i];
    if(i>x)
      rc+=lo[i];
  }
  if (lc > rc)
    cout << rc << endl;
  else
    cout << lc << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,l,a[MAXN];
inline void Solve(int p){
	puts("Possible");
	Rep(i,1,p-1)cout<<i<<"\n";
	Red(i,n-1,p)cout<<i<<"\n";
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),l=read();
	Rep(i,1,n)a[i]=read();
	Rep(i,1,n-1)if(a[i]+a[i+1]>=l)return Solve(i),0;
	puts("Impossible");
	return 0;
}




Measured memory_bytes: 4012
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w = sc.nextLong()
  if (h % 3 == 0 || w % 3 == 0) {
    println(0)
  } else {
    var ans = h.min(w)
    for (i <- 1 until h.toInt) {
      val a = w * i
      val b = (w/2) * (h-i)
      val c = ((w+1)/2) * (h-i)
      val sMin = a.min(b)
      val sMax = a.max(c)
      ans = ans.min(sMax - sMin)
    }

    for (i <- 1 until w.toInt) {
      val a = h * i
      val b = (h/2) * (w-i)
      val c = ((h+1)/2) * (w-i)
      val sMin = a.min(b)
      val sMax = a.max(c)
      ans = ans.min(sMax - sMin)
    }
    println(ans)
  }
}


Measured memory_bytes: 55508
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from collections import deque
class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)
    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)
    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None
    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0
    def flow(self):
        flow = 0
        G = self.G
        bfs = self.bfs; dfs = self.dfs
        while bfs():
            *self.it, = map(iter, G)
            while dfs(0, 1):
                flow += 1
        return flow
    def matching(self):
        return [cap for _, cap, _ in self.backwards]

N = INT()
hk = HopcroftKarp(N, N)
ab = [LIST() for _ in range(N)]
cd = [LIST() for _ in range(N)]

for i, (a, b) in enumerate(ab):
    for j, (c, d) in enumerate(cd):
        if a < c and b < d:
            hk.add_edge(i, j)

print(hk.flow())


Measured memory_bytes: 5716
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int p[n];rep(i,0,n)cin>>p[i];
    int ans=0;
    rep(i,0,n-1){
        if(p[i]==i+1){
            ans++;
            swap(p[i],p[i+1]);
        }
    }
    if(p[n-1]==n)ans++;
    cout<<ans<<endl;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

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

    vector<ll>a(n+1);
    for(int i=1;i<=n;i++) cin >> a[i];

    for(int i=k+1;i<=n;i++){
        if(a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4840
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define MAXN 100000
#define INF 1000000000000000LL
#define TOT 1000000000000000LL
using namespace std;
typedef long long LL;
struct edge
{
	LL to,val;
	edge(){};
	edge(LL _to,LL _val):to(_to),val(_val){};
};
vector<edge> G[2][MAXN+5];
multiset<LL> ans;
LL dist[2][MAXN+5],times[MAXN+5];
void SPFA(LL s,LL id)
{
	queue<LL> que;
	for(LL i=0;i<=MAXN;i++)
		dist[id][i]=INF;
	dist[id][s]=0;
	que.push(s);
	while(que.empty()==false)
	{
		LL fro=que.front();
		edge e;
		que.pop();
		for(LL i=0;i<G[id][fro].size();i++)
		{
			edge e=G[id][fro][i];
			if(dist[id][e.to]>dist[id][fro]+e.val)
			{
				dist[id][e.to]=dist[id][fro]+e.val;
				que.push(e.to);
			}
		}
	}
}
int main()
{
	LL n,m,s,t;
	scanf("%lld %lld",&n,&m);
	scanf("%lld %lld",&s,&t);
	LL u,v,a,b;
	for(LL i=1;i<=m;i++)
	{
		scanf("%lld %lld %lld %lld",&u,&v,&a,&b);
		G[0][u].push_back(edge(v,a));
		G[0][v].push_back(edge(u,a));
		G[1][u].push_back(edge(v,b));
		G[1][v].push_back(edge(u,b));
	}
	SPFA(s,0);
	SPFA(t,1);
	for(LL i=1;i<=n;i++)
		ans.insert(dist[0][i]+dist[1][i]);
	LL fro;
	for(LL i=0;i<n;i++)
	{
		fro=*ans.begin();
		printf("%lld\n",TOT-1LL*fro);
		ans.erase(ans.find(dist[0][i+1]+dist[1][i+1]));
	}
}

Measured memory_bytes: 22836
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
int fn(vector<int>& h, int n, int i, vector<int>& t){
	if(i == n - 1){
		return 0;
	}
	if(i == n - 2){
		return abs(h[i + 1] - h[i]) + fn(h, n, i + 1, t);
	}

	if(t[i] != -1){
		return t[i];
	}

	int cost = min((abs(h[i + 2] - h[i]) + fn(h, n, i + 2, t)),
			(abs(h[i + 1] - h[i]) + fn(h, n, i + 1, t)));
	t[i] = cost;

	return t[i];
}
int main(){
	int n;
	cin >> n;

	vector<int> h(n + 1);
	vector<int> t(n + 1, -1);

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

	cout << fn(h, n, 0, t) << endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  int ans = 1;
  if (n >= 64) ans = 64;
  else if (n >= 32) ans = 32;
  else if (n >= 16) ans = 16;
  else if (n >= 8) ans = 8;
  else if (n >= 4) ans = 4;
  else if (n >= 2) ans = 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void bubbleSort(int numbers[], int array_size)
{
  int i, j, temp;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      if (numbers[j-1] > numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}
int main()
{int n,x,a[101],i,cnt=0;
    scanf("%d %d",&n,&x);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    bubbleSort(a,n);
    for(i=0;i<n;i++){
        if((x-a[i]==0)||((x-a[i]>=0)&&(i!=n-1))){
            cnt++;
            x=x-a[i];
        }else break;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b,c,ans;
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
    printf("%lld",c/a*b);
}

Measured memory_bytes: 128
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)

Measured memory_bytes: 9200
n = int(input())
list_t = list((map(int, input().split())))
m = int(input())
count = 0
list_px = []
while count < m:
    list_px.append(list(map(int, input().split())))
    count += 1
list_t_sum = 0
for number in list_t:
    list_t_sum += number
for i in range(0,m):
    print(list_t_sum - list_t[list_px[i][0]-1] + list_px[i][1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<pair<int, int>> a;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        a.emplace_back(y, x);
    }
    sort(a.begin(), a.end());
    ll cur = 0;
    for (auto &p : a) {
        cur += p.second;
        if (cur > p.first) {
            cout << "No\n";
            exit(0);
        }
    }
    cout << "Yes\n";
}


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

pair<vector<int>, vector<string> > solve(int n, vector<pair<int, int> > const & ps) {
    bool parity = (ps[0].first + ps[0].second) & 1;
    for (auto p : ps) {
        if (((p.first + p.second) & 1) != parity) {
            return make_pair(vector<int>(), vector<string>());
        }
    }

    // construct the graph
    vector<int> ds;
    for (int d = 1 << 30; d >= 2; d >>= 1) {
        ds.push_back(d);
    }
    REP (i, 2) {
        ds.push_back(1);
    }
    if (parity) {
        ds.push_back(1);
    }

    // construct commands
    vector<string> ws;
    for (auto p : ps) {
        int x, y; tie(x, y) = p;
        string w;
        for (int d : ds) {
            if (x + y >= 0 and x - y >= 0) {
                w += 'R';
                x -= d;
            } else if (x + y >= 0) {
                w += 'U';
                y -= d;
            } else if (x - y >= 0) {
                w += 'D';
                y += d;
            } else {
                w += 'L';
                x += d;
            }
        }
        assert (x == 0 and y == 0);
        ws.push_back(w);
    }

    return make_pair(ds, ws);
}

int main() {
    // input
    int n; cin >> n;
    vector<pair<int, int> > p(n);
    REP (i, n) cin >> p[i].first >> p[i].second;

    // solve
    vector<int> d;
    vector<string> w;
    tie(d, w) = solve(n, p);

    // output
    if (d.empty()) {
        cout << -1 << endl;
    } else {
        cout << d.size() << endl;
        REP (i, d.size()) {
            if (i) cout << ' ';
            cout << d[i];
        }
        cout << endl;
        for (auto w_i : w) {
            cout << w_i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
W = 101

def solve(xyh):
    for bx, by, bh in xyh:
        if bh > 0:
            break
    for yy in range(W):
        for xx in range(W):
            H = bh + abs(bx - xx) + abs(by - yy)
            for x, y, h in xyh:
                if max(H - abs(xx - x) - abs(yy - y), 0) != h:
                    break
            else:
                return (xx, yy, H)

N = int(input())
xyh = [tuple(map(int, input().split())) for i in range(N)]
print(*solve(xyh))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const int MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ng = 0,  ok = 1e9;
  while(abs(ng-ok)>1){
    int m = (ng+ok)/2;
    auto f = [&](int m){
      ll now = 0;
      rep(i,n) now += (a[i]-1)/m;
      return now <= k;
    };
    if(f(m)) ok = m;
    else ng = m;
  }
  cout << ok << endl;
      
  
  return 0;
}


Measured memory_bytes: 3996
from bisect import bisect_left
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
X = []
for _ in range(M):
    b, c = map(int, input().split())
    X.append((b, c))

X = sorted(X, key=itemgetter(1), reverse=True)

for b, c in X:
    BC.extend([c] * b)
    if len(BC) >= N:
        break

Y = A + BC
Y.sort(reverse=True)
answer = sum(Y[:N])
print(answer)

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;

    int ans = 0;
    int i;
    for(i = 0;ans < n;i++){
        ans += i;
    }

    int tar = ans - n;

    // cout << tar << endl;

    for(int j = 1;j < i;j++){
        if(j != tar) cout << j << endl;
    }

    return 0;
}

Measured memory_bytes: 256