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

int main() {
  int n;
  cin >>n;
  map<long long int,int> list;
  for (int i=0;i<n;i++) {
    int temp;
    cin >> temp;
    //cout << temp;
    if(list.count(temp)) {
      list.at(temp)++;
    }
    else {
      list[temp]=1;
    }
  }
  //cout<<list.size()<<endl;
  long long int ans=0;
  for (auto p:list) {
    ans+=p.second%2;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int a[205];

int main()
{
	int n;
	cin>>n;
	int mi=1e9;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		int temp=0;
		while(a[i]%2==0)
		{
			temp++;
			a[i]/=2;
		}
		mi=min(temp,mi);
	}
	cout<<mi<<endl;
	return 0;
} 

Measured memory_bytes: 256
n,X[100],Y[100],R[100];U,V,S,T;f,i,u,v,s,t,o,x,y;main(m){for(;~scanf("%d",&n);m=0){for(i=n;i--;)scanf("%d%d%d",X+i,Y+i,R+i);for(scanf("%d",&m);m--;f=!puts(f?"Safe":"Danger"))for(scanf("%d%d%d%d",&U,&V,&S,&T),i=n;i--;f+=(o=hypot(u=U-X[i],v=V-Y[i])>R[i])^hypot(s=S-X[i],t=T-Y[i])>R[i]||o&fabs(y*s+x*t)/hypot(x,y)<=R[i]&v*y<u*x&t*y>s*x)x=U-S,y=T-V;}}

Measured memory_bytes: 0
#import 
#=input()
#=int(input())
n,k=map(int,input().split())
p=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

p.sort()
s = 0
for i in range(k):
    s += p[i]
print(s)

Measured memory_bytes: 9232
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	cout << (s < t ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
	cout<<"Yes";
	else\
	cout<<"No";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
#define De(...)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
using namespace std; 

int _; 

long long n,sum=26;
string s;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%lld",&n);
	while(n>0)
	{
		s += ('a'+(n-1)%sum/(sum/26));
		n -= sum;
		sum *= 26;
	}
	reverse(s.begin(),s.end());
	std::cout << s << endl;
	return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int num[15];
int n,m,q;
struct pp{
    int a,b,c,d;
}que[55];
int nct;
ll sum,ma;
void dfs(int la)
{
    if(nct==n)
    {
        sum=0;
        for(int i=1;i<=q;i++)
        {
            if(num[que[i].b]-num[que[i].a]==que[i].c)
                sum+=que[i].d;
        }
        ma=max(ma,sum);
        return;
    }
    for(int i=la;i<=m;i++)
    {
        num[++nct]=i;
        dfs(i);
        nct--;
    }
}
int main()
{
    cin >> n >> m >> q;
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d%d",&que[i].a,&que[i].b,&que[i].c,&que[i].d);
    }
    dfs(1);
    cout << ma;
    return 0;
}


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

#define ll long long int

using namespace std;

string s;
int n;

ll res=0;

void f(int idx,ll akt,ll done)
{
    if(idx==n)
    {
        res+=done;
        res+=akt;
        return;
    }
    f(idx+1,akt*10+s[idx]-'0',done);
    f(idx+1,s[idx]-'0',done+akt);
}

int main()
{
    cin>>s;
    n=s.length();
    f(1,s[0]-'0',0);
    cout<<res;
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<fixed<<setprecision(y)<<x;
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
#define f(i,n)          for(int i=0 ; i<n ; i++)
#define SIZE            200000
#define mod             1000000007


void ish_8()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

bool prime(int n)
{
  if(n<2)
    return false;
  for(int i=2 ; i<=sqrt(n) ; i++)
  {
    if(n%i == 0)
      return false;
  }
  return true;
}

/*int  power(int a, int b) {
 int rs = 1;
 while(b>0) {
  if(b & 1) 
  {
    rs *= a;
    rs = rs%mod;
  }
  a = ((a%mod)*(a%mod))%mod;
  b >>= 1;
}
return rs%mod;
}*/

int power(int x, int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return (power(x, (y%mod) / 2))%mod * (power(x%mod, (y)%mod / 2))%mod; 
    else
        return x%mod * power(x%mod, (y%mod) / 2)%mod * power(x%mod, (y)%mod / 2)%mod; 
} 

int log_a_to_base_b(int a, int b) 
{ 
  if(b==1)
    return 0;
  return log(a) / log(b); 
} 


double kthRoot(double n, int k) {
  return pow(k, (1.0 / k) * (log(n) / log(k))); 
}

int factorial(int n)
{
  if(n==0)
  {
    return 1;
  }
  return n*factorial(n-1);
}

void solve()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a==b && a==0)
   {
    cout<<"0"<<endl;
    return;
   }
   if(c==d && c==0)
   {
    cout<<"0"<<endl;
    return;
   }
   if(b==0)
    b--;
   if(d==0)
    d--;
   int x = b*d;
   int y = b*c;
   int z = a*c;
   int w = a*d;
   int f = max(x,y);
   int g = max(z,w);
   cout<<max(f,g)<<endl;
}

