akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  ll ans = 0;
  for (int i = 0; i < 60; ++i) {
    ll zero = 0, one = 0;
    ll mask = (1ll << i);
    for (int j = 0; j < n; ++j) {
      if (a[j] & mask) {
        one++;
      } else {
        zero++;
      }
    }
    ll res = mask % MOD * zero % MOD * one % MOD;
    ans += res;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
def depth(u, E):
    ud = [None] * len(E)
    cur = E[u].copy()
    ud[u] = 0
    d = 1
    while cur:
        nxt = []
        for c in cur:
            ud[c] = d
            for i in E[c]:
                if ud[i] is None:
                    nxt.append(i)
        cur = nxt
        d += 1
    return ud

def main():
    N, u, v = list(map(int, input().split()))
    u, v = u - 1, v - 1
    E = [list() for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        E[a - 1].append(b - 1)
        E[b - 1].append(a - 1)

    ud = depth(u, E)
    vd = depth(v, E)
    m = 0
    for i in range(N):
        udi = ud[i]
        vdi = vd[i]
        if udi >= vdi:
            continue
        steps = udi + (vdi - udi) - 1
        m = max(steps, m)
    print(m)



main()


Measured memory_bytes: 27440
#include <iostream>
#include <string>
#define MAX_N 101
using namespace std;

typedef struct{
string name;
int page;
}index;
index a[MAX_N];
index temp;
int n;
int main(){
	n=0;
	while(cin >> a[n].name >> a[n].page){
		n++;
	}

	for(int i=0;i<n-1;i++){
		for(int j=0;j<n-1-i;j++){
			if(a[j].name>a[j+1].name){
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}else if(a[j].name==a[j+1].name&&a[j].page>a[j+1].page){
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	cout << a[0].name << endl;
	cout << a[0].page;
	for(int i=1;i<n;i++){
		if(a[i-1].name!=a[i].name){
			cout <<endl << a[i].name << endl;
			cout <<a[i].page;
		}else if(a[i-1].name==a[i].name){
			cout << " "<<a[i].page;
		}
	}
	cout <<endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <ll>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {

  ll a[3][3],N,b[100];
  bool c[3][3];
    REP(i,3){
        REP(j,3){
            cin >> a[i][j];
            c[i][j] = false;
        }
    }
    cin >> N;
    REP(i,N){
        cin >> b[i];
        REP(j,3){
            REP(k,3){
                if(a[j][k]==b[i]){
                    c[j][k] = true;
                }
            }
        }
    }

    REP(i,3){
        if(c[i][0] && c[i][1] && c[i][2]){
            cout << "Yes";
            return;
        }
        if(c[0][i] && c[1][i] && c[2][i]){
            cout << "Yes";
            return;
        }
    }
    if(c[0][0] && c[1][1] && c[2][2]){
            cout << "Yes";
            return;
    }
    if(c[2][0] && c[1][1] && c[0][2]){
            cout << "Yes";
            return;
    }
    cout << "No";
}

signed main() {
    

    solve();

    return 0;
}

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

int main() {
  int x, y, s;

  while(cin >> x >> y >> s, x+y+s) {
    int maxt = -1;
    for(int i = 1; i < s-1; i++) {
      for(int j = 1; j < s-1; j++) {
        int xt = i*(x+100) / 100;
        xt += j*(x+100) / 100;
        if(xt > s) break;
        else if(xt == s) {
          int yt = i*(y+100) / 100;
          yt += j*(y+100) / 100;
          maxt = max(yt, maxt);
        }
      }
    }
    cout << maxt << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	map<char,char> mp1,mp2;
	rep(i,n){
		if(mp1.count(s[i])){
			if(t[i]!=mp1[s[i]]){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			mp1[s[i]]=t[i];
		}
		if(mp2.count(t[i])){
			if(s[i]!=mp2[t[i]]){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			mp2[t[i]]=s[i];
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 916
import numpy as np

a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

n = 0
i = 0
while i * 500 <= x and i <= a:
    if i * 500 == x:
        n += 1
#        print 10
    else:
        y = x - i * 500
        j = 0
        while j * 100 <= y and j <= b:
            if j * 100 == y:
                n += 1
#                print 20
            else:
                z = y - j * 100
                if z / 50 <= c:
                    n += 1
#                    print 30
            j += 1
    i += 1

print n


Measured memory_bytes: 10512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, x;
  cin >> n >> x;
  int bf;
  ll ans = 0;
  rep(i, n){
    int in;
    cin >> in;
    if(i == 0){
      if(in > x){
        ans += in - x;
        in = x;
      }
    }else{
      if(bf + in > x){
        ans += bf + in - x;
        in = x - bf;
      }
    }
    bf = in;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/24 13:37:46 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	n;
	cin >> n;
	vector<vector<int>>	V(n, vector<int>(26));
	rep(i, n)
	{
		string	s;
		cin >> s;

		rep(j, 10)
			V.at(i).at(s.at(j) - 'a')++;
	}
	sort(V.begin(), V.end());
	ll	sum;
	sum = 0;
	int i;
	i = 0;
	while (i < n)
	{
		ll	cnt;
		cnt = 1;
		while (i < n - 1 && V.at(i) == V.at(i + 1))
		{
			i++;
			cnt++;
		}
		if (cnt != 1)
			sum += cnt * (cnt - 1) / 2;
		i++;
	}
	cout << sum << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int n;
long long ans;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1, pre = 0, x; i <= n; i++) {
		cin >> x;
		if(x && pre) {
			x--;
			pre = 0;
			ans++;
		}
		ans += x >> 1;
		pre = x & 1;
	}
	cout << ans;
}


Measured memory_bytes: 256
input_ = input()
length = int(len(input_))
if length%2==0:
  print('No')
  exit(0)
f,b = input_[:int((length-1)/2)],input_[int((length-1/2)):]
str_ = [input_,f,b]
for s in str_:
  #print(s)
  if s==''.join(list(reversed(s))): pass
  else:
    print('No')
    exit(0)
print('Yes')

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

template <std::int64_t M>
class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept : a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

// L<=X<=Y<=R と Y%X = Y^X が条件
// まず場合分けをする
// 1) X = Y の場合、Y%X = Y^X == 0 なのでOK
// 2) X < Y の場合
//  2A) 2進数でXとYの桁数が同じ
//    Y^X = Y+X-2(Y&X)
//    Y%X = Y-X なぜならX<Y<2XよりY/X=1なので
//    つまり、X = X ^ Y
//    ある桁においてX=1でY=0はNG（そのほかの3つの場合でOK）
//  2B) 2進数でXとYの桁数が同じ
//    NG Y%Xは1から始まり、MODは0から始まるため

// dp[i][j][k][s]: 上からi桁番目まで見た時の個数。 
// jはX>=Lが確定しているかどうか
// kはY<=Rが確定しているかどうか
// sは先頭ビットが既に現れたかどうか

using mint = modint<1000000007>;
mint dp[64][2][2][2];

signed main() {
  ll L, R;
  cin >> L >> R;

  dp[63][0][0][0] = mint(1);
  for (ll i = 63; i>=1; i--) rep(j,2) rep(k,2) rep(s,2) {
    mint cur = dp[i][j][k][s];

    rep(x,2) rep(y,2) {
      if (x == 1 && y == 0) continue;

      ll ni = i - 1, nj = j, nk = k, ns = s;
      ll lb = (L>>ni) & 1;
      ll rb = (R>>ni) & 1;

      // j: X>=Lの判定
      if (!nj && lb == 1 && x == 0) continue;
      if (lb == 0 && x == 1) nj = 1;

      // k: Y<=Rの判定
      if (!nk && rb == 0 && y == 1) continue;
      if (rb == 1 && y == 0) nk = 1;

      // s: 先頭ビットが既出か判定
      if (!ns && (x^y == 1)) continue;
      if (x == 1 && y == 1) ns = 1;

      dp[ni][nj][nk][ns] += cur;
    }
  }

  mint ans(0);
  rep(j,2) rep(k,2) rep(s,2) {
    ans += dp[0][j][k][s];
  }
  cout << ans.value() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;

const int MAX_N = 50;
ll x[MAX_N];
ll y[MAX_N];

int main() {
    int N; cin >> N;
    rep(i,N) cin >> x[i] >> y[i];
    ll p, q;
    int ans = N;
    rep(i,N) {
        rep(j,N) {
            if(i <= j) continue;
            int cnt = 0;
            p = x[i] - x[j];
            q = y[i] - y[j];
            rep(k,N) rep(l,N) if(x[k]-p == x[l] && y[k]-q == y[l]) ++cnt;
            chmin(ans, N - cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b;cin>>a>>b;
    cout<<a*b-(a+b-1)<<endl;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
typedef long long int lli;
int main(void)
{
    int a[3];
    int b,c;

    scanf("%d %d",&b,&c);
    a[b-1]=1;
    a[c-1]=1;
    for(int i=0;i<3;i++){
        if(a[i]!=1){
            printf("%d\n",i+1);
            break;
        }
    }
    
    return 0;
}
//oo

Measured memory_bytes: 128
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
a, b = [-1]*2
for i,p in enumerate(permutations(range(1,N+1))):
  if a>0 and b>0: break
  if p == P: a = i
  if p == Q: b = i
print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 int main(){
     int N;cin>>N;
     string s;cin>>s;
     int res=0;
     for(int i=0;i+2<N;i++){
         if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')res++;
     }
     cout<<res<<endl;
    }
        






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int N;
int f(int x, int y) {
    if (x > y) swap(x, y);
    return x * N + y;
}
int main() {
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    for (auto &row : A) for (auto &a : row) cin >> a, a--;
    vector<vector<int>> G(N*N);
    vector<int> cnt(N*N);
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < N-1; j++) {
            G[f(i, A[i][j-1])].push_back(f(i, A[i][j]));
            cnt[f(i, A[i][j])]++;
        }
    }
    set<int> S;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (cnt[i * N + j] == 0) {
                S.insert(i * N + j);
            }
        }
    }
    int ans = 0;
    int used = 0;
    while (!S.empty()) {
        ans++;
        vector<int> B(N), add;
        for (auto it = S.begin(); it != S.end();) {
            int item = *it;
            int x = item / N, y = item % N;
            if (B[x] == 0 && B[y] == 0) {
                B[x] = B[y] = 1;
                used++;
                for (auto next : G[item]) {
                    cnt[next]--;
                    if (cnt[next] == 0) {
                        add.push_back(next);
                    }
                }
                it = S.erase(it);
            } else {
                ++it;
            }
        }
        for (auto &a : add) S.insert(a);
    }
    if (used != N * (N - 1) / 2) ans = -1;
    cout << ans << '\n';
    return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

#define MAX_N 100010

int V,E,Q;
vint G[MAX_N];
vint rG[MAX_N];
vint vs;
bool used[MAX_N];
int cmp[MAX_N];
int a,b;

void add_edge(int from,int to){
    G[from].pb(to);
    rG[to].pb(from);
}

void dfs(int v){
    used[v]=true;
    rep(i,0,G[v].size()){
        if(!used[G[v][i]])dfs(G[v][i]);
    }
    vs.pb(v);
}

void rdfs(int v,int k){
    used[v]=true;
    cmp[v]=k;
    rep(i,0,rG[v].size()){
        if(!used[rG[v][i]])rdfs(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    rep(v,0,V){
        if(!used[v])dfs(v);
    }
    memset(used,0,sizeof(used));
    int k=0;
    rrep(i,0,vs.size()){
        if(!used[vs[i]])rdfs(vs[i],k++);
    }
    return k;
}

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>V>>E;
    rep(i,0,E){
        cin>>a>>b;
        add_edge(a,b);
    }
    
    scc();
    
    cin>>Q;
    rep(i,0,Q){
        cin>>a>>b;
        if(cmp[a]==cmp[b])cout<<1<<endl;
        else cout<<0<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


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

int li[2][200200];
map<pair<int,int>,int> mp;

int fi(int s,int nw)
{
    if(li[s][nw]==nw)return nw;
    return li[s][nw]=fi(s,li[s][nw]);
}

void uni(int s,int la,int lb)
{
    li[s][la]=lb;
}

main()
{
    int n,k,l;
    scanf("%d %d %d",&n,&k,&l);
    for(int i=0;i<=n;i++)
        li[0][i]=li[1][i]=i;
    for(int i=0;i<k;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        if(fi(0,a)!=fi(0,b))
            uni(0,fi(0,a),fi(0,b));
    }
    for(int i=0;i<l;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        if(fi(1,a)!=fi(1,b))
            uni(1,fi(1,a),fi(1,b));
    }
    for(int i=1;i<=n;i++)
        mp[{fi(0,i),fi(1,i)}]++;
    for(int i=1;i<=n;i++)
        printf("%d ",mp[{fi(0,i),fi(1,i)}]);
}


Measured memory_bytes: 13568
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
const int MOD = 1e9 + 7;
int n;
string s;
int d[maxn];

void ReadInput()
{
    cin >> n;
    cin >> s;
}

void Solve()
{
    if(s[2 * n - 1] == 'W' || s[0] == 'W')
    {
        cout << "0\n";
        return;
    }
    d[0] = 0;
    for(int i = 1; i < 2 * n; ++i)
        d[i] = s[i] == s[i - 1] ? d[i - 1] ^ 1 : d[i - 1];
    int ans = 1;
    int cnt = 0;
    for(int i = 2 * n - 1; i >= 0; --i)
    {
        if(d[i] == 0)
        {
            ans = 1LL * ans * cnt % MOD;
            --cnt;
        }
        else ++cnt;
    }

    if(cnt != 0)
    {
        cout << "0\n";
        return;
    }

    for(int i = 1; i <= n; ++i)
        ans = 1LL * ans * i % MOD;

    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 1360
#include<cstdio>

int main() {
	int w, h, x, y;
	scanf("%d%d%d%d", &w, &h, &x, &y);
	printf("%.10lf %d\n", 1.*w*h/2, (x*2==w && y*2==h) ? 1 : 0);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
    cin>>arr[i];
   sort(arr,arr+n,greater<int>());
   long long int sum=0;
   for(int i=0;i<k;i++)
   {
    sum=sum+arr[i];
   }
   cout<<sum;



 return 0;
}








Measured memory_bytes: 3668
n, t = map(int, input().split())
time = list(map(int, input().split()))
sub_list = []
for i in range(1,n):
    sub_list.append(time[i] - time[i-1])

not_water = 0
for i in sub_list:
    if i > t:
        not_water += (i - t) 
print(time[-1] + t - not_water)


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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		int cl = 0, ol = 0, cd = 0, od = 0, cm = 0, om = 0;
		rep(i, n) {
			int h, m, M; scanf("%d:%d%d", &h, &m, &M);
			if (m > M)M += 60;
			if (660 <= h * 60 + m&&h * 60 + m < 900) {
				cl++;
				if (M - m <= 8)ol++;
			}
			if (1080 <= h * 60 + m&&h * 60 + m < 1260) {
				cd++;
				if (M - m <= 8)od++;
			}
			if (1260 <= h * 60 + m || h * 60 + m < 120) {
				cm++;
				if (M - m <= 8)om++;
			}
		}
		printf("lunch ");
		if (!cl)puts("no guest");
		else printf("%d\n", ol * 100 / cl);
		printf("dinner ");
		if (!cd)puts("no guest");
		else printf("%d\n", od * 100 / cd);
		printf("midnight ");
		if (!cm)puts("no guest");
		else printf("%d\n", om * 100 / cm);
	}
}

Measured memory_bytes: 3164
n, m, q=map(int, input().split())
l=[]
for _ in range(q):
  l.append(list(map(int, input().split())))
#print(l)
import itertools as itl
gl=list(range(1, m+1))  # 1からmのリスト
#print(gl)          
ans=0
for v in itl.combinations_with_replacement(gl, n): #1からのなかから、n個抽出
  check=0
  for i in range(q):
    if v[l[i][1]-1]-v[l[i][0]-1]==l[i][2]:
      check+=l[i][3]
  ans=max(check, ans)
print(ans)
    
                                   

Measured memory_bytes: 9200
N=int(input())
W=list(map(int,input().split()))
SAM=0
ans=0
flag=0

for i in range(0,N):
    SAM+=W[i]

ans=SAM/2

for i in range(0,N):
    ans-=W[i]
    if ans<=0:
        if abs(ans+W[i])<abs(ans):
            flag=i-1
            break;
        else :
            flag=i
            break;

A=0
B=0

for i in range(0,flag+1):
    A+=W[i]
for i in range(flag+1,N):
    B+=W[i]

print(abs(A-B))

Measured memory_bytes: 3064
#include <stdio.h>
#include<iostream>
using namespace std;
  
int main() {
  
    int v, i, j,k, N;
    int A[100];
  
    cin >> N;
  
    for (i = 0; i < N ; i++)
        cin >> A[i];
 
    cout << A[0];
 
    for (k = 1; k < N; k++)
        cout << " " << A[k];
    cout << endl;
 
  
    for (i = 1; i < N ; i++) {
  
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        cout << A[0];
    for (k = 1; k < N; k++)
        cout << " " << A[k];
    cout << endl;
    }
  
}





 

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

typedef struct node{
	int key;
	struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void insert(int k);
Node* find(int k);
void delete(int k);
void inOrder(Node *x);
void preOrder(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(x);

		}else if(com[0]=='p'){
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else if(com[0]=='f'){
			scanf("%d",&x);
			if(find(x)!=NIL)printf("yes\n");
			else printf("no\n");
		}else{
			scanf("%d",&x);
			delete(x);
		}
	}
	return 0;
}

void insert(int k){
	Node *y=NIL, *x=root, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=NIL;	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==NIL)root=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

Node* find(int k){
	Node* p=root;

	while(p!=NIL){
		if(p->key==k){
			return p;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}

	return NIL;
}

void delete(int k){
	Node *tgt=find(k),*del,*ch;

	if(tgt->left==NIL || tgt->right==NIL){
		del=tgt;
	}else{
		del=tgt->right;
		while(del->left!=NIL)del=del->left;
	}

	if(del->left!=NIL){
		ch=del->left;
	}else{
		ch=del->right;
	}
	if(ch!=NIL)	ch->parent=del->parent;

	if(del->parent==NIL){
		root=ch;
	}else{
		if(del==del->parent->left){
			del->parent->left=ch;
		}else{
			del->parent->right=ch;
		}
	}

	if(del!=tgt)tgt->key=del->key;

	free(del);
	return;
}

void inOrder(Node* x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node* x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}


Measured memory_bytes: 20452
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <memory>

using namespace std;

struct before_main {before_main() {cin.tie(0); ios::sync_with_stdio(false);}} before_main;

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

typedef long long ll;

typedef shared_ptr<struct tree> tree_ptr;

struct tree {
  string s;
  vector<tree_ptr> children;
  ll num = 1;
  tree() = default;
  tree(string s, ll num): s(s), num(num) {}
};

ll read_k(string& s) {
  stringstream ss(s);
  int x; string t; ss >> x >> t;
  s = t;
  return x;
}

string read_s(string& s) {
  int n = s.size();
  string t;
  int last = -1;
  bool br = 0;
  rep(i, n) {
    last = i;
    if (!isalpha(s[i])) { br = 1; break; }
    t.push_back(s[i]);
  }
  if (br) s = s.substr(last);
  else s = "";
  return t;
}

void consume(string& s, char expected) {
  if (s[0] != expected) {
    cout << "Expected: " << expected << endl;
    cout << "Remain: " << s << endl;
    assert(0);
  }
  s = s.substr(1);
}

void dfs(string& s, tree_ptr curr) {
  for (; !s.empty();) {
    if (isdigit(s[0])) {
      ll ck = read_k(s);
      if (isalpha(s[0])) {
        auto c = make_shared<tree>();
        c->num = ck;
        c->s = read_s(s);
        curr->children.push_back(c);
      }
      else {
        consume(s, '(');
        auto c = make_shared<tree>();
        curr->children.push_back(c);
        c->num = ck;
        dfs(s, c);
        consume(s, ')');
      }
    }
    else {
      auto c = make_shared<tree>();
      c->s = read_s(s);
      c->num = 1;
      curr->children.push_back(c);
      if(!s.empty() && !isdigit(s[0])) { return; }
    }
  }
}

string ans;

void visit(tree_ptr curr) {
  if(ans.size() >= 1000001) { return; }
  rep(i, curr->num) {
    if (curr->children.empty()) {
      ans += curr->s;
      if(ans.size() >= 1000001) { return; }
    }

    rep(i, curr->children.size()) {
      visit(curr->children[i]);
    }
  }
}

char solve(string& s, int idx) {
  auto root = make_shared<tree>();
  dfs(s, root);
  ans.clear();
  visit(root);
  if(ans.size() <= idx) { return '0'; }
//  cout << ans << endl;cout << ans.size() << " / " << idx << endl;
  return ans[idx];
}

int main() {

  while (1) {
    string s; cin >> s;
    int idx; cin >> idx;
    if (s == "0" && idx == 0) { break; }
    cout << solve(s, idx) << endl;
  }

  return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int c[3] = {0,0,0};
  ll ans = 1;
  for(int i=0; i<n; ++i){
    int cnt = 0;
    int cnum = 3;
    if(c[0] == an[i]){ ++cnt; cnum = 0;}
    if(c[1] == an[i]){ ++cnt; cnum = 1;}
    if(c[2] == an[i]){ ++cnt; cnum = 2;}
    if(cnum == 3){ ans = 0; break;}
    ++c[cnum];
    ans *= cnt;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import math

N, H = map(int, input().split())
ab=[]
for _ in range(N):
    ab.append(tuple(map(int, input().split())))
A = [el[0] for el in ab]
M=max(A)
B=[el[1] for el in ab if el[1]>M]

throw=sum(B)

if H>throw:

    print(math.ceil((H-throw)/M) + len(B))
else:
    B.sort(reverse=True)
    for i in range(N-1):
        if B[i]>=H:
            print(i+1)
            break
        B[i+1]+=B[i]
    else:
        print(N)


Measured memory_bytes: 66264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		int cnt = 1;
		int tap = 0;

		while (cnt < b) {
			tap++;
			cnt = cnt + (a - 1);
		}

		System.out.println(tap);
	}

}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  ll a, b, t;
  cin >> a >> b >> t;
  cout << t/ a * b << endl;
}


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

int a[200005];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int x = a[0];
    for(int i = 1; i < n; ++i){
        x = __gcd(x, a[i]);
    }
    cout << x << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    string s;cin>>s;
    if(s=="Sunny")
    cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
    cout<<"Rainy"<<endl;
    else
    cout<<"Sunny"<<endl;
}
int32_t main()
{
         rapido;
         int t;
         //cin>>t;
         t=1;
         while(t--)
         solve();
}

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

int main()
{
    long long answer = 0;
    long long n, k;
    cin >> n >> k;
    if(k == 0){
        cout << n * n << endl;
        return 0;
    }
    for(long long i = k + 1; i <= n; i++){
        long long loop = i - k;
        answer += loop * (n / i);
        if((n - (n / i) * i + 1) - k > 0){
            answer += (n - (n / i) * i + 1) - k;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let a:u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	let b:u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	if (a+b) % 2 == 0 {
		println!("{}", (a+b)/2);
	}else{
		println!("IMPOSSIBLE");
	}
}

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

int main(void){
  int num;
  cin >> num;
  num = num % 10;
  if(num == 3){
    cout <<"bon" <<endl;
  }
  if(num == 0 or num == 6 or num == 1 or num == 8){
    cout << "pon"<< endl;
  }
  if(num==2 or num == 4 or num == 5 or num == 7 or num==9){
    cout <<"hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<int, string> PSI;

int n, m;

int b[1100];
double x[1100], y[1100];
int s, g;

double d[1100];
int pre[1100];

double distance(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

struct edge{
	int to;
	double cost;
};

vector<edge> ve[1100];

void djikstra(){
	fill(d, d + 1100, INF);
	fill(pre, pre + 1100, -1);

	priority_queue< pair<double,int> > que;
	
	d[s] = 0;
	que.push({ d[s], s });

	while (!que.empty()){
		pair<double, int> p = que.top();
		que.pop();
		int v = p.second;

		if (d[v] < p.first)continue;

		REP(i, ve[v].size()){
			edge e = ve[v][i];
			if (d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push({ d[e.to], e.to });
				pre[e.to] = v;
			}
		}
	}
}

int main(){
	while (cin >> n&&n){
		REP(i, 1100)ve[i].clear();
		REP(i, n){
			cin >> b[i] >> x[i] >> y[i];
		}
		REP(i, n){
			REP(j, n){
				double dis = distance(x[i], y[i], x[j], y[j]);
				if (i != j&&dis - 50 < EPS){
					ve[b[i]].push_back({ b[j], dis });
				}
			}
		}
		cin >> m;
		REP(i, m){
			cin >> s >> g;
			djikstra();
			int v = g;
			if (pre[v] == -1){
				cout << "NA" << endl;
				continue;
			}
			vector<int> vi;
			vi.push_back(g);
			while (pre[v] != -1){
				vi.push_back(pre[v]);
				v = pre[v];
			}
			reverse(ALL(vi));
			REP(i, vi.size()){
				if (i == 0)cout << vi[i];
				else cout << " " << vi[i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1316
A,B=map(int,input().split())

answer=0
for i in range(A,B+1):
  list_i=list(str(i))
  list_i_reverse=list_i[::-1]
  if tuple(list_i)==tuple(list_i_reverse):
    #print(i)
    answer+=1
    
print(answer)

Measured memory_bytes: 2940
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[17][17];
int main(){
    for(int i=1;i<=9;++i)
        for(int j=1;j<=9;++j)
            a[i][j]=i*j;
    int n;
    cin>>n;
    for(int i=1;i<=9;++i)
        for(int j=1;j<=9;++j)
            if(a[i][j]==n){
                cout<<"Yes";
                return 0;
            }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int L[2*N];
  int i,j,k,tmp,x=0;
  for(i=0;i<2*N;i++)
  scanf("%d ",&L[i]);
  
  for (i=0; i<2*N; ++i) {
    for (j=i+1; j<2*N; ++j) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
  
  for(i=0;i<2 * N;i+=2){
    x += L[i];
  }
  
  printf("%d\n",x);
  
  return 0;
}

Measured memory_bytes: 384
n = input()
K = int(input())
len_n = len(n)
ans = 0
#自由な数字を選んでいいのかどうか？、今使った0以外、今の桁数
def calc(free, count, now):
    global ans
    if count == K:
        ans += 1
        return
    if now == len_n:
        return 
    if free:
        for _ in range(9):
            calc(free, count + 1, now+1)
        #この数字を0にするとき
        calc(free, count, now+1)
    else:
        #自由に数字選べない時
        if n[now] != '0':
            for _ in range(int(n[now])-1):
                calc(not free, count + 1, now+1)
            #この数字を元の数字と同じ
            calc(free, count+1, now+1)
        #このすうじを0にする
            calc(not free, count, now+1)
        else:
            calc(free, count, now+1)
calc(False,0,0)
print(ans)

Measured memory_bytes: 83804
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    for (int a = 0; a <= 100; a++) {
        int b = x - a;
        if (b < 0) continue;
        int c = a * 2 + b * 4;
        if (c == y) {
            cout << "Yes" << endl;
            ret();
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3624
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B,C = map(int, readline().split())
print(min(B//A,C))


Measured memory_bytes: 17860
n = int(input())
loss = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    loss.append((c,s,f))

for i in range(n-1):
    time = 0
    for j in range(i,n-1):
        if time < loss[j][1]:
            time = loss[j][1]
        if (time-loss[j][1])%loss[j][2] != 0:
            time += loss[j][2]-(time-loss[j][1])%loss[j][2]
        time += loss[j][0]
    print(time)
print(0)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>
#define int long long 

using namespace std;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=INT64_MAX;
static const int mod=1000000007;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

int N;
int A[200005],B[200005];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i]>>B[i];
    sort(A,A+N);
    sort(B,B+N);
    if(N%2==1){
        int mi=A[N/2],ma=B[N/2];
        cout<<ma-mi+1<<endl;
    }
    else {
        int mi=A[N/2-1]+A[N/2],ma=B[N/2-1]+B[N/2];
        cout<<ma-mi+1<<endl;
    }
}

Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    vector<int> index(4,0);
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(s[i]==s[j]){
                index[i]++;
            }
        }
    }
    for(int i=0;i<4;i++){
        if(2!=index[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	string check = "APPROVED";
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2 == 0){
			if(a % 3 != 0 && a % 5 != 0){
				check = "DENIED";
			}
		}
	}
	cout << check << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int line = sc.nextInt();
      if (line == 22){
        System.out.print("Christmas Eve Eve Eve");
      } else if (line == 23) {
        System.out.print("Christmas Eve Eve ");
      } else if (line == 24){
        System.out.print("Christmas Eve");
      }else if (line == 25){
        System.out.print("Christmas");
      }
    
    }
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main(void)
{
    char c[3][4];
    int i, j;

    for(i=1; i<=2; i++){
        for(j=1; j<=3; j++){
            cin >> c[i][j];
        }
    }

    if(c[1][1]==c[2][3] && c[1][2]==c[2][2] && c[1][3]==c[2][1]){
        cout << "YES" << endl;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int r, D, x;
    cin >> r >> D >> x;
    REP(i, 10)
    {
        x = r * x - D;
        cout << x << endl;
    }

    // system("pause");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	
	int n, k;
	cin >> n>>k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	int ans = ((n-1) / (k - 1)) + (((n-1) % (k - 1) == 0) ? 0 : 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        char[] A = a.toCharArray();
        int n = A.length;
        HashSet<Character> dic = new HashSet<>();
        ArrayList<int[]> interval = new ArrayList<>();
        int right = n-1;
        for(int i=n-1;i>=0;i--){
            dic.add(A[i]);
            if(dic.size()==26){
                interval.add(new int[]{i,right});
                right = i-1;
                dic = new HashSet<>();
            }
        }
        int tot = interval.size();
        if(tot==0){
            System.out.println(helper(A,0,A.length-1));
            System.exit(0);
        }
        StringBuilder res = new StringBuilder();
        int[] next = interval.get(tot-1);
        char cur = helper(A,0,next[0]-1);
        res.append(cur);
        for(int i=1;i<=tot;i++){
            int idx = find(A,next[0],cur);
            cur = helper(A,idx+1,next[1]);
            res.append(cur);
            if(i<tot) next = interval.get(tot-i-1);
        }
        System.out.println(res.toString());
    }
    static char helper(char[] A, int left, int right){
        int[] cnt = new int[26];
        for(int i=left;i<=right;i++) cnt[A[i]-'a']++;
        for(int i=0;i<26;i++){
            if(cnt[i]==0) return (char)(i+'a');
        }
        return 'z';
    }
    static int find(char[] A, int left, char target){
        for(int i=left;i<A.length-1;i++){
            if(A[i]==target) return i;
        }
        return A.length;
    }
}


Measured memory_bytes: 40652
N = int(input())
S = str(input())
count = [S[1:].count('E')]
for i in range(1, N):
	add = 0
	if S[i] == 'E':
		add -= 1
	if S[i-1] == 'W':
		add += 1
	count.append(count[i-1]+add)
print(min(count))

Measured memory_bytes: 15564