akhauriyash/Code-Regression huggingface dataset:
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust";
	else cout << "win";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int N;
	cin >> N;
	v.resize(N + 1);
	rep(i, 1, N)cin >> v[i];
	sort(v.begin(), v.end());
	int MIN = 1000000000;
	rep(x,v[1],v[N]) {
		int ans = 0;
		for (int y : v) {
			if (y == v[0])continue;
			//cout << "y:" << y << '\n';
			ans += (y - x)*(y - x);
		}
		//cout << "x:" << x << " ans:" << ans << '\n';
		if (ans < MIN) MIN = ans;
	}
	cout << MIN << '\n';
	return 0;
}

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

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

using namespace std;

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

	int ans=0;
	rep(i,n) ans+=(i<k?x:y);
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV

main = B.interact$B.pack.show.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:ps) = sum pp + (p `div` 2)
    where
        (p:pp)=reverse $ sort ps

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool digit[10];	// 禁止する数字

string i2s(int n){
	stringstream ss;
	int res;
	ss << n;

	return ss.str();
}

bool is_ok(int curr){
	string s = i2s(curr);
	rep (i, s.length()){
		if (!digit[(int)(s[i] - '0')]) return false;
	} // end rep
	return true;
}

int main()
{
	fill(digit, digit + 10, true);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	int K; cin >> K;
	rep (i, K){
		int D; cin >> D;
		digit[D] = false;
	} // end rep
 
	int res = 0;
	for (int i = N;;++i){
		bool ok = true;
		if (is_ok(i)){
			res = i; break;
		} // end if
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
ll n,wt;
ll w[200000],v[200000];
ll dp[200000][110];
ll solve(ll ind,ll val)
{
    
    if(ind==n-1)
    {
        if(val<=0)
        {
            return 0;
        }
        if(dp[val][ind]!=-1)
        {
            return dp[val][ind];
        }
        if(v[ind]>=val)
        {
            return w[ind];
        }
        else
        {
            return M;
        }
    }
    else
    {
        
        if(val<=0)
        {
            return 0;
        }
        else
        {
            if(dp[val][ind]!=-1)
            {
                return dp[val][ind];
            }
            ll val1=solve(ind+1,val);
            ll val2=w[ind]+solve(ind+1,val-v[ind]);
            dp[val][ind]=min(val1,val2);
            return dp[val][ind];
        }
    }
}
int main()
{
    IO
    cin>>n>>wt;
    memset(dp,-1,sizeof(dp));
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    for(ll j=s;j>=0;j--)
    {
        ll val=solve(0,j);
        if(val<=wt)
        {
            cout<<j<<lc;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 175540
#include <bits/stdc++.h>  
using namespace std; 
int n;
int a[100005];
int st;
int l=0,r=0;
inline bool comp(int x,int y){return x>y;}
int main()  
{  
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1,comp); 
    for(int i=1;i<=n+1;i++)
        if(a[i]<i)
        {
            st=i-1;
            break;
        }
    l=a[st]-st;
    r=-1;
    for(int i=st;a[i]>=st;i++)r++;
    //cout<<st<<" "<<l<<" "<<r<<endl;
    l%=2;
    r%=2;
    if(l||r)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

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

	if(n >= 10) cout << r << endl;
	else {
		cout << r + 100 * (10 - n) << endl;
	}
	
	return 0;
}


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

int main()
{
  double n, ans;
  while(1)
  {
    ans = 0;
    cin >> n;
    if(n < 0)
      break;
    
    if(n >= 256)
    {
      cout << "NA\n";
      continue;
    }

    int d;
    int m = (int)n;
    double r = n - m;
    
    for(int i = 0; i <= 8; i++)
    {

      d = m % 2;
      m /= 2;
      ans += d * pow(10, i);
    }
    for(int i = -1; i >= -4; i--)
    {
      d = (int)(r * 2);
      r = r * 2 - d;
      ans += d * pow(10, i);
    }
    if(r > 0.0001)
      cout << "NA\n";
    else
      printf("%013.4f\n", ans);
  }
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <stack>
#include <tuple>
#include <cassert>
#include <algorithm>

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define fst first
#define snd second
using namespace std;

class ArticulationPointDecomposition {
  std::vector<std::vector<std::pair<int, int> > > G;
  std::vector<int> ord;
  std::vector<int> low;
  std::vector<int> par;
  void Dfs(int v, int &times, stack<tuple<int, int, int> > &S);
  
public:
  std::vector<int> articulation_point;
  std::vector<std::vector<int> > edge_group;
  ArticulationPointDecomposition(const std::vector<std::pair<int, int> > &es);
};

void ArticulationPointDecomposition::Dfs(int v, int &times, stack<tuple<int, int, int> > &S){
  ord[v] = low[v] = ++times;
  for (const auto &e : G[v]){
    int w = e.fst;
    int i = e.snd;
    
    if (ord[w] < ord[v]) {
      S.push(make_tuple(v, w, i));
    }

    if (ord[w] == -1){
      Dfs(w, times, S);
      low[v] = min(low[v], low[w]);

      if ((ord[v] == 1 && ord[w] != 2) || (ord[v] != 1 && low[w] >= ord[v])){
        articulation_point.push_back(v);
      }
      
      if (low[w] >= ord[v]){
        edge_group.push_back(vector<int>());
        while (true){
          int a, b, j;
          tie(a, b, j) = S.top(); S.pop();
          edge_group.back().push_back(j);
          if (v == a && w == b) break;
        }
      } 
    } else {
      low[v] = min(low[v], ord[w]);
    }
  }
}

ArticulationPointDecomposition::ArticulationPointDecomposition(const vector<pair<int, int> > &es){
  assert(es.size() < 1ull << 31);
  int V = 0;
  for (const auto &e : es) V = max(V, max(e.fst, e.snd) + 1);
  
  ord = vector<int>(V, -1);
  low = vector<int>(V, -1);
  par = vector<int>(V, -1);
  G   = vector<vector<pair<int, int> > >(V);
  for (size_t i = 0; i < es.size(); i++){
    G[es[i].fst].emplace_back(es[i].snd, i);
    G[es[i].snd].emplace_back(es[i].fst, i);
  }

  REP(v, V) if (ord[v] == -1){
    int times = 0;
    stack<tuple<int, int, int> > S;
    Dfs(v, times, S);
  }
  sort(articulation_point.begin(), articulation_point.end());
  articulation_point.erase(unique(articulation_point.begin(), articulation_point.end()), articulation_point.end());
}
  
int main(int argc, char *argv[])
{
  int n, m, u, v;
  cin >> n >> m;
  vector<pair<int, int> > es;
  REP(i, m){
    cin >> u >> v;
    if (u > v) swap(u, v);
    es.emplace_back(u, v);
  }
  ArticulationPointDecomposition ad(es);
  sort(ad.articulation_point.begin(), ad.articulation_point.end());

  for (int v : ad.articulation_point){
    cout <<v  << endl;
  }
  return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
  
    int a,b,c;
    cin>>a>>b>>c;
    
    int k;
    cin>>k;
    int i;
    while(k!=0)
    {
        if(b>a)
           break;
           
        else
          b*=2;
          
          k-=1;
    }
    
    while(k!=0)
    {
        if(c>b)
          break;
          
        else
          c*=2;
          
          k-=1;
    }
    
    if(b>a && c>b)
      cout<<"Yes";
      
    else
      cout<<"No";
      
   
   
     return 0;
}

Measured memory_bytes: 3628
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int arr[100000];
int main() {
	cin >> N;
	ll cost = 0;
	int prev = 0;
	rep(i, N){
		cin >> arr[i];
		cost += abs(prev - arr[i]);
		prev = arr[i];
	}
	cost += abs(prev);
	vector<int> pos;
	pos.push_back(0);
	rep(i, N){
		pos.push_back(arr[i]);
	}
	pos.push_back(0);

	rep(i, N){
		cout << cost - abs(pos[i] - pos[i+1]) - abs(pos[i+1] - pos[i+2]) + abs(pos[i] - pos[i+2]) << endl;	
	}
}



Measured memory_bytes: 2168
import Data.List
import Data.Char

solve :: String -> Bool
solve s =  head s == 'A'
        && (length . filter (=='C')) s2 == 1
        && all isLower s'
  where s1 = take 2 s
        s2 = init . drop 2 $ s
        s3 = [last s]
        s' = tail s1 ++ delete 'C' s2 ++ s3

main :: IO ()
main = getLine >>= \s -> putStrLn $ if solve s then "AC" else "WA"


Measured memory_bytes: 380
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n,mx;
int a[MAXN];

void run() {
	scanf("%d%d",&n,&mx); REP(i,n) scanf("%d",&a[i]);
	ll ret=0;
	FOR(i,1,n) {
		ll cur=(ll)a[i-1]+a[i];
		ll snd=max(0LL,min(cur-mx,(ll)a[i]));
		ret+=snd,cur-=snd,a[i]-=snd;
		ll fst=max(0LL,min(cur-mx,(ll)a[i-1]));
		ret+=fst,cur-=fst,a[i-1]-=fst;
		assert(cur<=mx);
	}
	printf("%lld\n",ret);
}

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


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

int main() {
  
  int N, M;
  cin >> N >> M;
  
  vector<int> A(2*M);
  
  for (int i=0; i<2*M; i++)
    cin >> A.at(i);
  
  for (int i=1; i<=N; i++){
    
    int n=0;
    
    for (int j=0; j<2*M; j++){
      
      if (A.at(j) == i)
        n++;
    
    }
    
    cout << n << endl;
    
  }
  
}

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

int main(){
    int n;
    long long int k;
    vector< pair<int,int> > v;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;

        v.push_back(make_pair(a,b));
    }

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


    // for(int i=0;i<n;i++){
    //     cout<<v[i].first<<" "<<v[i].second<<endl;
    // }

    for(int i=0;i<n;i++){
        k-=v[i].second;

        if(k<=0){
            cout<<v[i].first<<endl;
            break;
        }
    }
    return 0;

}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, int> pli;
ll cnt[1000001];

int main()
{
    set<pli> st;

    int n, q;
    cin >> n >> q;
    rep(i, q)
    {
        int a, v;
        cin >> a >> v;
        st.erase(make_pair(-cnt[a], a));
        cnt[a] += v;
        st.insert(make_pair(-cnt[a], a));
        pli ans = *st.begin();

        cout << ans.second << " " << -ans.first << endl;
    }

    return 0;
}


Measured memory_bytes: 16792
program interval_running
  implicit none
  integer(8) :: t(2), a(2), b(2), p, q, x, y
  read(*,*) t
  read(*,*) a
  read(*,*) b
  p = (a(1)-b(1))*t(1)
  q = (a(2)-b(2))*t(2)
  if (p > 0_8) then
    p = -p
    q = -q
  end if
  if (p+q < 0_8) then
    write(*,'(i0)') 0
    stop
  else if (p+q == 0_8) then
    write(*,'(a)') "infinity"
    stop
  end if
  x = -p/(p+q)
  y = min(mod(-p,p+q),1_8)
  write(*,'(i0)') 2_8*x+y
end program interval_running

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

int main(void)
{
    int N, M, Q, L, R, p, q;
    cin >> N >> M >> Q;

    int* trains = new int[N*N]();
    int* ans = new int[N*N]();

    for(int i=0; i<M; i++) {
        cin >> L >> R;
        trains[(L-1)*N + R-1] ++;
    }

    for(int l=0; l<N; l++)
        for(int r=l; r<N; r++) {
            int s = 0;
            for(int x=l; x<=r; x++)
                for(int y=x; y<=r;y++)
                    s += trains[x*N + y];
            ans[l*N + r] = s;
        }
         
    for(int i=0; i<Q; i++) {
        cin >> p >> q;
        cout << ans[(p-1)*N + q-1] << endl;
    }

    delete [] trains;
    delete [] ans;

    return 0;
}

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

int A[201];
int n;

bool solve(int m, int nn){ 
	/*
	m current sum number 
	nn 遍历A中元素的位置 若遍历完则退出
	*/
	if(m==0) return true;
	else if(nn==n && m!=0) return false;
	return solve(m-A[nn], nn+1)||solve(m, nn+1);
}

int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>A[i];
	int n1;cin>>n1;
	int tem1;
	for(int i=0; i<n1; i++){
		cin>>tem1;
		if(solve(tem1, 0)){
			cout<<"yes"<<endl;
		}
		else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[90];
int main() {
	int N, i;
	in[0] = 2, in[1] = 1;
	scanf("%d", &N);
	for (i = 2; i <= N; i++) in[i] = in[i - 1] + in[i - 2];
	return !printf("%lld\n", in[N]);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int d,r;
		double f,x,y;

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.print(d = a/b);
		System.out.print(" ");
		System.out.print(r = a%b);
		System.out.print(" ");
		x = a;
		y = b;
	//	System.out.print(f = x/y);
		f=x/y;
		System.out.printf("%f",f);


	}
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int r, g, b; cin >> r >> g >> b;

  int x = r * 100 + g * 10 + b;
  cout << (x % 4 == 0 ? "YES\n" : "NO\n");
  
  return (0);
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n,x;
    int cnt = 0;
    bool flag = false;
    while (scanf("%d",&x)!=EOF) {
        if (flag)
            continue;
        cnt++;
        if (x==0) {
            flag = true;
            n = cnt;
        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 3224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  int result_water=0;
  int result_sugar=0;

  bool water_can_make[3001]={};
  bool sugar_can_make[3001]={};
  water_can_make[0]=true;
  sugar_can_make[0]=true;
  for(int i=100;i<=3000;i+=100){
    if(i-a*100>=0&&water_can_make[i-a*100]){
      water_can_make[i]=true;
    }else if(i-b*100>=0&&water_can_make[i-b*100]){
      water_can_make[i]=true;
    }
  }
  for(int i=1;i<=3000;i++){
    if(i-c>=0&&sugar_can_make[i-c]){
      sugar_can_make[i]=true;
    }else if(i-d>=0&&sugar_can_make[i-d]){
      sugar_can_make[i]=true;
    }
  }
  for(int w=0;w<=f&&w<=3000;w+=100){
    for(int s=0;s+w<=f&&s<=3000;s++){
      if(water_can_make[w]&&sugar_can_make[s]){
        if(w*e>=s*100){
          if(result_sugar*(w+s)<s*(result_sugar+result_water)||(result_water==0&&result_sugar==0)){
            result_water=w;
            result_sugar=s;
          }

        }

      }
    }
  }
  cout<<result_water+result_sugar<<" "<<result_sugar<<endl;




  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	auto even = 0;
	vector<int> list(N, -1);
	queue<pair<int, bool>> q;
	q.push({ 0, false });
	vector<bool> used(N);
	bool all = false;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();
		if (p.second)
		{
			++even;
			list[p.first] = 1;
		}
		else
		{
			list[p.first] = 0;
		}

		for (auto v : G[p.first])
		{
			if (list[v] >= 0 && list[p.first] == list[v])
			{
				all = true;
				break;
			}

			if (used[v])
			{
				continue;
			}

			used[v] = true;
			q.push({ v, !p.second });
		}

		if (all)
		{
			break;
		}
	}

	auto result = 0ll;
	if (all)
	{
		result = (ll)N * (N - 1) / 2 - M;
	}
	else
	{
		for (auto i = 0; i < N; ++i)
		{
			auto num = even;
			if (list[i])
			{
				num = N - num;
			}
			num -= G[i].size();
			result += num;
		}

		result /= 2;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 6272
#include<stdio.h>

int main(void){

int hi,hy,ki,ky,a,b,c,d,ht=0,kt=0,hc,hd,kc,kd;

scanf("%d %d",&hi,&hy);
scanf("%d %d",&ki,&ky);
scanf("%d %d %d %d",&a,&b,&c,&d);

ht = hi*a+hy*b;
kt = ki*a+ky*b;

if(hi>=10){
hc = hi/10;
ht = ht+hc*c;
}
if(hy>=20){
hd = hy/20;
ht = ht+hd*d;
}
if(ki>=10){
kc = ki/10;
kt = kt+kc*c;
}
if(ky>=20){
kd = ky/20;
kt = kt+kd*d;
}


if(ht>kt){
printf("hiroshi\n");
}
else if(ht<kt){
printf("kenjiro\n");
}
else if(ht == kt){
printf("even\n");
}

return 0;
}


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

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


	if ((a-c)*(a-c) <= d*d){
        cout << "Yes" << endl;
    }


	else if ((a-b)*(a-b) <= d*d && (c-b)*(c-b) <= d*d){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" <<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N];
int main()
{
	int n;
	cin>>n;
	//vector<int> a(n);
	for(int i=1;i<=n;i++) cin>>a[i];
	int ans=0;
	for(int i=1,j;i<=n;i=j+1){
		j=i;
		ans++;
		while(j+1<=n&&a[i]==a[j+1]) j++;
		if(j+1<=n){
			if(a[i]<a[j+1]) 
				while(j+1<=n&&a[j]<=a[j+1]) j++;
			else
				while(j+1<=n&&a[j]>=a[j+1]) j++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	ll n, k;
	cin >> n >> k;
	multiset<pair<ll, ll>> s;
	while (n--)
	{
		ll a, b;
		cin >> a >> b;
		s.insert({a, b});
	}
	for (auto i : s)
	{
		ll a = i.first;
		ll b = i.second;
		k -= b;
		if (k <= 0)
		{
			cout << a;
			break;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 6528
# Knapsack
module Knapsack
  def self.calc(w, data)
    items = data.map do |data|
      Item.new(data)
    end

    dp = Array.new(items.size + 1) { Array.new(w + 1, 0) }

    for i in 1..items.size
      item = items[i - 1]
      for j in 1..w
        if item.weight <= j
          dp[i][j] = [item.value + dp[i - 1][j - item.weight], dp[i - 1][j]].max
        else
          dp[i][j] = dp[i - 1][j]
        end
      end
    end

    max_value, max_weight = -Float::INFINITY, -Float::INFINITY
    for j in 1..w
      if max_value < dp[items.size][j]
        max_value = dp[items.size][j]
        max_weight = j
      end
    end

    [max_value, max_weight]
  end

  # Item
  class Item
    attr_reader :value, :weight

    def initialize(args)
      @value, @weight = args
    end
  end
end

count = 1

while line = gets
  w = line.chomp.to_i
  break if w == 0

  items = []

  n = gets.chomp.to_i

  n.times do
    items << gets.chomp.split(',').map(&:to_i)
  end

  puts "Case #{count}:"
  puts Knapsack::calc(w, items)

  count += 1
end

Measured memory_bytes: 16904
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=400005;
int n,m,l,Flag[N],tot,zz[N],fi[N],ne[N],flag[N][2],f[N],g[N],x[N],y[N];
char s[N];
void down(int x){
	int i=x;
	if (x*2<=l&&flag[f[x*2]][0]*flag[f[x*2]][1]<flag[f[i]][0]*flag[f[i]][1])i=x*2;
	if (x*2<l&&flag[f[x*2+1]][0]*flag[f[x*2+1]][1]<flag[f[i]][0]*flag[f[i]][1])i=x*2+1;
	if (i!=x){
		swap(f[x],f[i]);
		swap(g[f[x]],g[f[i]]);
		down(i);
	}
}
void up(int x){
	if (x==1)return;
	if (flag[f[x]][0]*flag[f[x]][1]<flag[f[x/2]][0]*flag[f[x/2]][1]){
		swap(f[x],f[x/2]);
		swap(g[f[x]],g[f[x/2]]);
		up(x/2);
	}
}
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x[i],&y[i]);
		flag[x[i]][s[y[i]]-'A']++;
		flag[y[i]][s[x[i]]-'A']++;
		jb(x[i],y[i]);jb(y[i],x[i]);
	}
	for (int i=1;i<=n;i++)f[i]=g[i]=i;
	l=n;
	for (int i=n;i;i--)down(i);
	while (l&&flag[f[1]][0]*flag[f[1]][1]==0){
		int k=f[1];
		Flag[k]=1;
		f[1]=f[l--];
		g[f[1]]=1;
		down(1);
		for (int i=fi[k];i;i=ne[i])
			if (!Flag[zz[i]])flag[zz[i]][s[k]-'A']--,up(g[zz[i]]);
	}
	if (l)puts("Yes");
	else puts("No");
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

int counter(ll v, ll x) {
  int cnt = v / x;
  if( v % x == 0 ) --cnt;
  return cnt;
}

int N,K;
vector<ll> A;
bool check(ll x) {
  if( x == 0 ) return false;
  int rem = K;
  rep(i,N) {
    int tmp = counter(A[i],x);
    rem -= tmp;
    if( rem < 0 ) return false;
  }
  return rem >= 0;
}

int main() {
  cin >> N >> K;
  A.resize(N);
  ll maxi = 0;
  rep(i,N) {
    cin >> A[i];
    maxi = max(maxi,A[i]);
  }
  ll L = 0, R = maxi + 10LL;
  while( L + 1LL < R ){
    ll M = ( L + R ) / 2LL;
    if( check(M) ) R = M;
    else           L = M;
  }
  if( check(L) ) printf("%lld\n",L);
  else if( check((L+R)/2) ) printf("%lld\n",(L+R)/2);
  else printf("%lld\n",R);
  
  return 0;
}


Measured memory_bytes: 4776
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000
int main(){
int w;
bool ans[10];
for(int i=0;i<11;i++){
ans[i]=0;
}
while(cin>>w){
for(int i=0;i<11;i++){
ans[i]=0;
}
for(int i=10;i--;){
if(w>=pow(2,i)){
ans[i]=1;
w=w-pow(2,i);
}
}
int i=0;
for(;i<11;i++){
if(ans[i]){
cout<<pow(2,i);
break;
}
}i++;
for(;i<11;i++){
if(ans[i]){
cout<<" "<<pow(2,i);
}
}cout<<endl;
}
return 0;
}

Measured memory_bytes: 1272
void main()
{
    long n, w;
    rdVals(n, w);
    Pair[] pair = n.rdCol!Pair;

    long limit = 10L ^^ 3 * n + 1;
    long[][] dp = new long[][](n+1, limit);
    dp[0][] = inf;
    dp[0][0] = 0;
    foreach (i, p; pair)
    {
        foreach (j; 0 .. limit)
        {
            dp[i+1][j] = dp[i][j];
            if (j - p.b < 0) continue;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-p.b]+p.a);
        }
    }

    foreach_reverse (i, x; dp[n])
    {
        if (x <= w)
        {
            i.writeln;
            return;
        }
    }
}

struct Pair
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 82172
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, i;
	scanf("%d", &N);

	int ans = INF * 2;
	while (N--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		ans = min(ans, t1 + t2);
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1001];
long long s=0;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	 cin>>a[i];
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i+=2)
	 s+=a[i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc082/tasks/arc087_a

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;

int N;
int a[N_MAX];

map<int, int> mp;

void add(int k) {
  if (mp.count(k) == 0) mp[k] = 1;
  else mp[k]++;
}

void solve() {

  REP(i, N) add(a[i]);
  int ans = 0;
  ITR(mp, it) {
    if (it->second < it->first) ans += it->second;
    else ans += it->second - it->first;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
}

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


Measured memory_bytes: 5120
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

ls = p[:x]+q[:y]+r
ls.sort(reverse=True)

print(sum(ls[:x+y]))

Measured memory_bytes: 23328
/* AOJ 0140:Bus Line */
#include <stdio.h>
#include <string.h>
 
int main(){
  char a[]="6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9";
  char *b,*c,*d,e,f;
  int h,i;
  scanf("%d\n",&h);
  for(i=0;i<h;i++){
    scanf("%c %c\n",&e,&f);
    b=strchr(a,e);
    c=strchr(b+1,e);
    d=strchr(b+1,f);
    if(c==NULL || c>d)c=b;
    for(;c<=d;c++) printf("%c",c[0]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 576
from collections import Counter

S = input()
T = input()

counter_s = Counter(S)
counter_t = Counter(T)

# print(counter_s, counter_t)
s_value = sorted(counter_s.values())
t_value = sorted(counter_t.values())

# print(s_value, t_value)
if s_value == t_value:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4016
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  while (x >= b)
    x -= b;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

const int M = 100010;
long long a[M][3];

long long dp[M][3];

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

    rep(i, N) rep(j, 3) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue; // 2日連続で同じ活動はできない
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long ans = 0;
    rep(i, 3) chmax(ans, dp[N][i]);
    cout << ans << endl;
}


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



int main(){
	int n;cin>>n;
	int k ; cin>>k;
	int aa;
	vector<int> arr(n);
	for(int i=0;i<n;i++){
		cin>>aa;
		arr[i] = aa;
	}
	
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		for(int j=1;j<=k;j++)
		if(i-j>=0)
		dp[i] = min(dp[i], dp[i-j] + abs(arr[i]- arr[i-j]));
	}
	
	cout<<dp[n-1];
	
	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    rep(i, len) {
        if (i % 2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

#define MAX 3005

#define int int64_t

int l1, l2, dp[MAX][MAX];
char s1[MAX], s2[MAX];

int f(int i, int j)
{
    if (i == l1 || j == l2)
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    int tmp = max(f(i + 1, j), f(i, j + 1));
    if (s1[i] == s2[j])
        tmp = max(tmp, f(i + 1, j + 1) + 1);
    return dp[i][j] = tmp;
}

void g(int i, int j)
{
    if (i == l1 || j == l2)
        return;
    int tmp, tmp1, tmp2;
    tmp = f(i + 1, j);
    tmp1 = f(i, j + 1);

    if (s1[i] == s2[j])
    {
        if (f(i + 1, j + 1) == f(i, j) - 1)
        {
            printf("%c", s1[i]);
            g(i + 1, j + 1);
        }
    }
    else
    {
        if (tmp > tmp1)
        {
            g(i + 1, j);
        }
        else
        {
            g(i, j + 1);
        }
    }
    // if (i == l1 || j == l2)
    //     return;
    // int tmp = max(f(i + 1, j), f(i, j + 1));
    // if (s1[i] == s2[j])
    //     tmp = max(tmp, f(i + 1, j + 1) + 1);
    // return tmp;
}

signed main()
{
    scanf("%s %s", s1, s2);
    l1 = strlen(s1);
    l2 = strlen(s2);
    for (int i = 0; i <= l1 + 2; i++)
        for (int j = 0; j <= l2 + 2; j++)
            dp[i][j] = -1;
    f(0, 0);
    g(0, 0);
    printf("\n");
}


Measured memory_bytes: 71040
#include<stdio.h>
#include<limits.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define TRUE 1
#define FALSE 0
/*void DFSVisit(int);
  void DFS(void);*/
void BFS(int);
int deQueue(void);
void enQueue(int);
int isEmpty(void);
int G[MAX][MAX];
int D[MAX];
int F[MAX];
int color[MAX];
int Q[MAX];
int n;
int time;
int head = 0, tail = 0;
main(){
  int i, j, m, k, value, start = 1;
  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){

      G[i][j] = 0;

    }
  }

  for(i = 1; i <= n; i++){

    scanf("%d %d", &k, &m);

    for(j = 1; j <= m; j++){

      scanf("%d",&value);

      G[i][value] = 1;
    }
  }
 
  BFS(start);

  for(i = 1; i <= n; i++)
    {
      if(D[i]==INT_MAX)D[i] = -1;
      printf("%d %d\n", i, D[i]);
    }

 return 0;

}




/*void DFS(void){
  int u;

  for( u = 1; u <= n; u++ ){

    color[u] = WHITE;

  }

  time = 0;

 for( u = 1; u <= n; u++ ){
   if( color[u] == WHITE )
     DFSVisit(u);

  }

}

void DFSVisit(int u){
  int v;

  color[u] = GRAY;

  time++;
 
  D[u] = time;

  for(v = 1; v <= n ; v++){

    if(G[u][v] == 1 && color[v] == WHITE)
      DFSVisit(v);
  }
  color[u] = BLACK;

  F[u] = ++time;
  }*/

void BFS(int start){
  int u, v;

  for(u = 2; u <= n; u++ ){

    color[u] =  WHITE;

    D[u] = INT_MAX;

  }

  color[start] = GRAY;

  D[start] = 0;

  enQueue(start);
  while(isEmpty() != FALSE){

    u = deQueue();

    for( v = 1; v <= n; v++ ){
      if(color[v] == WHITE && G[u][v] == 1){

	color[v] = GRAY;

	D[v] = D[u] + 1;

	enQueue(v);
      }
    }
  }
}

void enQueue(int x){

  Q[tail] = x;

    if(tail == 100)tail = 0;
    
    else tail ++; 

}

int deQueue(){

  int x;

  x = Q[head];

  if(head == 100)head = 0;

  else head++;

  return x;
}


int isEmpty(){
  if(tail == head)return FALSE;

  else return TRUE;
}

Measured memory_bytes: 632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b; cin >> a >> b;
	if (a + b >= 10)cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}

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

#define pb      push_back
#define all(v)  v.begin(),v.end()
#define endl    "\n"
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

const int N = 1e5+2;
bool mark[N];
vector<int> v;

struct data{
	ll cost, start, dif;
}arr[505];

int main() {
	ll n;
	scanf("%lld", &n);
	for(int i = 1; i < n; i++) 
		scanf("%lld %lld %lld", &arr[i].cost, &arr[i].start, &arr[i].dif);
	for(int i = 1; i < n; i++) {
		ll cur = 0;
		for(int j = i; j < n; j++) {
			int c = arr[j].cost, s = arr[j].start, t = arr[j].dif;
			if(s >= cur) cur = s;
			else cur = s + ceil((cur-s)/(double)t) * t;
			cur += c;
		}
		printf("%lld\n", cur);
	}
	printf("0\n");
	return 0;
}




Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>

using namespace std;

typedef vector<int> VI;
typedef pair<int, int> P;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int _N = 1e5;

ll n,m;

string s;

VI E[_N];
int color[_N];

int main() {
	omajinai;
	cin >> n >> m;
	REP(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].PB(b);
		E[b].PB(a);
	}

	bool nibu = true;
	int color1 = 0;
	queue<int> q;
	q.push(0);

	while(!q.empty()){
		int i = q.front();
		q.pop();
		if(color[i]==0) color[i] = 2;
		EACH(it, E[i]){
			int j = E[i][it];
			if(color[j] == color[i]){
				nibu = false;
				break;
			}
			if(color[j]) continue;
			color[j] = 3 - color[i];
			if(color[j]==1)color1++;
			q.push(j);
		}
		if(!nibu)break;
	}
	if(nibu){
		cout << (n - color1) * color1 - m << endl;
	}else{
		cout << (n-1ll)*n/2ll - m << endl;
	}

}


Measured memory_bytes: 6272
using System;
using System.Linq;

namespace _2386
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[,] d = new int[n, n];
			for (int i = 0; i < n; i++)
			{
				int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
				for (int j = 0; j < n; j++) d[i, j] = x[j];
			}
			long ret = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = i; j < n; j++)
				{
					ret += Math.Min(d[i, j], d[j, i]);
				}
			}
			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 20304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b-a == c -b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 998244353;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
ll Base = 101;

ll a[Maxn], b[Maxn];
set<pll> st;
ll n;

ll nx(ll i){
	return (i + 1) % n;
}
ll bef(ll i){
	return (i - 1 + n) % n;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		st.insert({-b[i], i});
	}
	ll ans = 0;
	while(!st.empty()){
		ll ind = st.begin() -> S;
		//cerr << ind << '\n';
		st.erase(st.begin());
		if(b[ind] <= a[ind]) continue;
		ll up = max({a[ind], b[bef(ind)], b[nx(ind)]});
		//cerr << ind << ' ' << up << '\n';
		if(up > b[ind]) continue;
		
		ll d = b[bef(ind)] + b[nx(ind)];
		ll stp = (b[ind] - up) / d;
		stp = max(stp, 1LL);
		if(stp > 0){
			b[ind] -= (stp * d);
			if(b[ind] < a[ind]) return cout << -1, 0;
			//cerr << ind << ' ' << b[ind] << '\n';
			st.insert({-b[ind], ind});
			ans += stp;
		}
	}
	for(int i = 0; i < n; i++) if(a[i] != b[i]) return cout << -1, 0;
	cout << ans << '\n';
	return 0; 
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B){
    if(C!=A)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
    
  else if(A==C){ 
    if(B!=C)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;    
  }
   
  else if(C==B){ 
    if(C!=A)
      cout << "Yes" << endl;  
    else
      cout << "No" << endl;    
  }
   
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])

Measured memory_bytes: 3060
N = int(input())
dis_list = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for x1,y1 in dis_list:
    for x2,y2 in dis_list:
        ans += ((x1-x2)**2 + (y1-y2)**2)**0.5
print(ans/N)

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

const int INF = 1001001001;

int main() {
  int h,n;
  cin >> h >> n;
  vector<vector<int>> ab(n,vector<int>(2,0));

  for(auto& v : ab) {
    cin >> v[0] >> v[1];
  }

  vector<vector<int>> dp(n+1,vector<int>(h+1,INF));
 rep(j,h+1) {
   dp[0][j] = ((j + ab[0][0] - 1) / ab[0][0])*ab[0][1];
 }

 rep(i,n) {
   rep(j,h+1){
       if (i == 0) continue;
       dp[i][j] = min(dp[min(i-1,n)][j],dp[i][max(j-ab[i][0],0)]+ab[i][1]);
     }
 }

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


Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
const int N = 10010;
int n,m;
int v[N],d[N];
void solve(){
    int a,b;
    for(int i=1;i<=n;++i){
        scanf("%d%d",&a,&b);
        v[i] = a-b;
        d[i] = a+b;
    }
}
int main()
{
    int a,b;
    cin >> a >> b;
    for(int i=b-a+1;i<=b+a-1;++i){
        printf("%d ",i);
    }printf("\n");
    return 0;
}


Measured memory_bytes: 256