int32_t main()
{
  ish_8();
  //w(t)
  //{
    solve();
  //}
}



Measured memory_bytes: 3684
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=1e15;
const int MOD = 1e9 + 7;

struct Edge{
    int from,to;
	ll cost;
    Edge(int from, int to, ll cost): from(from),to(to), cost(cost){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator < (const Edge &e, const Edge &f){
    return e.cost > f.cost;
}

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

    int n,m;cin>>n>>m;
	int s,t;cin>>s>>t; s--;t--;
	vector<Edge> es;
	Graph g(n);
	for(int i=0;i<m;i++){
		int u,v; cin>>u>>v; u--;v--;
		ll d;cin>>d;
		es.push_back(Edge(u,v,d));
		es.push_back(Edge(v,u,d));
		g[u].push_back(Edge(u,v,d));
		g[v].push_back(Edge(v,u,d));
	}
	vector<ll> dp1(n,0),dp2(n,0);// s,tからの最短路の個数
	dp1[s]=1; dp2[t]=1;
	vector<ll> dis1(n,INF),dis2(n,INF);
	dis1[s]=0; dis2[t]=0;
	priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,s)); // P(dis, pos)
    while(!que.empty()){
        ll dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(dis1[v]<dist) continue;
        for(const auto &e: g[v]){
            if(dis1[e.to]<dis1[v]+e.cost) continue;
			else if(dis1[e.to]==dis1[v]+e.cost){
				dp1[e.to] += dp1[v];
				dp1[e.to] %=MOD;
				continue;
			}
            dis1[e.to] = dis1[v] + e.cost;
			dp1[e.to] = dp1[v];
            que.push(P(dis1[e.to], e.to));
        }
    }
	que.push(P(0,t)); // P(dis, pos)
    while(!que.empty()){
        ll dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(dis2[v]<dist) continue;
        for(const auto &e: g[v]){
            if(dis2[e.to]<dis2[v]+e.cost) continue;
			else if(dis2[e.to]==dis2[v]+e.cost){
				dp2[e.to] += dp2[v];
				dp2[e.to] %=MOD;
				continue;
			}
            dis2[e.to] = dis2[v] + e.cost;
			dp2[e.to] = dp2[v];
            que.push(P(dis2[e.to], e.to));
        }
    }
	ll res = dp1[t]*dp1[t]; res %= MOD;
	ll col=0;
	for(int i=0;i<n;i++){
		if(2*dis1[i]!=dis1[t]) continue;
		if(dis1[i]+dis2[i]!=dis1[t]) continue;
		ll tmp= dp1[i]*dp2[i]; tmp %=MOD;
		tmp *= tmp; tmp %= MOD;
		col += tmp; col %= MOD;
	}
	for(int i=0;i<2*m;i++){
		Edge e=es[i];
		int u=e.from, v=e.to;
		ll c=e.cost;
		if(2*dis1[u]>=dis1[t] || 2*dis1[v]<=dis1[t] || dis1[u]+c!=dis1[v]) continue;
		if(dis1[u]+dis2[u]!=dis1[t] || dis1[v]+dis2[v]!=dis1[t]) continue;
		ll tmp=dp1[u]*dp2[v]; tmp%=MOD;
		tmp *= tmp; tmp%=MOD;
		col += tmp; col %=MOD;
	}
	cout<< (res-col+MOD)%MOD<<endl;
}


