akhauriyash/Code-Regression huggingface dataset:
import sys
import collections
from functools import lru_cache

sys.setrecursionlimit(10 ** 7 + 1)
xy = []
d = collections.defaultdict(list)

@lru_cache(maxsize=None)
def alg_memoization_recursion(f):
    mt = 0
    for v in d[f]:
        mt = max(mt, alg_memoization_recursion(v) + 1)
    return mt


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    for i in range(m):
        x, y = list(map(int, readline().split()))
        d[x-1] += [y-1]
    mt = 0
    for i in range(n):
        mt = max(mt, alg_memoization_recursion(i))
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 151852
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        string a,b,c;
        cin >> a >> b >> c;
        transform(a.begin(),a.end(),a.begin(), ::toupper);
        transform(b.begin(),b.end(),b.begin(), ::toupper);
        transform(c.begin(),c.end(),c.begin(), ::toupper);
        cout << a[0]<<b[0]<<c[0]<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE];
int main(){
    DRI(N);
    REP(i,N){
        RI(a[i]);
    }
    sort(a,a+N);
    int ll=0,rr=N-1;
    while(ll<rr){
        int mm=(ll+rr)/2;
        LL me=0;
        REP(i,mm+1)me+=a[i];
        bool fail=0;
        REPP(i,mm+1,N){
            if(a[i]<=me*2)me+=a[i];
            else{
                fail=1;
                break;
            }
        }
        if(fail)ll=mm+1;
        else rr=mm;
    }
    printf("%d\n",N-ll);
    return 0;
}


Measured memory_bytes: 640
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 15;
const int inf = 1e9 + 7;

int n, m, X;
int c[maxn], a[maxn][maxn];

void read_input()
{
    cin >> n >> m >> X;
    for(int i = 0; i < n; ++i)
    {
        cin >> c[i];
        for(int j = 0; j < m; ++j)
            cin >> a[i][j];
    }
}

