akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class BBounding {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n,x;
        cin >> n >> x;

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

        vector<int> nums = {0};
        int t = 0;


        for (int i = 0; i < n; ++i) {
            t += a[i];
            nums.push_back(t);
        }

        int ans = 0;
        for (int i = 0; i < nums.size(); ++i) {
            if (nums[i]  <= x){
                ans++;
            }
        }
        cout << ans << endl;
	}
};


int main() {
	BBounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())
 
if A == B:
    print("YES")
    exit()
 
if V == W:
    print("NO")
    exit()
 
time = abs(A - B) / (V - W)
if 0 <= time and time <= T:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 61856
from math import gcd
if __name__ == "__main__":
    n = int(input())

    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                tmp = gcd(i, j)
                tmp = gcd(tmp, k)
                ans += tmp

    print(ans)


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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, t;
    cin >> n >> t;
    vector<Int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<Int> ma = a;
    rrep(i, n, 1) ma[i - 1] = max(ma[i - 1], ma[i]);
    map<Int, Int> mp;
    rep(i, 0, n - 1) {
        //cout << ma[i + 1] << " " << a[i] << endl;
        mp[ma[i + 1] - a[i]]++;
    }
    dump((*mp.rbegin()).se);
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 30;
const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int N, M; cin >> N >> M;
    VLL x(N), y(N), z(N); REP(i,N) cin >> x[i] >> y[i] >> z[i];

    ll ans = -INF;
    for (int bit = 0; bit < (1 << 3); bit++) {
        ll a = (bit & (1 << 0)) ? -1 : 1;
        ll b = (bit & (1 << 1)) ? -1 : 1;
        ll c = (bit & (1 << 2)) ? -1 : 1;
        VLL d(N);
        REP(i, N) d[i] = a * x[i] + b * y[i] + c * z[i];
        RSORT(d);
        ll total = 0;
        REP(i, M) total += d[i];
        ans = max(ans, total);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
typedef pair<ll, ll> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,x,y,k,t,n,z,c,d,r;
     
           ld a,b,h,m;
           cin>>a>>b>>h>>m;
           ld ang=5.5*(h*(60.0)+m);
           ang*=(3.1415926535897);
           ang/=(180.0);
           ld t1=b*sin(ang);
           ld t2=b*cos(ang);
           ld ans=sqrt((t1*t1+(a-t2)*(a-t2)));
           cout<<fixed<<setprecision(10)<<ans;
    return 0;
 
    
}

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