Measured memory_bytes: 26856
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD2; 
int dp[40];
int comb[40];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int a,b,c;
          cin>>a>>b>>c;
          swap(a,b);swap(a,c);
          cout<<a<<" "<<b<<" "<<c<<endl;
      }
      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int niz[100005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin >> n >> m;
    int sum = 0;
    ff(i,0,n - 1){
        cin >> niz[i];
        sum += niz[i];
    }
    sort(niz, niz + n);
    reverse(niz, niz + n);
    ff(i,0,n - 1){
        niz[i] *= (4 * m);
        if(niz[i] < sum){
            cout << "No\n";
            return 0;
        }
        if(i+1 >= m){
            cout << "Yes\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<ll> divisor;
void list_divisor(ll n) {
    divisor.clear();
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            divisor.push_back(i);
            if(i*i != n) divisor.push_back(n/i);
        }
    }
    sort(divisor.begin(), divisor.end());
}

vector<bool> Eratosthenes(ll N) {
    vector<bool> primes(N, true);
    vector<ll> ret;
    primes[0] = false;
    primes[1] = false;
    for (ll i=2; pow(i,2)<=N; i++) {
        if (primes[i]) {
            for(int j=2; i*j<=N; j++) primes[i*j] = false;
            ret.push_back(primes[i]);
        }
    }
    return primes;//ret;
}

int main() {
    ll N, D;
    cin >> N >> D;

    ll ret = 0;
    for(ll i = 0; i < N; i++) {
        ll X, Y;
        cin >> X >> Y;

        if(D*D >= X*X + Y*Y) ret++;
    }

    cout << ret << endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstring>
#include <vector>

class dice{

    public:
        dice();
        void SetPips();
        int GetUpperPip(){return pip[0];};
        void Rolldice(char order);
        int GetRight(int upper,int flont);
        friend std::ostream &operator<<(std::ostream &out, const dice &d);//?????
    private:
    int pip[6];

};

dice::dice():pip{}{
    //:だけでいいのはなんで？イニシャライザ
}

void dice::SetPips(){
    for(int i=0;i<6;i++){
        std::cin>>pip[i];
    }
}

void dice::Rolldice(char order){
    int tem;
    switch(order){
        case 'N':{
            tem=pip[0];
            pip[0]=pip[1];
            pip[1]=pip[5];
            pip[5]=pip[4];
            pip[4]=tem;
            break;
        }
        case 'E':{
            tem=pip[0];
            pip[0]=pip[3];
            pip[3]=pip[5];
            pip[5]=pip[2];
            pip[2]=tem; 
            break;           
        }
        case 'S':{
            tem=pip[0];
            pip[0]=pip[4];
            pip[4]=pip[5];
            pip[5]=pip[1];
            pip[1]=tem;  
            break;    
        }
        case 'W':{
            tem=pip[0];
            pip[0]=pip[2];
            pip[2]=pip[5];
            pip[5]=pip[3];
            pip[3]=tem;  
            break;    
        }
    }
}

int dice::GetRight(int upper,int flont){
    if(upper==pip[0]){
        if(flont==pip[1]){return pip[2];}
        else if(flont==pip[2]){return pip[4];}
        else if(flont==pip[4]){return pip[3];}
        else if(flont==pip[3]){return pip[1];}
    }
    else if(upper==pip[1]){
        if(flont==pip[2]){return pip[0];}
        else if(flont==pip[0]){return pip[3];}
        else if(flont==pip[3]){return pip[5];}
        else if(flont==pip[5]){return pip[2];}
    }
    else if(upper==pip[2]){
        if(flont==pip[0]){return pip[1];}
        else if(flont==pip[1]){return pip[5];}
        else if(flont==pip[5]){return pip[4];}
        else if(flont==pip[4]){return pip[0];}
    }
    else if(upper==pip[3]){
        if(flont==pip[0]){return pip[4];}
        else if(flont==pip[4]){return pip[5];}
        else if(flont==pip[5]){return pip[1];}
        else if(flont==pip[1]){return pip[0];}
    }
    else if(upper==pip[4]){
        if(flont==pip[0]){return pip[2];}
        else if(flont==pip[2]){return pip[5];}
        else if(flont==pip[5]){return pip[3];}
        else if(flont==pip[3]){return pip[0];}
    }
    else if(upper==pip[5]){
        if(flont==pip[1]){return pip[3];}
        else if(flont==pip[3]){return pip[4];}
        else if(flont==pip[4]){return pip[2];}
        else if(flont==pip[2]){return pip[1];}
    }                    
}

std::ostream &operator<<(std::ostream &out, const dice &d)
{
    for (auto &x : d.pip)
    {
        out << x << " ";
    }
} //??????

int main(){
    using namespace std;
    int n;
    int flont, upper;
    dice d;
    d.SetPips();
    cin>>n;
   
    for (int i=0;i<n;i++){
        std::cin>>upper>>flont;
        cout<<d.GetRight(upper,flont)<<endl;
    }
    
    return 0;
}




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

const int N = 2e5 + 100;

int n, a[N], b[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++)
		if(a[i] >= b[(n >> 1)])
			cout << b[(n >> 1) - 1] << '\n';
		else
			cout << b[n >> 1] << '\n';
	return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,i,arr[26]={0},ans=1;
		string str;

		cin>>n>>str;
		rep(i,0,n)
		{
			arr[str[i]-'a']++;
		}
		rep(i,0,26)
		{
			ans=(ans*(arr[i]+1))%hell;
		}
		cout<<(ans-1+hell)%hell<<endl;

	}
	return 0;
}