void solve()
{
    int ans = inf;
    for(int mask = 0; mask < (1 << n); ++mask)
    {
        vector<int> f(m, 0);
        int cost = 0;
        for(int i = 0; i < n; ++i)
            if(mask >> i & 1)
            {
                cost += c[i];
                for(int j = 0; j < m; ++j)
                    f[j] += a[i][j];
            }
        bool ok = true;
        for(int i = 0; i < m; ++i)
            if(f[i] < X)
            {
                ok = false;
                break;
            }
        if(ok) ans = min(ans, cost);
    }
    if(ans == inf) ans = -1;
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vint a(n), b(n), c(n);
    ll ans=0;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    // rep(i,n) cout << a[i] << " "; cout << endl;
    // rep(i,n) cout << b[i] << " "; cout << endl;
    // rep(i,n) cout << c[i] << " "; cout << endl;

    rep(i,n){
        ll a_idx = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll c_idx = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        ans += a_idx * (n-c_idx);
        // printf("a_i = %d, c_i = %d\n", a_idx, c_idx);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
# Merge Sort
N = int(input())
lst = list(map(int, input().split()))

INF = 10**9 + 1
cnt = 0
def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(INF)  # 番兵
    R = A[mid:right]
    R.append(INF)  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if (L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
        
merge_sort(lst, 0, len(lst))
print(*lst)
print(cnt)


Measured memory_bytes: 63692
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    int c1 = 0, c2 = 0, c4 = 0;
    rep(i,n) {
        cin >> a[i];
        if (a[i] % 2 == 1)
            c1++;
        else if (a[i] % 4 == 0)
            c4++;
        else
            c2++;
    }

    if (n % 2 == 0) {
        if (c2 % 2 == 0 && c1 -c4 <= 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    } else {
        if (c1 - c4 <= 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N;
	cin >>N;
	
	cout << (N-2)*180<< endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String S = sc.next();
		sc.nextLine();
		int K = sc.nextInt();
		String answer = S.replaceAll(String.format("[^%s]", S.substring(K-1,K)), "*");
		System.out.println(answer);
	}
}


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



int main()
{
  int N,L;
  cin >> N >> L;
  int bitten;
  if (L >= 0) {
    bitten = L;
  } else if ( L+N-1 >= 0) {
    bitten = 0;
  } else {
    bitten = L+N-1;
  }
  int tmp;
  tmp = (2*L+N-1)*N/2-bitten;
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,sum=0;
  cin>>N;
  int s[N];
  for(int i=0;i<N;i++){
    cin>>s[i];
    sum+=s[i];
  }
  sort(s,s+N);
  
  for(int i=0;i<N;i++){
    if(sum%10!=0) break;
    else{
      if(s[i]%10!=0)sum-=s[i];
    }
  }
  
  if(sum%10==0) cout<<"0"<<endl;
  else cout<<sum<<endl;
  
}



Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-11-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int rtnmsb(ll v) {
    for (ll i = 63; i >= 0; --i) {
        if(((ll)(1) << i) & v) return i + 1;
    }
    return -1;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int A[1000];
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    vector<ll> sub_sum;
    ll start_sum = sum;
    ll max_sub_sum = 0;
    for (int i = N-1; i >= 0; --i) {
        ll tmp = start_sum;
        for (int s = 0; i + s < N; ++s) {
            sub_sum.push_back(tmp);
            tmp -= A[s];
            tmp += A[s + i + 1];
            max_sub_sum = max(tmp, max_sub_sum);
        }
        start_sum -= A[i];
    }

    sort(sub_sum.begin(), sub_sum.end());
    sub_sum.erase(unique(sub_sum.begin(), sub_sum.end()), sub_sum.end());

    int max_msb = rtnmsb(max_sub_sum);

    // 最上位が確定でk個集まるラインを求める
    vector<ll> cand;
    for (int i = max_msb; i >= 0; --i) {
        int count = 0;
        for (int j = sub_sum.size() - 1; j >= 0; --j) {
            if(rtnmsb(sub_sum[j]) == i){
                count++;
                cand.push_back(sub_sum[j]);
            }
            if(((ll)(1) << (i - 1)) > sub_sum[j]) break;
        }
        if(count >= K){
            max_msb = i;
            break;
        }
    }

    // 先に求めた桁から減らして和を求める
    ll ans = ((ll)(1) << (max_msb - 1));
    for (int i = max_msb - 1; i > 0; --i) {
        vector<ll> tmp;
        int count = 0;

        for (int j = cand.size() - 1; j >= 0; --j) {
            if((cand[j] & ((ll)(1) << (i - 1))) > 0){
                tmp.push_back(cand[j]);
            }
        }

        if(tmp.size() >= K){
            cand = tmp;
            ans += pow(2, i-1);
        }
    }

    cout << ans << "\n";


    return 0;
}



Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int dp[100010][3];
int a[100010][3];
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < N; i++)
    {
        dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
    }
    cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }

    vector<ll> sum(n+1,0);
    rep(i,n) a[i]--;
    rep(i,n) sum[i+1]=sum[i]+a[i];
    rep(i,n+1) sum[i]%=k;

    // debug(sum);

    map<ll,ll> mp;
    rep(i,min(n+1,k)){
        mp[sum[i]]++;
    }

    ll ans=0;
    for(auto x:mp){
        // cout<<x.first<<": "<<x.second<<endl;
        ans+=x.second*(x.second-1)/2;
    }
    for(int i=k;i<=n;i++){
        mp[sum[i-k]]--;
        ans+=mp[sum[i]];
        mp[sum[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
#include "stdio.h"

int num;
int a;
int b;
int in=0;
int out=0;
char letter[100002];
bool flag[100000] = {};
int ans = 0;

int main() {
	scanf("%d %d %d", &num, &a, &b);
	scanf("%s", letter);
	for (int i = 0; i < num; i++) {
		if (letter[i] == 'a') {
			if (in+out<a+b) {
				flag[i] = true;
				in++;
			}
		}
		else if (letter[i] == 'b') {
			if (in + out < a + b&&out < b) {
				flag[i] = true;
				out++;
			}
		}
		if (flag[i])printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main(void)
{
  char input_text;
  
  //input
  cin >> input_text;
  
  switch(input_text){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    default:
      cout << 'ERROR' << endl;
      break;
  }
  
  return 0;
}

Measured memory_bytes: 256
n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
d=[0]*n
for i in range(1,n):
  d[i]=min([d[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])
print(d[n-1])

Measured memory_bytes: 52576
# frozen_string_literal: true

n, w = gets.split.map(&:to_i)

table = Array.new(w + 1, -1)
table[0] = 0
max_wei = 0
n.times do
  weight, value = gets.split.map(&:to_i)

  max_wei.downto(0) do |wei|
    if table[wei] != -1 && wei + weight <= w && table[wei + weight] < table[wei] + value
      table[wei + weight] = table[wei] + value
      max_wei = wei + weight if wei + weight > max_wei
    end
  end
end

puts table.max


Measured memory_bytes: 4604
#include <stdio.h>

int main(void)
{
    int n, m;
    char c;
    int next_i, next_o;
    int i;
    int rensa;
    int ans;
    
    while (1){
        scanf("%d", &n);
        getchar();
        
        if (n == 0){
            break;
        }
        
        scanf("%d", &m);
        getchar();
        
        rensa = 0;
        next_i = 1;
        ans = 0;
        for (i = 0; i < m; i++){
            scanf("%c", &c);
            
            if (next_i == 1 && c == 'I'){
                next_o = 1;
                next_i = 0;
                rensa++;
            }
            else if (next_o == 1 && c == 'O'){
                next_i = 1;
                next_o = 0;
                rensa++;
            }
            else if (next_o == 1 && c == 'I'){
                rensa = 1;
                next_i = 0;
                next_o = 1;
            }
            else {
                rensa = 0;
                next_i = 1;
                next_o = 0;
            }
            
            if (rensa == 2 * n + 1){
                ans++;
                rensa -= 2;
                next_o = 1;
                next_i = 0;
            }
        }
        
        printf("%d\n", ans);
        getchar();
    }
    
    return (0);
}

Measured memory_bytes: 416
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    vi x(5);
    inN(x, 5);

    rep(i, 5)
    {
        if (x[i] == 0)
        {
            outl(i + 1);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;
int n;
int a[101];
int f[100001];
int main()
{
    int k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    f[0]=0;
    for(int i=1;i<=k;i++)
    {
        f[i]=0;
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0)
            {
                f[i]|=!f[i-a[j]];
            }
        }
    }
    if(f[k])
    {
      cout << "First";
    }
    else
    {
      cout << "Second";
    }
    return 0;
}


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

class Kruskal{
    private:
    int V=0,E=0;
    typedef std::pair<std::pair<int,int>,long long> P;
    std::vector<int> UF,rank;
    std::vector<std::pair<std::pair<int,int>,long long>> es;
    
    bool comp(P F,P G){
        return F.second<G.second;
    }
    
    int root(int k){
        if(UF[k]==k){
            return k;
        }else{
            UF[k]=root(UF[k]);
            return UF[k];
        }
    }
    
    bool same(int p,int q){
        return root(p)==root(q);
    }
    
    void unite(int P,int Q){
        int p=root(P);
        int q=root(Q);
        if(p==q)return;
        if(rank[p]<rank[q])std::swap(p,q);
        UF[q]=p;
        if(rank[p]==rank[q])rank[p]++;
    }
    
    public:
    
    
    std::vector<P> solve(std::vector<P> edge){
        //頂点数を決定する
        V=0;
        for(int i=0;i<edge.size();i++){
            V=std::max(V,edge[i].first.first+1);
            V=std::max(V,edge[i].first.second+1);
        }
        //辺数をもとめる　
        E=edge.size();
        //unionfindを初期化する
        UF.clear();
        rank.clear();
        for(int i=0;i<V;i++){
            UF.push_back(i);
            rank.push_back(0);
        }
        //辺をソートして代入しておく
        std::sort(edge.begin(),edge.end(),[&](P x, P y){return comp(x, y);});
        es=edge;
        
        std::vector<P> R;
        for(int i=0;i<E;i++){
            if(!same(es[i].first.first,es[i].first.second)){
                unite(es[i].first.first,es[i].first.second);
                R.push_back(es[i]);
            }
        }
        return R;
    }
    
    //solve:{{int,int},longlong}のvectorを渡すことで最小全域木を返す
};


struct machi{
  int x,y,num;  
};

bool compx(machi F,machi G){
    if(F.x!=G.x){
        return F.x<G.x;
    }else{
        return F.y<G.y;
    }
}
bool compy(machi F,machi G){
    if(F.y!=G.y){
        return F.y<G.y;
    }else{
        return F.x<G.x;
    }
}
 
machi city[114514];

int main(){
    int N,x,y;
    cin >> N;
    
    vector<pair<pair<int,int>,long long>> G;
    
    REP(i,N){
        cin >> x >> y;
        city[i].x = x;
        city[i].y = y;
        city[i].num = i;
    }
    
    sort(city,city+N,compx);
    REP(i,N-1){
        int c=min(abs(city[i].x-city[i+1].x),abs(city[i].y-city[i+1].y));
        G.push_back({{city[i].num,city[i+1].num},c});
    }
    
    sort(city,city+N,compy);
    REP(i,N-1){
        int c=min(abs(city[i].x-city[i+1].x),abs(city[i].y-city[i+1].y));
        G.push_back({{city[i].num,city[i+1].num},c});
    }
    
    Kruskal krus;
    G=krus.solve(G);
    
    int Ans=0;
    REP(i,G.size()){
        Ans+=G[i].second;
    }
    
    cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 16364
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<functional>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define double long double
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int ans[10];
map<pair<int, int>,bool>mp;
int h, w, n, a, b;
signed main(){
	cin >> h >> w >> n;
	ans[0] = (h - 2)*(w - 2);
	rep(i, n) {
		cin >> a >> b;
		mp[{a, b}] = true;
		for (int j = -1; j <= 1; j++) {
			for (int k = -1; k <= 1; k++) {
				int cnt = 0;
				for (int l = -1; l <= 1; l++) {
					for (int m = -1; m <= 1; m++) {
						if (0 >= j + l + a || j + l + a > h || 0 >= k + m + b || k + m + b > w)goto kaage;
						if(mp[{j + l + a, k + m + b}])cnt++;
					}
				}
				ans[cnt - 1]--;
				ans[cnt]++;
			kaage:;
			}
		}
	}
	rep(i, 10)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 156544
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

static const long long INFL = 0x3f3f3f3f;

long long TSP(int n, const vector<vector<long long>> &d) {
        vector<vector<long long>> dp(n, vector<long long> (1 << n, -1));
        function<long long (int, int)> dfs = [&](int u, int remain) {
                if (dp[u][remain] != -1) return dp[u][remain];
                if (!remain && u == 0) return dp[u][remain] = 0;
                long long &ret = dp[u][remain];
                ret = INFL;
                for (int v = 0; v < n; v ++) {
                        if (remain & (1 << v)) {
                                ret = min(ret, dfs(v, remain & ~(1 << v)) + d[u][v]);
                        }
                }
                return ret;
        };
        dfs(0, (1 << n) - 1);
        return dp[0][(1 << n) - 1] == INFL ? -1 : dp[0][(1 << n) - 1];
}

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<vector<long long>> d(n, vector<long long> (n, INFL));
        for (int i = 0; i < m; i ++) {
                int a, b;
                long long c;
                scanf("%d%d%lld", &a, &b, &c);
                d[a][b] = c;
        }
        printf("%lld\n", TSP(n, d));
        return 0;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int ans1, ans2; ans1 = ans2 = 0;
	rep(i, 0, s.size()) {
		if (i % 2 == 0 && s[i] == '1' || i % 2 == 1 && s[i] == '0') ans1++;
		else ans2++;
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

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

// 回答リストを用意しておいて、それとマッチするかどうかを判定する関数を書く。
// 回答リストの数はたかだか2*15 なので多分実時間実行可能

int count_num(vector<int> v, int N){
  int ans = 0;
  for (int i=0; i<N; i++){
    if (v[i] == 1){
      ans++;
    }
  }
  return ans;
}

vector<int> create_v(int n, int N){
  vector<int> v(N);
  for (int i=0; i<N; i++){
    v[i] = n % 2;
    n /= 2;
  }
  return v;
}

int solve(vector<vector<int>> vv, vector<int> v, int N){
  for (int i=0; i<N; i++){
    // 不親切な人の話は聞かない
    if (v[i] == 0) continue;
    for (int j=0; j<N; j++){
      if (vv[i][j] != 2){
        // printf("x:%d, y:%d\n", vv[i][j], v[j]);
        if (vv[i][j] != v[j]){
          // 矛盾している
          return 1;
        }
      }
    }
  }
  return 0;
}

int main(){
  int N;
  cin >> N;
  vector<int> num_test(N, 0);
  vector<vector<int>> table(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      table.at(i).at(j) = 2;
    }
  }

  // ある人に対してどのような証言がなされているかをリストとして集める

  for (int i=0; i<N; i++){
    cin >> num_test[i];
    for (int j=0; j<num_test[i]; j++){
      int x, y;
      cin >> x >> y;
      table[i][x-1] = y;
    }
  }

  // for (int i=0; i<N; i++){
  //   for (int j=0; j<N; j++){
  //     printf("%d ", table[i][j]);
  //   }
  //   printf("\n");
  // }

  int max = 0;
  for (int i=0; i<(int)pow(2, N); i++){
    vector<int> v = create_v(i, N);
    // printf("%d %d %d\n", v[0], v[1], v[2]);
    // printf("solve: %d\n", solve(table, v, N));
    if (solve(table, v, N) == 0){
      int tmp = count_num(v, N);
      // printf("%d\n", tmp);
      if (max < tmp){
        max = tmp;
      }
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 384
# frozen_string_literal: true

N = gets.chomp.to_i

L = if N % 7 == 0
      (9 * N) / 7
    else
      9 * N
    end

num = 10**1 % L

(1..10**6).each do |n|
  if num - 1 == 0
    puts n
    exit
  end
  num = num * 10 % L
end

puts -1


Measured memory_bytes: 14372
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


ll N;
ll g[555][555];
ll clr=0;

void rec(ll l, ll r, ll c) {
  if(l+1==r) return;
  
  ll mid=(l+r)/2;
  rec(l, mid, c+1);
  rec(mid, r, c+1);
  
  ll i, j;
  for(i=l; i<mid; i++) {
    for(j=mid; j<r; j++) {
      g[i][j]=c;
    }
  }
  
  
}

int main(void) {
  ll i, j, k;
  cin >> N;
  
  memset(g, -1, sizeof(g));
  rec(0, N, 1);
  
  for(i=0; i<N; i++) {
    for(j=i+1; j<N; j++) {
      cout << g[i][j] << " ";
    }
    pt("");
  }
  
}



Measured memory_bytes: 2944
a, b, c, d = map(int, input().split())
a_b = max(a, b) - min(a, b) <= d
b_c = max(b, c) - min(b, c) <= d
c_a = max(c, a) - min(c, a) <= d

if (a_b and b_c) or c_a:
    print('Yes')
else:
    print('No')


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, ans = 0;
  string s;
  cin >> n >> s;

  for (int i = 0; i < n - 2; ++i)
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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 MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,ans=1;
  string S;
  cin >> N >> S;
  rep(i,N-1){
    if(S[i]==S[i+1]);
    else ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int a, b; cin >> a >> b;
    cout << a * b << endl;
}


Measured memory_bytes: 3636
N,K = map(int, input().split())
A = list(map(int,input().split()))

binK = bin(K)[2:]
maxbinAsize = 0
ans = 0
B = [0 for _ in [0]*40]

for i in range(N):
    binA = bin(A[i])[2:][::-1]
    maxbinAsize = max(maxbinAsize,len(binA))
    for j in range(len(binA)):
        B[j] = B[j] + int(binA[j])
        
SearchRange = max(len(binK),maxbinAsize)
index = [int(t < N/2) for t in B[:len(binK)][::-1]]

for k in range(SearchRange):
    if k < len(binK):
        ans = ans + max(B[k], N-B[k])*(2**k)
    else:
        ans = ans + B[k]*(2**k)

for l in range(len(binK)):
    if int(binK[l]) > index[l]:
        break
    if int(binK[l]) < index[l]:
        ll = len(index) - l - 1
        ans = ans - abs(N - 2 * B[ll])*(2**ll)
            
print(ans)

Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

	long n;
	cin >> n;
	vector<string> v(n);
	for (long i = 0; i < n; i++)
		cin >> v[i];
	for (long i = 0; i < n; i++)
		sort(v[i].begin(), v[i].end());
	map<string, long> m;
	for (long i = 0; i < v.size(); i++)
	    m[v[i]]++;
	long Count = 0;
	for (auto itr = m.begin(); itr != m.end(); itr++)
	    if (itr->second > 1)
    	    Count += ((itr->second * (itr->second - 1)) / 2);
    cout << Count << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<long> a(n);
  cin >> a[0];
  long num = a[0];
  long long ans = 0;
  for (int i=1; i<n ; i++){
    cin >> a[i];
    if(a[i]<num){
      ans += num - a[i];
    } else {
      num = a[i];
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4768
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var N = o.a();
  var C = o.a();
  var c = Array(C).fill(0).map(a=>[]);
  var tmax = 0;
  for(var i = 0; i < N; i++){
    var t = o.l();
    c[t[2]-1].push([t[0],t[1]]);
    if(tmax < t[1])tmax = t[1];
  }
  var a = [], b = [];
  for(i = 0; i < C; i++){
    c[i].sort((a,b)=>a[0]-b[0]);
    var l = c[i].length;
    for(var j = 0; j < l; j++){
      a.push(c[i][j][0]-1);
      while(j+1 < l && c[i][j][1]+1 >= c[i][j+1][0])j++;
      b.push(c[i][j][1]);
    }
  }
  a.sort((a,b)=>a-b);
  b.sort((a,b)=>a-b);
  var an = 0, bn = 0;
  var ans = 0, v = 0;
  for(i = 0; i <= tmax; i++){
    while(b[bn] === i)v--, bn++;
    while(a[an] === i)v++, an++;
    if(ans < v)ans = v;
  }
  return ans;
}

Measured memory_bytes: 56056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	int n,a;
	string  ans="hon";
	cin >>n;
	a=n%10;
	if (a==0||a==1||a==6||a==8) ans="pon";
	if (a==3) ans="bon";
	cout <<ans<<endl;
	return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long N;
  scanf("%lld", &N);

  ll m = max(H, W);
  put((N + m - 1) / m);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
import math
import math
N = int(input())
N_MAX = 10 ** 7
table = [1]*N

def get_divisors(n):
  num = 0
  ceil = n
  if n == 1:
    return 1
  for i in range(1, n+1):
    q, mod = divmod(n, i)
    if mod == 0: 
      num += 2
      ceil = q
    if i < ceil: break
  print(n, num)
  return num

ans = 0
for i in range(2,N+1):
  for j in range(1,math.floor(N/i)+1):
    table[i*j-1] += 1

for i, div in enumerate(table):
  ans += (i+1)*div
print(ans)

Measured memory_bytes: 151664
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,a,b,i;
cin >>k>>a>>b;
bool flag=false;
for(i=a;i<=b;i++){
    if(i%k==0){
        flag=true;
    }
}
if(flag==true){
    cout <<"OK";
}
else{
    cout<<"NG";
}
}


Measured memory_bytes: 3636
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(n: usize, x: usize, ls: [usize; n]);

    let mut ans = 1;
    let mut cur = 0;
    for i in 0..n {
        cur += ls[i];
        if cur <= x {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;
    if (a < b)
    {
        if (a + v * t >= b + w * t)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    else
    {
        if (a - v * t <= b - w * t)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50, MOD = 1e9 + 7;
struct mat
{
    ll a[N][N];
    mat() : a{} {}
    mat operator * (const mat & b) const
    {
        mat c;
        for (int k = 0; k < N; ++k)
            for (int i = 0; i < N; ++i)
                for (int j = 0; j < N; ++j)
                    (c.a[i][j] += a[i][k] * b.a[k][j]) %= MOD;
        return c;
    }
};
int main()
{
    int n;
    ll k;
    cin >> n >> k;
    mat a, r;
    for (int i = 0; i < n; ++i)
        for  (int j = 0; j < n; ++j) {
            cin >> a.a[i][j];
            r.a[i][j] = i == j;
        }
    for (; k; k >>= 1, a = a * a)
        if (k & 1)
            r = r * a;
    ll ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            ans += r.a[i][j];
    cout << ans % MOD << endl;
}



Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
//////////////////////////////////////////////////////////////////////

int main() {
	ll n, a;
	cin >> n >> a;
	cout << 1 + (n - 1) / (2*a+1) << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0].split(' ').map(n => Number(n))
  const N = input[0]
  const A = input[1]
  const B = input[2]

  const max = A < B ? A : B
  const min = (A + B) - N < 0 ? 0 : (A + B) - N

  console.log(max, min)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21192
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
long long int process(vector<ll>v){
    if(v.size()==0){
        return 0;
    }
    ll val = 0;
    ll curr = 0;
    int state =0;
    vector<ll>p;
    for(int i=0;i<v.size();i++){
        if(state == v[i]%2){
            curr+=v[i];
        }else{
            p.push_back(curr);
            curr = v[i];
            state = v[i]%2;
        }
    }
    p.push_back(curr);
    ll ans = 0;
    for(int i=0;i<p.size();i+=2){
        if(i+1>=p.size()){
            ans = max(ans,v[i]);
        }else if(i+2>=p.size()){
            ans = max(ans,v[i]+v[i+1]);
        }else{
            ans = max(ans,v[i]+v[i+1]+v[i+2]);
        }
    }
    return ans;
}
ll dp[5][200001]{0};
void solve(){
    ll n;cin>>n;
    ll arr[n+1];
    for(int i=0;i<n;i++){
        cin>>arr[i+1];
    }
    for(int i=1;i<=n;i++){
        dp[0][i] = dp[0][i-1] + arr[i];
        ll oo = min(dp[1][i-1],dp[0][i-1]);
        if(arr[i]==0){
            dp[1][i] = oo + 2; 
        }else if(arr[i]%2==0){
            dp[1][i] = oo;
        }else{
            dp[1][i] = oo + 1;
        }
        oo = min(oo,dp[2][i-1]);
        if(arr[i]==0){
            dp[2][i] = oo + 1; 
        }else if(arr[i]%2==1){
            dp[2][i] = oo;
        }else{
            dp[2][i] = oo + 1;
        }
        oo = min(oo,dp[3][i-1]);
        if(arr[i]==0){
            dp[3][i] = oo + 2; 
        }else if(arr[i]%2==0){
            dp[3][i] = oo;
        }else{
            dp[3][i] = oo + 1;
        }
        oo = min(oo,dp[4][i-1]);
        dp[4][i] = oo+arr[i];
    }
    ll ans = 1e18;
    for(int j=0;j<5;j++){
        ans = min(ans,dp[j][n]);
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 13040