string s;
void solve(){
    cin >> s;
    int n = (int)s.size();
    if(n == 2) {
        if(s[0] == s[1])
            cout << 1 << " " << 2 << "\n";
        else
            cout << -1 << " " << -1 << "\n";
        return;
    }
    auto ok = [&](int i) {
        return (s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]);
    };
    for(int i=0;i+2<n;++i) {
        if(ok(i)) {
            cout << i+1 << " " << i+2+1 << "\n";
            return;
        }
    }
    cout << "-1 -1\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3756
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(int argc,char** argv)
{
 
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if( A == B ){
		printf("%d\n", C);
	}
	else if ( A == C ){
		printf("%d\n", B);
	}
	else{
		printf("%d\n", A);
	}
	return(0);
 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,X,M,i=1,ans;cin>>N>>X>>M;vector<ll>S(M,-1);
  S.at(X)=0;ll A[min(N,M+1)],B[min(N,M+1)];A[0]=X;B[0]=X;
  while(i<N){
    A[i]=A[i-1]*A[i-1]%M;B[i]=B[i-1]+A[i];
    if(S.at(A[i])!=-1)break;S.at(A[i])=i;i++;
  }
  if(i<N){
    ans=B[S.at(A[i])];N-=S.at(A[i])+1;ll T=i-S.at(A[i]),SUM=B[i]-B[S.at(A[i])];
    ans+=N/T*SUM+B[S.at(A[i])+N%T]-B[S.at(A[i])];
  }
  else ans=B[N-1];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4796
import numpy as np
N = int(input())
A = list(map(int, input().split()))

Even = A[0::2]
Odd = A[1::2]

list1 = []
ans = sum(Even)-sum(Odd)
list1.append(int(ans))

for i in range(len(A)-1):
  ans = -ans + 2*A[i]
  list1.append(int(ans))

print(*list1)

Measured memory_bytes: 23612
n, k = map(int, input().split())
x_list = list(map(int, input().split()))

min_dist = float('inf')
for i in range(0, n-(k-1)):
    left = x_list[i]
    right = x_list[i+(k-1)]

    dist = abs(left - right) + min(abs(left), abs(right))
    min_dist = min(dist, min_dist)
print(min_dist)


Measured memory_bytes: 62576
from operator import mul
from functools import reduce


def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10**9 + 7))


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s, t; cin >> s >> t;
    int ans = INF;
    int n = s.length(), m = t.length();
    for (int l = 0; l <= n - m; ++l) {
        int cnt = 0;
        for (int i = 0; i < m; ++i) {
            if (s[l + i] != t[i])++cnt;
        }
        if (cnt < ans)ans = cnt;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3656
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private long count;
 
    private void solve(Scanner sc, PrintWriter out) {
        long x = sc.nextLong();
        long y = sc.nextLong();
 
        if (x < 0 && y < 0) {
            if (x > y) {
                ++count; // B
                count += Math.abs(y) - Math.abs(x); // A
                ++count; // B
            } else {
                count += Math.abs(x) - Math.abs(y); // A
            }
        } else if (x >= 0 && y < 0) {
            if (x > Math.abs(y)) {
                ++count; // B
                count += x - Math.abs(y); // A
            } else {
                count += Math.abs(y) - x; // A
                ++count; // B
            }
        } else if (x < 0 && y > 0) {
            if (Math.abs(x) > y) {
                count += Math.abs(x) - y; // A
                ++count; // B
            } else {
                ++count; // B
                count += y - Math.abs(x); // A
            }
        } else if (x < 0 && y == 0) {
            count += Math.abs(x); // A
        } else if (x > 0 && y == 0) {
            ++count; // B
            count += x; // A
        } else {
            if (x > y) {
                ++count; // B
                count += x - y; // A
                ++count; // B
            } else {
                count += y - x; // A
            }
        }
 
        out.println(count);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[1080000];
Int revfact[1080000];
Int rev[1080000];


void init(){
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for(int i = 1;i < 1080000;i++){
        fact[i] = fact[i-1] * i % m;
        if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
        revfact[i] = revfact[i-1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k){
    if(n < k)return 0;
    return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}

Int n, a, b, c;

int main(){
    init();
    cin >> n;
    cin >> a >> b >> c;
    Int res = 0;
    Int ab = a + b;
    a *= inv(ab);a %= MOD;
    b *= inv(ab);b %= MOD;
    
    Int cnt;
    if(c != 0)cnt = 100 * inv(100-c) % MOD;
    else cnt = 1;
    for(int i = 0;i < n;i++){
        res += nCk(n-1+i, i) * mod_pow(a, i) % MOD * mod_pow(b, n)  %MOD * (n+i) % MOD * cnt % MOD;res %= MOD;
        res += nCk(n-1+i, i) * mod_pow(b, i) % MOD * mod_pow(a, n)  %MOD * (n+i) % MOD * cnt % MOD;res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 25600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	if (n >= 1000){
		cout << "ABD" << endl;
	}else{
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3492
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    cout << fixed << setprecision(8);
    ll N, K, T, U, V, L;
    cin >> N >> K >> T >> U >> V >> L;
    double ans = 0;
    int num = 0;
    double rem = 0;
    double prev = 0;
    int D;
    for (int i = 0; i < N; i++) {
        cin >> D;
        double dash = T * V * num + rem;
        //cout << dash << endl;
        if (dash <= D - prev + eps) {
            ans += dash / V;
            ans += ((D - prev) - dash) / U;
            num = 0;
            rem = T * V;
            //cout << "aaa" << endl;
        } else {
            ans += (D - prev) / V;
            if (D - prev <= rem + eps) {
                rem -= D - prev;
                num++;
                if (num > K) {
                    num = K;
                    rem = T * V;
                }
                //cout << "bbb" << endl;
            } else {
                double diff = D - prev - rem;
                int usenum = 0;
                for (int j = 1; j <= num; j++) {
                    double d = j * T * V;
                    if (d >= diff + eps) {
                        usenum = j;
                        break;
                    }
                }
                rem = usenum * T * V - diff;
                num -= usenum;
                num++;
                if (num > K) {
                    num = K;
                    rem = T * V;
                }
                //cout << "ccc" << endl;
            }
        }
        prev = D;
        //cout << ans << " " << num << " " << rem << endl;
    }
    double last = L - prev;
    double lastdash = T * V * num + rem;
    if (lastdash <= last + eps) {
        ans += lastdash / V;
        ans += (last - lastdash) / U;
    } else {
        ans += last / V;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3264
import math
def cnt_div(n):
    div = []
    for i in range(1,int(math.sqrt(n)+2)):
        if n%i == 0:
            div.append(i)
            div.append(n//i)
    if len(set(div)) == 8:
        return 1
    else:
        return 0
n = int(input())
ans = 0
for i in range(1,n+1,2):
    ans += cnt_div(i)
print(ans)

Measured memory_bytes: 9048
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
vector<pair<int,int> > con[5111];
int sz[5111],pc[5111];
ll ans;
void dfs(int x,int pre=-1)
{
	sz[x]=1;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i].FF;
		if(pre!=u)
		{
			dfs(u,x);
			sz[x]+=sz[u];
			pc[u]=con[x][i].SS;
			ans+=1ll*pc[u]*min(sz[u],n-sz[u])*2;
		}
	}
}
ll qpow(ll x,ll k){return k==0?1:qpow(x*x%mod,k>>1)*(k&1?x:1)%mod;}
ll fac[5111],ifac[5111];
ll C(int x,int y){return x<y?0:fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
ll dp[5111],ndp[5111];
int main()
{
	fac[0]=1;
	for(int i=1;i<=5005;i++)fac[i]=fac[i-1]*i%mod;
	ifac[5005]=qpow(fac[5005],mod-2);
	for(int i=5004;i>=0;i--)ifac[i]=ifac[i+1]*(i+1)%mod;
	geti(n);
	for(int i=1;i<n;i++)
	{
		int x,y,c;
		getii(x,y);
		c=1;
		con[x].PB(MP(y,c));
		con[y].PB(MP(x,c));
	}
	dfs(1);
	int mn=n+1,mnid=-1;
	for(int i=1;i<=n;i++)
	{
		if(sz[i]*2==n)
		{
			cout<<fac[n/2]*fac[n/2]%mod<<endl;
			return 0;
		}
		if(sz[i]*2>=n)
		{
			if(sz[i]<mn)mn=sz[i],mnid=i;
		}
	}
	dfs(mnid);
	dp[0]=1;
	for(int i=0;i<con[mnid].size();i++)
	{
		int u=con[mnid][i].FF;
		memset(ndp,0,sizeof(ndp));
		int m=sz[u];
//		cerr<<"m="<<m<<endl;
		for(int j=0;j<=m;j++)
		{
			ll coef=C(m,j)*C(m,j)%mod*fac[j]%mod;
			if(j&1)coef=(mod-coef)%mod;
			for(int t=0;t<=n;t++)
			{
				if(!dp[t])continue;
				ndp[j+t]+=dp[t]*coef%mod;
			}
		}
		for(int t=0;t<=n;t++)dp[t]=ndp[t]%mod;
	}
//	for(int t=0;t<=n;t++)cerr<<dp[t]<<" ";cerr<<endl;
	ll ans=0;
	for(int i=0;i<=n;i++)ans=(ans+dp[i]*fac[n-i]%mod)%mod;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout <<min(abs(a-b)+abs(b-c),min(abs(a-c)+abs(c-b),min(abs(b-a)+abs(a-c),min(abs(b-c)+abs(c-a),min(abs(c-a)+abs(a-b),abs(c-b)+abs(b-a)))))) << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std ;
void Print( int A ) {
	int Zeros = 5 - (int)( log( A ) / log( 10 ) + 0.00000001 ) ;
	for(register int i = 1 ; i <= Zeros ; ++i )
		putchar('0') ;
	printf( "%d" , A ) ;
}
int N , M ;
struct City {
	int P , Y , Id , Rank ;
} C[100005] ;
inline bool Cmp1( City A , City B ) {
	return A.Y < B.Y ;
}
inline bool Cmp2( City A , City B ) {
	return A.Id < B.Id ;
}
int Ranking[100005] ;
int main() {
	
	scanf( "%d%d" , &N , &M ) ;
	for(register int i = 1 ; i <= M ; ++i ) {
		scanf( "%d%d" , &C[i].P , &C[i].Y ) ;
		C[i].Id = i ;
	}
	sort( C + 1 , C + 1 + M , Cmp1 ) ;
	for(register int i = 1 ; i <= M ; ++i )
		C[i].Rank = ++Ranking[C[i].P] ;
	sort( C + 1 , C + 1 + M , Cmp2 ) ;
	for(register int i = 1 ; i <= M ; ++i ) {
		Print( C[i].P ) ;
		Print( C[i].Rank ) ;
		putchar( '\n' ) ;
	}
	return 0 ;
	
}

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

using ll = long long;
using pii = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;

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

int main() {
    int N; cin >> N;
    vector<ll> a(N), b(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> b[i];
    }
    for(int i = 0; i < N; ++i) {
        if(b[i] < a[i]) {
            for(int j = 0; j < N; ++j) {
                ll t = max(min((b[j] - a[j]) / 2, a[i] - b[i]), 0LL);
                b[i] += t;
                a[j] += 2 * t;
            }
        }
    }
    bool ok = true;
    for(int i = 0; i < N; ++i) {
        ok &= a[i] <= b[i];
    }
    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(){
  char s[10]={'\0'};
  char input[10];
  int now=0,i,len;
  
  scanf("%s",input);
  len=strlen(input);
  
  for(i=0;i<len;i++){
    switch((int)input[i]){
      case '1':
        s[now]='1';
        now++;
        break;
      case '0':
        s[now]='0';
        now++;
        break;
      case 'B':
        if(now>0){
          s[now-1]='\0';
          now--;
        } else {
          s[now]='\0';
        }
    }
  }
  
  printf("%s",s);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
bool isSame(int n)
{
    int x,y,z;
    x = n % 10;
    y = (n / 10) % 10;
    z = (n / 100) % 10;
    if(x == y && y == z)
        return true;
    else
    {
        return false;
    }
    
}


int main()
{
    int n;
    cin >> n;
    while(!isSame(n))
    {
        n++;
    }
    cout << n;
    
    return 0;
}

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

B = sum(A) * sum(A)
taikaku = 0
for a in A:
    taikaku += a * a  
ans = (B - taikaku) // 2
print(ans % mod)

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll N,x;
   cin >> N >> x;
   vector<ll>a(N);
   ll ans=0;
   FOR(i,N)cin>>a[i];
   FOR(i,N){
      if(i+1<N&&a[i]+a[i+1]>x){
         ans+=a[i]+a[i+1]-x;
         a[i+1]-=min(a[i]+a[i+1]-x,a[i+1]);
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(n)
    mm = 0
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9228
#include <stdio.h>
 
int main() {
 
int al[30] = {0};
char b[2000]= {0};
int i,j,n;
 
i=0;
 
while( scanf("%c",&b[i]) != EOF) {
 
if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;
 
} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}
 
for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}
 
return 0;
 
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1e9+7;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;

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

    for (int i=0; i<n-1; i++){
        int u, v;
        cin>>u>>v;
        if (v<u) swap(u,v);
        u--; v--;
        ans -= (u+1)*(n-v);
    }

    cout<<ans<<endl;

    return 0 ;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int helper(vector<int> a, int n,int k)
{
    vector<int>dp(n,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<k;j++)
        {
            if((i-j-1)>=0)
                dp[i]=min(dp[i],dp[i-j-1]+abs(a[i-j-1]-a[i]));
        }
    }
    return dp.back();
}

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


//     vector<int>a={40,10,20,70,80,10,20,70,80,60};
//     int res=helper(a,10,4);
//     cout<<res<<endl;

}


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

using namespace std;

#define rep(i,n) for(long long int i=0;i<n;i++)
#define rep1(i,n) for(long long int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(long long int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(long long int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define vci(v) for(long long int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(long long int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mp make_pair
#define fir first
#define sec second
#define clr(arr) memset((arr),0,sizeof(arr))

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vb;
typedef vector<vector<double>> vvd;
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
typedef pair<int,int> pii;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{0,0},{1,0},{1,1},{0,1},{-1,1},{0,-1},{-1,-1},{0,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> inline void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

inline long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}
  
             
/*The main code follows below*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int B=0,s=0,n; ci(n);
	vi v;
	rep(i,n){
		int a; ci(a);
		v.pub(a);
		s+=a;
	}
	sort(v.begin(),v.end());
	rep(i,n) if(i%2) B+=v[n-i-1];
	lco(s-2*B);
	return 0;
}

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

using namespace std;

int main()
{

   int a,b,h1,s;
   cin>>a>>b;
   s=a+b;
   if(s>=24){
    h1=s-24;
    cout<<h1<<endl;
   }
   else{
    cout<<s<<endl;
   }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c;
    ll ans=0;
    cin>>a>>b>>c;
    if (a%c==0){
        cout<<b/c-a/c+1;
    }
    else{
        cout<<b/c-a/c;
    }
    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
void pass()
{
    ll k = 0,s = 0;
    int n;
    cin>>n;
    vector<int>a(n+1,0);

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= n; j+=i)
        {
            a[j]++;
        }
    }

    for(int i = 1; i <= n; i++)
    {
        s += (i*(ll)a[i]);;
    }

    cout<<s<<endl;
}
int main()
{
    ll n,m,k=0,s=0,l=0,t=0;
    pass();
}




Measured memory_bytes: 42280
while True:
    H,W=map(int,input().split())
    if (H==0 and W==0):
        break
    for i in range(H):
        for j in range(W):
            if (i==0 or j==0 or i==H-1 or j==W-1):
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()
    


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N,0);
    rep(i,N) cin >> A[i];
    ll ans = 1000000000;
    ll ng = 0;
    ll cnt = 0;
    ll mid;
    while(ans - ng > 1){
        cnt = 0;
        mid = (ans + ng) / 2;
        rep(i,N){
            if(mid < A[i]){
                cnt += A[i] / mid;
            }
        }
        if(cnt > K){
            ng = mid;
        }
        else{
            ans = mid;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4760
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def dfs(now, prev):
    ans[now]+=(h[now]+ans[prev])
    # 今いる頂点から行ける頂点を順に next に入れてループ
    for next in g[now]:
        if next != prev:
            if memo[next]==True:
                # 過去に訪れていれば終わらせる
                return False
            else:
                memo[next] = True
                dfs(next, now)
 
#木構造の取り込み 
n, q = map(int, input().split())
g = [[] * n for i in range(n)]
for i in range(n-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
 
#操作の取り込み
h=[0]*n
for i in range(q):
    u, v = map(int, input().split())
    u -= 1
    h[u]+=v
 
#初期のカウンター
ans=[0]*n
memo = [False for i in range(n)]
 
#DFSでカウンターを動かす
dfs(0,0)
 
print(' '.join(map(str, ans)))

Measured memory_bytes: 239388
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n, i;
  cin >> n >> i;
  cout << n - i + 1;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int day =sc.nextInt();
		int num =sc.nextInt();
		//int a[]=new int[num];
		
		for(int i=0;i<num;i++) {
			int a=sc.nextInt();
           day-=a;
		}
		
		if(day<0) {
			System.out.print(-1);
		}
		else {
			System.out.print(day);
		}
		sc.close();
		
	}

}

Measured memory_bytes: 38036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<pair<ll, ll>> cnt;
    ll tmp = a[0];
    cnt.emplace_back(a[0], 1);
    rep(i, 1, n) {
        if (tmp == a[i]) cnt.back().second++;
        else cnt.emplace_back(a[i], 1), tmp = a[i];
    }
    cnt.emplace(cnt.begin(), -INF, -INF);
    cnt.emplace(cnt.begin(), -INF, -INF);
    cnt.emplace(cnt.begin(), -INF, -INF);
    cnt.emplace_back(INF, -INF);
    cnt.emplace_back(INF, -INF);
    cnt.emplace_back(INF, -INF);
    ll ans = 0;
    rep(i, 0, (int)cnt.size()-2) {
        tmp = cnt[i].second;
        if (abs(cnt[i].first - cnt[i+1].first) <= 2) tmp += cnt[i+1].second;
        if (abs(cnt[i].first - cnt[i+2].first) <= 2) tmp += cnt[i+2].second;
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_int v(n);
    cin >> v;

    sort(v.begin(), v.end());
    
    double ans = (v[0]+v[1])/2.0;
    irep2(i, 2, n-1) {
        ans = (ans+v[i])/2.0;
    }

    printf("%.12f\n", ans);

    return 0;
} /*atcoder*/



Measured memory_bytes: 3752
#include <stdio.h>

int main(void) {
  int a[]={1,2,3},b;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  if(a[0]>a[1]){
  b=a[0];
  a[0]=a[1];
  a[1]=b;
  }
  if(a[1]>a[2]){
  b=a[1];
  a[1]=a[2];
  a[2]=b;
  }
  if(a[0]>a[1]){
  b=a[0];
  a[0]=a[1];
  a[1]=b;
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}


Measured memory_bytes: 2104
X=[]
n=int(input())
for i in range(n):
    t,a=map(int,input().split())
    X.append([t,a])

T=X[0][0]
A=X[0][1]

for i in range(1,n):
    N=max(-(-T//X[i][0]),-(-A//X[i][1]))
    T=X[i][0]*N
    A=X[i][1]*N
print(T+A)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main(void){
    ll h; cin >> h;
    cout << func(h) << endl;
    return 0;
}

Measured memory_bytes: 256
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

use std::collections::HashMap;

fn main() {
    input! {
        s: chars,
    }
    let mut letters = HashMap::new();
    for ch in s.iter() {
        let counter = letters.entry(ch).or_insert(0);
        *counter += 1;
    }
    if letters.len() == 2 && letters.values().all(|&x| x == 2) {
        println!("{}", "Yes");
    } else {
        println!("{}", "No")
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,t=1,i,res=0;
  int a[N_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  for(i=1;i<n;i++)
    if(a[i]==a[i-1]){
      t++;
    }else{
      if(t>=a[i-1])
        res+=t-a[i-1];
      else
        res+=t;
      t=1;
    }
  if(t>=a[i-1])     
    res+=t-a[i-1];
  else
    res+=t;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define pii pair<int,int>
#define sz(x) (int) x.size()
#define f first
#define s second
using namespace std;
const int N=2e5+3;
const int M=1e8;
const int tox[4]={1,-1,0,0};
const ll inf=1e18;
const int toy[4]={0,0,1,-1};
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    vector<vector<char>>a(n,vector<char>(m));
    vector<vector<ll>>dst(n,vector<ll>(m,inf));
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;--x1;--x2;--y1;--y2;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>>q;
    q.push({0,{x1,y1}});
    dst[x1][y1]=0;
    while(!q.empty()){
        auto c= q.top();
        q.pop();
        int dt=c.f,x=c.s.f,y=c.s.s;
        if(dst[x][y]<dt) continue;
        for(int i=0;i<4;i++){
            for(int j=1;j<=k;j++){
                int nx=x+tox[i]*j,ny=y+toy[i]*j;
                if(nx<0 || ny<0 || nx>=n || ny>=m){
                    break;
                }
                if(a[nx][ny]!='@' && dst[nx][ny]>dt+1){
                    dst[nx][ny]=dt+1;
                    q.push({dt+1,{nx,ny}});
                }
                else if (a[nx][ny]=='@' || dst[nx][ny]<dt+1){
                    break;
                }
            }
        }
    }
    cout<<(dst[x2][y2]==inf ? -1 : dst[x2][y2]);
    return 0;
}
// abcd


Measured memory_bytes: 19900
//writer：Sakura
//problem：Built? 
//id：arc_076b 
//from：AtCoder

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

ll n,fa[N],a,ans=0;
priority_queue<pair<ll,pair<ll,ll> > > que;
pair<ll,ll> x[N],y[N];

int root(int x){//并查集 
	if(fa[x]==x)return x;
	else return fa[x]=root(fa[x]);
}

void link(int x,int y){//并查集归类 
	x=root(x);y=root(y);
	if(x==y)return;
	fa[x]=y;
}

int main(){
	//freopen("Built.in","r",stdin);
	//freopen("Built.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)fa[i]=i;//初始fa 
	for(int i=0;i<n;i++){
		scanf("%lld %lld",&x[i].first,&y[i].first);
		x[i].second=i;
		y[i].second=i;
		//second记录下标 
	}
	sort(x,x+n);sort(y,y+n);//按照横纵排序 
	
	/*for(int i=0;i<n;i++){
		printf("%lld %lld\n",x[i].first,y[i].first);
	}cout<<endl;
	for(int i=0;i<n;i++){
		printf("%lld %lld\n",x[i].second,y[i].second); 
	}cout<<endl; 
	*/
	
	for(int i=0;i<n-1;i++){//存入花费【min(abs(a-c),abs(b-d));】 
		que.push(make_pair(-(abs(x[i].first-x[i+1].first)),make_pair(x[i].second,x[i+1].second)));
		que.push(make_pair(-(abs(y[i].first-y[i+1].first)),make_pair(y[i].second,y[i+1].second)));
	}
	while(!que.empty()){
		pair<ll,ll> edge;
		ll xx,yy;//xx,yy分别为横纵 
		ll cost;//cost花费的yen 
		pair<ll, pair<ll,ll> > new_q;
		new_q=que.top();
		edge=new_q.second;
		cost=-new_q.first;
		xx=edge.first;yy=edge.second;//xx，yy分别是新的横纵 
		que.pop();
		if(root(xx)==root(yy))continue;
		link(xx,yy);//链接xxyy构成边 
		ans+=cost;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

struct Node {
  int key;
  Node *next, *prev;
};
Node *nil;
Node* listSearch(int key){
  Node *cur = nil -> next;
  while( cur != nil && cur -> key != key){
    cur = cur -> next;
  }
  return cur;
}
void initial(){
  nil = (Node *)malloc( sizeof(Node) );
  nil -> next = nil;
  nil -> prev = nil;
}
void printList(){
  Node *cur = nil -> next;
  int isFirst = 0;
  while( 1 ){
    if( cur == nil) break;
    if( isFirst++ > 0 ) cout << " ";
    printf("%d", cur -> key);
    cur = cur -> next;
  }
  cout << "\n";
}
void deleteNode(Node *t){
  if( t == nil ) return;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}
void deleteKey(int key){
  deleteNode(listSearch( key ));
}
void deleteFirst(){
  deleteNode( nil -> next );
}
void deleteLast(){
  deleteNode( nil -> prev );
}
void insert(int key){
  Node *x = (Node *)malloc( sizeof(Node) );
  x -> key = key;
  x -> next = nil -> next;
  nil -> next -> prev = x;
  nil -> next = x;
  x -> prev = nil;
}
int main(){
  int key, n; cin >> n;
  string s;
  initial();
  rep(i, n){
    cin >> s;
    if( s == "insert" ){
      cin >> key;
      insert( key );
    }else if( s == "delete" ){
      cin >> key;
      deleteKey( key );
    }else if( s == "deleteFirst"){
      deleteFirst();
    }else{
      deleteLast();
    }
  }
  printList();
}


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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	long long ans;
	vector<long long int> v(10000000,0);
	for(int x=1;x<100;x++)
	{
	    for(int y=1;y<100;y++)
	    {
	        for(int z=1;z<100;z++)
	        {
	            ans = x*x + y*y + z*z + x*y + y*z + z*x;
	            v[ans]+=1;
	        }
	    }
	}
	for(int i=1;i<=n;i++)
	{
	    cout<<v[i]<<"\n";
	}
	return 0;
}


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

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

  for(int i = 0; i < 3; i++){
    if(n[i] == '1'){
      cout << '9';
    }
    else if(n[i] == '9'){
      cout << '1';
    }
    else
    {
      cout << n[i];
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
   int N;
   cin >> N;
   int d[N];
   for(int i=0;i<N;i++) cin >> d[i];
   int e[101];
   for(int i=0;i<101;i++) e[i] = 0;
   for(int i=0;i<N;i++) e[d[i]] += 1;
   int cnt = 0;
   for(int i=0;i<101;i++){
       if(e[i] > 0) cnt +=1;
   }
   cout << cnt <<endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! レベルNバーガーの枚数
ll M[55];
//! レベルNバーガーに含まれるパティの数
ll P[55];

//! レベルnバーガーのx下からxマイ目までにパティが何枚含まれるか
ll num(ll n, ll x)
{
    if (x == 0)
        return 0;
    if (n == 0)
        return 1;
    ll sum = 0;
    //! 一番下はバン
    x--;
    if (x <= M[n - 1])
    {
        return num(n - 1, x);
    }
    sum += P[n - 1];
    x -= M[n - 1];
    if (x > 0)
    {
        sum++;
        x--;
    }
    if (x <= M[n - 1])
    {
        return sum + num(n - 1, x);
    }
    return sum + P[n - 1];
}

int main()
{
    ll N, X;
    cin >> N >> X;
    M[0] = 1;
    P[0] = 1;
    FOR(i, N + 1, 1)
    {
        M[i] = M[i - 1] * 2 + 3;
        P[i] = P[i - 1] * 2 + 1;
    }

    cout << num(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256