Measured memory_bytes: 512
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int a[1005][4];

void solve(){
   
    int n,m;
    cin >> n >> m;

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

    for(int i = 0; i<(1<<3); i++){
        vector<int> v;

        for(int j = 1;j<=n;j++){
            int s =0;

            for(int k = 0; k<3; k++){
                if(i&(1<<k))s+=a[j][k]; else s-=a[j][k];
            }

            v.push_back(s);
        }
        sort(v.begin(), v.end()); reverse(v.begin(), v.end());
        int temp= 0;

        for(int t = 0;t<m;t++)temp+=v[t];
            ans= max(ans, temp);
    }

    cout << ans << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7
N = 10**5 + 1
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
n = int(input())
A = list(map(int,input().split()))
 
val = sum(A) - sum(set(A))
i = -1
j = -1
for k in range(n+1):
    if A[k] == val:
        if i == -1:
            i = k
        elif j == -1:
            j = k
            break
for k in range(1,n+2):
    print((cmb(n+1, k, mod) - cmb(n + i - j, k - 1, mod)) % mod)


Measured memory_bytes: 27568
a,b,k=map(int,input().split())
#食べられた後のa
A=a
#食べられた後のb
B=b
K=k

if a>=k:
    A=a-k
    print(A,B)
elif a<k:
    B=b-(k-a)
    A=0
    if k-a>=b:
        B=0
    print(A,B)
else:
    A=0
    B=0
    print(A,B)

Measured memory_bytes: 3064
s = str(input())

if s[1] == "R":
    if s[0] == "R" and s[2] == "R":
        print(3)
    elif s[0] == "R" or s[2] == "R":
        print(2)
    else:
        print(1)
else:
    if s[0] == "R" or s[2] == "R":
        print(1)
    elif s[0] != "R" and s[2] != "R":
        print(0)


Measured memory_bytes: 9112
#include <iostream>

int b[201];
int d[201];

int main() {
  long n;
  std::cin >> n;

  for (int i=0; i<n; i++) {
    int a;
    std::cin >> a;
    std::cin >> b[a];
    b[a] += 1;
  }

  for (int i=0; i<n; i++) {
    int c;
    std::cin >> c;
    std::cin >> d[c];
    d[c] += 1;
  }

  int ans=0;
  for (int c=0; c<201; c++) {
    if (d[c] != 0) {
      int max_b = 0;
      int cand_a = 0;
      for (int a=0; a<c; a++) {
        if (b[a] > max_b && b[a] < d[c]) {
          max_b = b[a];
          cand_a = a;
        }
      }
      if (max_b != 0) {
        b[cand_a] = 0;
        ans++;
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e16;
const ll MM=1e18;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}
const ll MaxSize = 3e5;
ll facts[MaxSize], invFacts[MaxSize];

void preproc() {
  facts[0] = 1;
  for (int i = 1; i < MaxSize; i++) {
    facts[i] = ((ll)facts[i - 1] * i) % mod;
  }
  invFacts[MaxSize - 1] = expo(facts[MaxSize - 1], mod - 2,mod);

  for (int i = MaxSize - 2; i >= 0; i--) {
    invFacts[i] = ((ll)invFacts[i + 1] * (i + 1)) % mod;
  }
}

ll combination(ll n, ll k) {
  if(n<k) return 0;
  ll res = facts[n];
  res = ((ll)res * invFacts[k]) % mod;
  return ((ll)res * invFacts[n - k]) % mod;
}

void solve()
{
   ll n,m,k,re=0;
   cin>>n>>m>>k;
   preproc();
   for(int  i=0;i<=k;i++)
   {
       ll temp=(combination(n-1,i)*((m*expo(m-1,n-1-i,mod))%mod))%mod;
       if(temp<0)debug(i);
       re=(re+temp)%mod;
       //if(re<0)debug(i);
   }
   cout<<re<<endl;

}


int main()
{
  boost;
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}



Measured memory_bytes: 8344
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

// const int64_t kMod = 1000000007LL;
const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t N;
  cin >> N;
  vector<int64_t> H(N, 0);
  int64_t depth = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t d;
    cin >> d;
    if (i == 0 && d != 0) {
      cout << 0 << endl;
      return 0;
    } else if (i > 0 && d == 0) {
      cout << 0 << endl;
      return 0;
    }
    ++H[d];
    depth = max(d, depth);
  }
  if (H[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int64_t i = 0; i <= depth; ++i) {
    if (H[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  Mint result(1);
  for (int64_t i = 1; i <= depth; ++i) {
    Mint temp = H[i - 1];
    result *= temp.Pow(H[i]);
  }
  cout << result << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i)
    cin >> d[i];
  sort(d.begin(), d.end());
  if (N % 2 != 0)
    cout << 0 << endl;
  else
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100050
int n,i;
long long a[N],b[N],c[N],d[N],e[N],f[N],m;
int main()
{
	scanf("%d%lld",&n,&m);
	for (i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]),c[i]=m-a[i],d[i]=b[i],b[i]+=b[i-1];
	for (i=n;i>=0;i--) d[i]+=d[i+1];
	for (i=1;i<=n;i++) e[i]=max(e[i-1],b[i]-2*a[i]),f[i]=max(f[i-1],b[i]-a[i]);
	long long ans=0;
	for (i=1;i<=n+1;i++) ans=max(ans,max(e[i-1]+d[i]-c[i],f[i-1]+d[i]-2*c[i]));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
H, W = map(int, input().split())
 
a = [list(map(int, input().split())) for i in range(H)]
 
l = []
 
for i in range(H):
	for j in range(W-1):
		if a[i][j]%2 == 0:
			continue
		
		l.append((i+1, j+1, i+1, j+2))
		a[i][j] -= 1
		a[i][j+1] += 1
 
for i in range(H-1):
	if a[i][W-1]%2 == 0:
		continue
	
	l.append((i+1, W, i+2, W))
	a[i][W-1] -= 1
	a[i+1][W-1] += 1
 
print(len(l))
 
for y, x, y_, x_ in l:
	print('{} {} {} {}'.format(y, x, y_, x_))

Measured memory_bytes: 26200
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,m; 
  cin>>n;
  vector<int> d(n);
  rep(i,n)cin >>d[i];
  cin >>m;
  vector<int> t(m);
  rep(i,m)cin >>t[i];
  sort(all(d));
  sort(all(t));
  map<ll,ll> mpd;
  map<ll,ll> mpt;
  rep(i,n) mpd[d[i]]++;
  rep(i,m) mpt[t[i]]++;
  rep(i,m){
    if(mpt[t[i]]>mpd[t[i]]){
      cout <<"NO"<<endl;
      return 0;
    }
  }
  cout <<"YES"<<endl;
}

Measured memory_bytes: 29896
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K = sc.nextInt();
    System.out.println(a[K-1]);
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand(1, 26);        // [0, 99] 範囲の一様乱数
    REP(i, 0, 365) {
        MSG(rand(mt))
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	multiset<ll>A;
	cin >> Q;
	rep(i, Q) {
		ll a, b,c;
		cin >> a ;
		if (a==0) {
			cin >> b;
			A.insert(b);
			cout << A.size() << endl;
		}
		else if(a==1){
			cin >> b;
			cout << A.count(b)<< endl;
		}
		else if (a == 2) {
			cin >> b;
			A.erase(b);
		}
		else {
			cin >> b >> c;
			for (set<ll>::iterator j = A.lower_bound(b); j != A.upper_bound(c); ++j) {
				cout << *j << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12364
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    
    vector<int> A(N);
    rep(i, N) A[i] = i + 1;
    vector<int> ans(2 * N, -1); // 0: R, 1: B
    
    string first;
    
    cout << "? ";
    voutput(A);
    cin >> first;
    
    vector<int> ind(2 * N);
    rep(i, 2 * N) ind[i] = i;
    
    
    int l = 0, r = N; // ng, ok;
    while(r - l > 1) {
        vector<int> B = A;
        int m = (l + r) / 2;
        rep(i, m) {
            B[i] += N;
        }
        cout << "? ";
        voutput(B);
        cout.flush();
        string current;
        cin >> current;
        if(first != current) {
            r = m;
        }
        else {
            l = m;
        }
    }
    
    if(first == "Red") {
        ans[r - 1] = 0;
        ans[r - 1 + N] = 1;
    }
    else {
        ans[r - 1] = 1;
        ans[r - 1 + N] = 0;
    }
    
    vector<int> C;
    rep(i, N) {
        if(i == r - 1) continue;
        if(i < r) C.pb(i + 1);
        else C.pb(i + 1 + N);
    }
    C.pb(0);
    string current;
    rep(i, N) {
        if(i == r - 1) continue;
        if(i < r) {
            C[N - 1] = i + 1 + N;
        }
        else C[N - 1] = i + 1;
        cout << "? ";
        voutput(C);
        cout.flush();
        cin >> current;
        if(current == "Red") ans[C[N - 1] - 1] = 0;
        else ans[C[N - 1] - 1] = 1;
    }
    
    C.clear();
    rep(i, N) {
        if(i == r - 1) continue;
        if(i < r) C.pb(i + 1 + N);
        else C.pb(i + 1);
    }
    C.pb(0);
    rep(i, N) {
        if(i == r - 1) continue;
        if(i < r) {
            C[N - 1] = i + 1;
        }
        else C[N - 1] = i + 1 + N;
        cout << "? ";
        voutput(C);
        cout.flush();
        cin >> current;
        if(current == "Red") ans[C[N - 1] - 1] = 0;
        else ans[C[N - 1] - 1] = 1;
    }
    
    
    
    string a = "! ";
    rep(i, 2 * N) {
        if(ans[i] == 0) a += 'R';
        else a += 'B';
    }
    cout << a << endl;
    cout.flush();
    
    return 0;
}


Measured memory_bytes: 724
nstr=["0","1","2","3","4","5","6","7","8","9"]

k=int(input())
#k=100000
k=k-1

kcnt=-1
m=[]
ms=[""]*100000

for ii in range(1,10):
    kcnt=kcnt+1
    ms[kcnt]=nstr[ii]
#    m.append(nstr[ii])
#    print(kcnt,ms[kcnt])
    if kcnt>=k:
        print(ms[k])
        break                

ked=-1
while kcnt<k:
    kst=ked+1
    ked=kcnt
    for i in range(kst,ked+1):
        i2=int(ms[i][-1])
        for ii in range(max(i2-1,0),min(i2+1,9)+1):
            kcnt=kcnt+1
            ms[kcnt]=ms[i]+nstr[ii]
#            print(kcnt,ms[kcnt])
            if kcnt>=k:
                print(ms[k])
                break                
        if kcnt>=k:
#            print(k)
            break                


Measured memory_bytes: 10092
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
INF = float('inf')

class SegmentTree:

    def __init__(self, N):
        self.N = 1<<(N-1).bit_length()
        self.data = [None] * (2*self.N)

    def Update(self, l, r, t, v):
        L, R, val = l+self.N, r+self.N, (t, v)
        while L < R:
            if R & 1:
                R -= 1
                self.data[R-1] = val
            if L & 1:
                self.data[L-1] = val
                L += 1
            L >>= 1
            R >>= 1

    def getValue(self, x):
        x += self.N-1
        ret = (-1, INF)
        while x >= 0:
            if self.data[x]:
                ret = max(ret, self.data[x])
            x = (x-1)//2
        return ret[1]

N, Q = map(int, input().split())
stx = [[int(x) for x in input().split()] for i in range(N)]
stx.sort(key = lambda v : -v[2])
D = [(int(input()), i) for i in range(Q)]
D.sort(key = lambda v : v[0])
d, p = [d for d, p in D], [p for d, p in D]
seg = SegmentTree(Q)
for i, (s, t, x) in enumerate(stx):
    l = bisect_left(d, s-x)
    r = bisect_left(d, t-x)
    seg.Update(l, r, i, x)
ans = [None] * Q
for i in range(Q):
    tmp = seg.getValue(i)
    if tmp == INF:
        tmp = -1
    ans[p[i]] = tmp
print(*ans, sep = '\n')


Measured memory_bytes: 119368
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

bool check(int n, int arr[]){
    if(n==1) return true;
    
    arr[0]--;
    for(int i=0; i<n-1; i++){
        if(arr[i] == arr[i+1]) continue;
        if(arr[i] < arr[i+1]){
            arr[i+1]--;
        }
        else return false;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    int arr[n];
    ip(arr, n);

    (check(n, arr))?cout<<"Yes\n":cout<<"No\n";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long n,i,j,k,ans,y;
	ans=0;
	string x,xx;
	cin>>x;
	cin>>k;
	if (k==1)
	{
		ans=ans+(x.length()-1)*9+int(x[0])-48;
		cout<<ans<<endl;
	}
	else if (k==2)
	{
		i=x.length();
		if (i>=2)
		{
			ans=ans+((i-2)*(i-1)*81)/2;
			for (j=1;j<i;j++)
			{
				if (x[j]=='0')
				{
					continue;
				}
				else
				{
					break;
				}
			}
			ans=ans+(int(x[0])-49)*(i-1)*9;
			if (j==i)
			{
				ans=ans;
			}
			else
			{
				ans=ans+(i-j-1)*9;
				ans=ans+int(x[j])-48;	
			}
			cout<<ans<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
	else
	{
		i=x.length();
		if (i>=3)
		{
			y=0;
			ans=ans+((i-1)*(i-2)*(i-3)*729)/6;
			//cout<<ans<<endl;
			ans=ans+((int(x[0])-49)*81*(i-2)*(i-1))/2;
			//cout<<ans<<endl;
			for (j=1;j<i;j++)
			{
				if (x[j]=='0')
				{
					continue;
				}
				else
				{
					break;
				}
			}
			xx="";
			while (j<i)
			{
				xx=xx+x[j];
				j++;
			}
			//cout<<xx<<endl;
			i=xx.length();
			y=y+((i-2)*(i-1)*81)/2;
			for (j=1;j<i;j++)
			{
				if (xx[j]=='0')
				{
					continue;
				}
				else
				{
					break;
				}
			}
			y=y+(int(xx[0])-49)*(i-1)*9;
			if (j==i)
			{
				y=y;
			}
			else
			{
				y=y+(i-j-1)*9;
				y=y+int(xx[j])-48;	
			}
			ans=ans+y;
			cout<<ans<<endl;						
		}
		else
		{
			cout<<0<<endl;
		}		
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)5e3 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 
const double pi = acos(-1.0);
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        

int n, d, ans = inf, cnt, p[maxn], dp[maxn][maxn];
vi g[maxn];

int dist(int a, int b){
	if(a == b) return 0;
	int &res = dp[a][b];
	if(res != -1) return res;
	res = inf;
	if(p[a]) res = min(res, dist(p[a], b) + 1);
	if(p[b]) res = min(res, dist(a, p[b]) + 1);
	return res;
}

void dfs(int v, int par){
	p[v] = par;
	for(auto to : g[v])
		if(to != par)
			dfs(to, v);
}
void solve(){
	scanf("%d%d", &n, &d);
	forn(i, 1, n - 1){
		int u, v;	
		scanf("%d%d", &u, &v);
		g[u].pb(v);
		g[v].pb(u);
	}
	memset(dp, -1, sizeof(dp));
	dfs(1, 0);
	forn(root, 1, n){
		if(!(d & 1)){
			cnt = 0;
			forn(go, 1, n)
				if(dist(root, go) > d / 2) cnt++;
			ans = min(ans, cnt);
		}else{
			for(auto to : g[root]){
				cnt = 0;
				forn(i, 1, n)
					if(min(dist(root, i), dist(to, i)) > d / 2)
						cnt++;
				ans = min(ans, cnt);
			}
		}
	}
	printf("%d", ans);
}
int main () {
	int t = 1;
	while(t--)
		solve(); 
}

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

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


Measured memory_bytes: 256
n = int(input())
a, b = 0, 0
for i in range(n):
    c = input().split()
    if c[0] == c[1]:
        a += 1
        b += 1
    else:
        pc = c[0]
        sc = sorted(c)
        if pc == sc[0]:
            b += 3
        else:
            a += 3
print(a, b)



Measured memory_bytes: 5600
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)1e6 + 7)
#define N ((int)2e5 + 7)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < pair < ll, pair < ll, ll > >,  null_type,  less < pair < ll, pair < ll, ll > > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).



int main()
{
    fastio;
    string str;
    cin>>str;
    for(int i = 0 ; i<3 ; i++) cout<<str[i];
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pi 3.174
int main() {
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        m[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<m[i]<<endl;
}

Measured memory_bytes: 13008
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  var w = ""

  def shuffle(cnt:Int, w:String):String = {
    if(cnt == 0) { w }
    else {
      val m = readInt
      shuffle(cnt-1, (w+(w take m)) drop m)
    }
  }

  while( { w = readLine.trim;w } != "-") {
    val n = readInt
    println(shuffle(n,w))
  }
}

Measured memory_bytes: 43760
#include <stdio.h>

int main(void) {
    int amount, remainder;
    int change = 0;

    do {
        scanf("%d", &amount);
    } while (amount < 1 || 10000 < amount);
    
    remainder = amount % 1000;
    if (remainder != 0) {
        change = 1000 - remainder;
    }
    printf("%d\n", change);

    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;

    if (!s.compare("Sunny"))
    {
        cout << "Cloudy" << endl;
    }else if(!s.compare("Cloudy")){
        cout << "Rainy" << endl;
    }else if(!s.compare("Rainy")){
        cout << "Sunny" << endl;
    }

    // cout << fixed;
    // cout << setprecision(10);

    // if (x >= a * a * b / 2)
    // {

    //     cout << atan(2 * (pow(a, 2) * b - x) / pow(a, 3) )* 180 / M_PI << endl;
    // }
    // else
    // {
    //     cout << atan(a * b * b / (2 * x)) * 180 / M_PI << endl;
    // }

    // ll answer = 1;

    // ll last = n;

    // for (ll i = 1; i < n; i++)
    // {
    //     if (i > last || i * i > n)
    //     {
    //         break;
    //     }

    //     if (n % i == 0)
    //     {
    //         if (i < n - i)
    //         {
    //             answer = (i - 1) + (n / i - 1);
    //             last = n / i;
    //         }
    //         else
    //         {
    //             break;
    //         }
    //     }
    // }

    // cout << answer << endl;

    // bool flg = false;

    // for (int i = 1; i <= 9; i++)
    // {
    //     if (n % i == 0)
    //     {
    //         if ((n / i) >= 1 && (n / i) <= 9)
    //         {
    //             flg = true;
    //             break;
    //         }
    //     }
    // }

    // if (!flg)
    // {
    //     cout << "No" << endl;
    // }
    // else
    // {
    //     cout << "Yes" << endl;
    // }

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

    // vector<ll> a;
    // for (int i = 0; i < n; i++)
    // {
    //     int j;
    //     cin >> j;
    //     a.push_back(j);
    // }

    //sort(a,a+n); ソート
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (A == B) {
        cout << "YES" << endl;
        return 0;
    }

    if (A <= B) {
        A += V * T;
        B += W * T;
        if (B <= A) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        // B < A
        A -= V * T;
        B -= W * T;
        if (A <= B) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3644