akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main(){

    ll x, k, d;
    L3(x, k, d);
    ll kol = abs(x) / d;
    if( kol > k) {
        ll bol = d * k;
        ll res = x;
        if( x < 0) res += bol;
        else res -= bol;
        cout<<abs(res)<<endl;
     }else {
        ll bol = d * kol;
        ll res = x;
        if( x < 0) res += bol;
        else res -= bol;

        k -= kol;

        int fl = 1;
        if(res > 0) fl = -1;
        if(k % 2) {
            res += fl * d;
        }

        cout<<abs(res)<<Endl;

     } 
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


int ar[sz];

int main()
{
  fastio;
  ll t, a, b, c, ans=0, i, n;
  cin>>n;
  
  for(i=0; i<n; i++)cin>>ar[i];
  
  for(i=1; i<n; i++)
  {
      if(ar[i]<ar[i-1])
      {
          b=abs(ar[i]-ar[i-1]);
          ans+=b;
          ar[i]+=b;
      }
  }
  cout<<ans<<endl;
}


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

using namespace std;

const int MAXN = 2007;

int n, m, q;
int a[MAXN][MAXN];
int v[MAXN][MAXN];
int eh[MAXN][MAXN], ev[MAXN][MAXN];
char s[MAXN];

int main(){

    scanf("%d%d%d", &n, &m, &q);
    for(int i=1; i<=n; i++){
        scanf("%s", s);
        for(int j=1; j<=m; j++){
            a[i][j] = s[j-1] == '1' ? 1 : 0;
        }
    }

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

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            eh[i][j] = eh[i-1][j] + eh[i][j-1] - eh[i-1][j-1];
            ev[i][j] = ev[i-1][j] + ev[i][j-1] - ev[i-1][j-1];
            if(a[i][j] == 1){
                ev[i][j] += a[i-1][j];
                eh[i][j] += a[i][j-1];
            }
        }
    }

    // for(int i=1; i<=n; i++){
    //     for(int j=1; j<=m; j++){
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // for(int i=1; i<=n; i++){
    //     for(int j=1; j<=m; j++){
    //         cout << v[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // for(int i=1; i<=n; i++){
    //     for(int j=1; j<=m; j++){
    //         cout << eh[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // for(int i=1; i<=n; i++){
    //     for(int j=1; j<=m; j++){
    //         cout << ev[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    int x1, x2, y1, y2;

    for(int i=1; i<=q; i++){
        scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
        int vcnt = v[y2][x2] - v[y2][x1-1] - v[y1-1][x2] + v[y1-1][x1-1];
        int ecnt = ev[y2][x2] + eh[y2][x2] - ev[y2][x1-1] - eh[y2][x1] - ev[y1][x2] - eh[y1-1][x2] + eh[y1-1][x1] + ev[y1][x1-1];
        // cout << "VCNT: " << vcnt << " ECNT: " << ecnt << endl;
        printf("%d\n", vcnt-ecnt);
    }


    return 0;
}

Measured memory_bytes: 64640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
int power(int a,int b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
    
    
        
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;++i)
            cin>>a[i];
        int ans=0;
        for(int i=0;i<n;++i)
        {
            int temp=0;
            for(int j=i+1;j<n;++j)
            {
                if(a[j]<=a[j-1])
                {
                    if(j==n-1)
                        i=n-1;
                    temp++;
                }
                else
                {
                    i=j-1;
                    break;
                }
            }
            //cout<<i<<" "<<temp<<endl;
            ans=max(ans,temp);
        }
        cout<<ans;

}

Measured memory_bytes: 1024
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  cout << (10000 - N) % 1000 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long int t,d;
cin>>t>>d;
long long int p,q;
long long int ans=0;
while(t)
{
    t--;
    cin>>p>>q;
    if(p*p+q*q<=d*d)
    ans++;
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3188
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	//Flength:環状線の円周 store:店の数 order:注文の数 ans:answer
	ll Flength, store, order, ans;
	vector<ll> locate;

	while(cin >> Flength)
	{
		if(Flength == 0) break;
		
		cin >>store >> order;
		
		ans = 0;
		locate.clear();

		ll wk;
		for(int i = 0; i < store - 1; i++)
		{
			cin >> wk;
			locate.push_back(wk);
		}
		locate.push_back(0);
		locate.push_back(Flength);

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

		for(int i = 0; i < order; i++)
		{
			cin >> wk;
			for(int i = 0; i < locate.size(); i++)
			{
				if(locate[i] > wk)
				{
					ans += min(locate[i] - wk, wk - locate[i-1]);
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2120
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>

using namespace std;

template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }

template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; }
template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; }
template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); }
//オーバーフローするとき+INFを返す
//
int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
		vector<string> a(n), b(m); 
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}

	for(int i = 0; i < m; ++i){
		cin >> b[i];
	}

	for(int i_zero = 0; i_zero < n-m+1; ++i_zero){
		for(int j_zero = 0; j_zero < n-m+1; ++j_zero){
			bool isSame = true;
			for(int i = 0; i < m; ++i){
				for(int j = 0; j < m; ++j){
					isSame = isSame && (b[i][j] == a[i_zero+i][j_zero+j]);
				}
			}

			if(isSame) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i = 0, j = 0, k = 0, n = 0;
    int m, f, r;
    char ans[50] = {0};

    while (1)
    {
        scanf("%d %d %d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1)
            break;
        if (m == -1 || f == -1)
            ans[j] = 'F';
        else if (m + f >= 80)
            ans[j] = 'A';
        else if (m + f >= 65)
            ans[j] = 'B';
        else if (m + f >= 50)
            ans[j] = 'C';
        else if (m + f >= 30)
            if (r >= 50)
                ans[j] = 'C';
            else
                ans[j] = 'D';
        else
            ans[j] = 'F';
        j += 1;
    }
    for (i = 0; i < 50; i++)
    {
        if (ans[i] == 0)
            break;
        printf("%c\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 2752
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int N;
    cin>>N;
    string a,b;
    cin >> a >> b;
    string c;
    REP(i,N){
        c += a[i];
        c += b[i];
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}

// g++ -std=c++11 prac.cpp
ll Max=-1,Min=1e9+1;

int main(){
    ll x,x2,y,y2,n,m,k,l,r,w,sum1=0,sum2=0,ans=0,amax=-1,amax2=-1,bmax=-1,bmax2=-1;
    string s,t;
    bool f=true;
    cin >> n;
    VI a(n/2);
    VI b(n/2);
    VI aa(100001);
    VI bb(100001);
    rep(i,n/2){
        cin >> a[i] >> b[i];
        aa[a[i]]++;
        bb[b[i]]++;
	}
    rep(i,100001){
        if(amax < aa[i]) {
            amax2 = amax;
            amax = aa[i];
            x2 = x;
            x = i; 
        }
        else if (amax2 < aa[i]){
            amax2 = aa[i];
            x2 = i;
        }

        if(bmax < bb[i]) {
            bmax2 = bmax;
            bmax = bb[i];
            y2 = y;
            y = i; 
        }
        else if (bmax2 < bb[i]){
            bmax2 = bb[i];
            y2 = i;
        }
    }
    if(x == y){
        if(bmax2 < amax2){
            ans += n/2 - amax2;
            ans += n/2 - bmax;
        }
        else{
            ans += n/2 - bmax2;
            ans += n/2 - amax;
        }
    }
    else{
        ans += n/2 - amax;
        ans += n/2 - bmax;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1408
grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')


Measured memory_bytes: 38256
H, N  = map(int, input().split())
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j+a, H)
        dp[nj] = min(dp[nj], dp[j]+b)
print(dp[H])

Measured memory_bytes: 54364
N = int(input())
x = []
sum = 0

for i  in range(N):
    x.append(list(map(str, input().split())))

for i in range(N):
    if x[i][1] == 'BTC':
        sum += float(x[i][0]) * 380000
    else:
        sum += float(x[i][0])

print(sum)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

long double dp[3000] = {0.0L};
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, target;
    cin >> n;
    target = (n+1)/2;
    dp[0] = 1.0L;
    while(n--)
    {
        long double p;
        cin >> p;
        for(int i = 2999; i > 0; i--)
            dp[i] = dp[i]*(1.0L - p) + dp[i-1]*p;
        dp[0] = dp[0]*(1.0L - p);
    }
    long double ans = 0.0L;
    for(int i = target; i <= 2999; i++)
        ans += dp[i];
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3848
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	string  s,t;
	cin >> s >> t;
	int count = t.size();

	for (int i = 0; i <= s.size() - t.size();i++) {
		int ch = 0;
		for (int j = 0; j < t.size();j++) {
			if (s[j+i]!=t[j]) {
				ch++;
			}
		}
		count = min(count, ch);
	}

	cout << count << endl;

	return 0;
}


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

const int MAXN = 100005;
const int INF = 2000000000;
int dp[MAXN];
int h[MAXN];

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


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, a[SIZE], k, ans;
int main() {
	io(); cin >> n;
	k = 1;
	while (n) {
		ans += k;
		k <<= 1;
		n /= 2;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



vcs splitAll(string s, string t) {
	vcs r;
	for (int p = 0; (p = s.find(t)) != s.npos;) {
		r.pb(s.substr(0, p));
		s = s.substr(p + t.size());
	}
	r.pb(s);
	return r;
}

int main() {
	string line;
	getline(cin, line);
	
	vcs ans;
	
	vcs split = splitAll(line, " ");
	for_(i, 0, (int)split.sz) {
		string sp = split[i];
		vcs filt1 = splitAll(sp, ",");
		vcs filt2 = splitAll(filt1[0], ".");
		
		string rest = filt2[0];
		int len = (int)rest.sz;
		if (len >= 3 && len <= 6) ans.pb(rest);
	}
	
	int n = (int)ans.sz;
	for_(i, 0, n-1) cout << ans[i] << " ";
	cout << ans[n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 1192
from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]
 
rev = False
 
for i in range(Q):
  if int(Q_list[i][0]) == 1:
    rev = not rev
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if rev ^ (int(F) == 1): # 排他的論理和片方真片方ぎの時真になる
      S.appendleft(C) # 反転している場合は、末尾、先頭追加を逆にする
    else:
      S.append(C)
      
if rev: # 最終的に反転している場合は反転させる
  S.reverse()
  
print(''.join(S))

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

int main() {
	int N, K, X;
  	cin >> N >> K;
  	X = 1
  rep (i, N) {
  	if (X < K) X *= 2;
    else X += K;
  }
  cout << X << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N, A;
    cin >> N;
    vi data(N);
    int maxnum = 0;
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
        maxnum = max(maxnum, data.at(i));
    }
    vi count(maxnum + 1, 0);
    for (int x : data) {
        count.at(x)++;
    }
    bool check = true;
    if (count.at(maxnum) > 1) {
        check = false;
    }
    int secondnum;
    for (int i = maxnum - 1; i > 0; i--) {
        if (count.at(i) != 0) {
            secondnum = i;
            break;
        }
    }
    for (int i = 0; i < N; i++) {
        if (data.at(i) == maxnum && check) {
            cout << secondnum << endl;
        }
        else {
            cout << maxnum << endl;
        }
    }
}

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

class prog{
  static void Main(){
    
    int[] w = Console.ReadLine().Split().Select(int.Parse).ToArray();
    Console.WriteLine((w[0] + w[1] > w[2] + w[3]) ? "Left" : (w[0] + w[1] == w[2] + w[3]) ? "Balanced" : "Right");
    
  }
}

Measured memory_bytes: 13268
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
x,y = rl()
for i in range(x+1):
    if i*2+(x-i)*4==y:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 61872
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    ll m=0;
    ll a=0;
    ll r=0;
    ll c=0;
    ll h=0;
    rep(i,n){
        cin >> s.at(i);
        if(s.at(i).at(0)=='M')m++;
        else if(s.at(i).at(0)=='A')a++;
        else if(s.at(i).at(0)=='R')r++;
        else if(s.at(i).at(0)=='C')c++;
        else if(s.at(i).at(0)=='H')h++; 
    }
    unsigned long long ans;
     ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout << ans << endl;
}

Measured memory_bytes: 6144
N = int(input())
A = list(map(lambda x: int(x), input().split(' ')))
A.append(0)
A.insert(0, 0)

S = sum([abs(A[i+1] - A[i]) for i in range(N+1)])
for i in range(1, N+1):
    diff = abs(A[i+1] - A[i-1])
    diff -= abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])
    print(S + diff)



Measured memory_bytes: 65244
import sys
sys.setrecursionlimit(10**9)

def main():
    N,M = map(int,input().split())
    H = list(map(int,input().split()))

    ok = [True] * N


    for i in range(M):
        A,B = map(int,input().split()) # 1-index
        if H[A-1] > H[B-1]:
            ok[B-1] = False
        elif H[A-1] < H[B-1]:
            ok[A-1] = False
        else:
            ok[A-1] = False
            ok[B-1] = False


    ans = 0
    for opt in ok:
        if opt:
            ans += 1

    # print(ok)
    print(ans)

if __name__ == "__main__":
  main()


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N; cout << N*N*N << endl;
    return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/
int N;
int A[220000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 1; i < N; i++) {
        if (A[i] - A[i - 1] > 1) {
            cout << -1 << endl;
            return 0;
        }
        if (A[i] - A[i - 1] == 1) {
            ans++;
        } else {
            ans += A[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main() {
    int n, m;
    int C[MMAX + 1];
    int T[NMAX + 1];
    
    cin >> n >> m;
    
    for ( int i = 1; i <= m; i++ ) {
        cin >> C[i];
    }
    
    for ( int i = 0; i <= NMAX; i++ ) T[i] = INFTY;
    T[0] = 0;
    for ( int i = 1; i <= m; i++ ) {
        for ( int j = 0; j + C[i] <= n; j++ ) {
            T[j + C[i]] = min(T[j + C[i]], T[j] + 1 );
        }
    }
    
    cout << T[n] << endl;
    
    return 0;
}


Measured memory_bytes: 3312
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
// #include <xmmintrin.h>
// #include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,k;
    cin>>n>>k;
    vec a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    lint ans=0;
    rep(i,n){
        if(i>=k)ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    ll N = s.size();
    vector<ll> v;
    bool check = false;
    if (s[0] == '>') {
        check = true;
    }
    ll tmp = 1;
    for (ll i = 1; i < N; i++) {
        if (check) {
            if (s[i] == '>') {
                tmp++;
            } else {
                v.emplace_back(tmp);
                tmp = 1;
                check = !check;
            }
        } else {
            if (s[i] == '<') {
                tmp++;
            } else {
                v.emplace_back(tmp);
                tmp = 1;
                check = !check;
            }
        }
    }
    v.emplace_back(tmp);
    N = v.size();
    ll sum = 0;
    for (ll i = 0; i < N; i += 2) {
        if (i == 0 && s[0] == '>') {
            sum += (v[i] + 1) * (v[i]) / 2;
            i--;
        } else if (i == N - 1) {
            sum += (v[i] + 1) * v[i] / 2;
        } else if (v[i] >= v[i + 1]) {
            sum += ((v[i] + 1) * v[i] + (v[i + 1]) * (v[i + 1] - 1)) / 2;
        } else {
            sum += ((v[i + 1] + 1) * v[i + 1] + (v[i]) * (v[i] - 1)) / 2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c - (a - b);
    cout << max(0, ans) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    int ans1,ans2;
    scanf("%d %d %d",&a,&b,&c);
    ans1=a*b;
    ans2=c;
    printf("%d",min(ans1,ans2));
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)

	A := make([]int, n+2)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i+1])
	}

	cstMax := 0
	for i := 0; i < n+1; i++ {
		cstMax += abs(A[i+1] - A[i])
	}

	for i := 1; i < n+1; i++ {
		ans := cstMax
		ans -= abs(A[i+1]-A[i]) + abs(A[i]-A[i-1])
		ans += abs(A[i+1] - A[i-1])

		fmt.Println(ans)
	}
}


Measured memory_bytes: 8452
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define all(e) e.begin(), e.end()
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

typedef long long ll;
typedef unsigned long long ull;

const int INF = ~(1 << 31);

using namespace std;

bool already[100001];
int num[100001];

vector<pair<int, int> > graph[100001];
// 自分用メモ
// vectorの配列、配列の各要素がfrom
// その中にtoとコストをpairで管理
bool ng = false;

void dfs(int n, int cost){
    //cerr << "from = " << n << ", currentcost = " << cost << endl;
    /*if(already[n]) cerr << "true" << endl;
    else cerr << "false" << endl;*/
    if(already[n]){
        //cerr << "num = " << num[n] << ", cost = " << cost << endl;
        if(num[n] != cost){
            ng = true;
            //cerr << "flag has standed" << endl;
        }
        return;
    }
    already[n] = true;
    num[n] = cost;
    //cerr << "size = " << graph[n].size() << endl;
    rep(i, graph[n].size()){
        pair<int, int> p = graph[n][i];
        //cerr << "to = " << p.first << ", cost = " << p.second << endl;
        dfs(p.first, p.second + cost);
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int l, r, d;
    rep(i, m){
        cin >> l >> r >> d;
        l--;
        r--;
        graph[l].push_back(make_pair(r, d));
        graph[r].push_back(make_pair(l, -d));
    }

    /*
    rep(i, n){
        rep(j, graph[i].size()){
            cerr << "from = " << i << ", to = " << graph[i][j].first << ", cost = " << graph[i][j].second << endl;
        }
    }*/

    memset(already, false, sizeof(already));
    rep(i, n){
        if(already[i]) continue;
        dfs(i, 0);

        if(ng){
            no;
            return 0;
        }
    }
    yes;

    return 0;
}

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


int main(){ 
    int a[3];
    int sum;
    char *ans;

    for (int i = 0; i < 3; ++i) {
        scanf("%d", &a[i]);
    }

    sum = a[0] + a[1]+a[2];
    
    if(sum >= 22){
        ans = "bust";
    }else{
        ans = "win";
    }
    printf("%s\n", ans);

    return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
bool solve() {
    int M, T, P, R; readf("%d %d %d %d\n", &M, &T, &P, &R);
    if (M == 0 && T == 0 && P == 0 && R == 0) return false;
    struct Team {
        int id;
        int ac;
        int penalty;
    }
    Team[] X = new Team[T];
    for (int i = 0; i < T; i++) X[i].id = i + 1;
    int[][] W = new int[][](T, P); // WA Count
    for (int i = 0; i < R; i++) {
        int m, t, p, j; readf("%d %d %d %d\n", &m, &t, &p, &j);
        t--; p--;
        if (j == 0) {
            X[t].ac++;
            X[t].penalty += m + W[t][p] * 20;
        } else {
            W[t][p]++;
        }
    }
    bool comp(in Team a, in Team b) {
        if (a.ac == b.ac) {
            if (a.penalty == b.penalty) {
                return a.id > b.id;
            } else {
                return a.penalty < b.penalty;
            }
        } else {
            return a.ac > b.ac;
        }
    }
    X = X.sort!(comp).array;
    printf("%d", X[0].id);
    for (int i = 1; i < T; i++) {
        if (X[i - 1].ac == X[i].ac && X[i - 1].penalty == X[i].penalty) {
            printf("=");
        } else {
            printf(",");
        }
        printf("%d", X[i].id);
    }
    printf("\n");
    return true;
}

void main() {
    while (solve()) {}
}

Measured memory_bytes: 1096
/*********************
 *ALDS_1_3_C:	     *
 *Doubly Linked List *
 *		     *
 *2019/08/06	     *
 *********************/

#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *prev ,*next;
};

Node *nil;

Node* search_list(int key){
  Node *cur = nil->next;
  
  while(cur != nil && cur->key != key) cur = cur->next;
  
  return cur;
}

void init_list(){
  nil = (Node*)malloc(sizeof(Node));
  nil->key = 0;
  nil->next = nil;
  nil->prev = nil;
}

void print_list(){
  Node *cur = nil->next;
  int isf=0;/*最初のみ空白入れないための変数*/

  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void delete_Node(Node *target){
  if(target == nil) return;
  target->prev->next = target->next;
  target->next->prev = target->prev;
  free(target);
}

void delete_First_Node(){
  delete_Node(nil->next);
}

void delete_Last_Node(){
  delete_Node(nil->prev);
}

void delete_Key_Node(int key){
  delete_Node(search_list(key));
}

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,i;
  int size = 0;
  char com[20];
  int np = 0,nd = 0;
  scanf("%d", &n);
  init_list();

  for(i=0; i < n;i++){
    scanf("%s%d",com,&key);
    switch(com[0]){
    case 'i':
      insert(key);
      np++;
      size++;
      break;
    case 'd':
      if(strlen(com) > 6){
	if(com[6] == 'F')
	  delete_First_Node();
	else
	  if(com[6] == 'L')
	    delete_Last_Node();
      }
      else{
	delete_Key_Node(key);
	nd++;
      }
      size--;
      break;
    default:
      fprintf(stderr,"%s is not option.\n",com);
      break;
    }
  }

  print_list();
  
  return 0;
}



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

typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int>t(n), a(n);
	ll T, A; T = A = 1;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
		ll tmp; tmp = max((T + t[i] - 1) / t[i], (A + a[i] - 1) / a[i]);
		T = t[i] * tmp, A = a[i] * tmp;
	}
	cout << A + T << endl;

	return 0;
}

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

int main(){
  int N;
  cin >>N;
  
  vector<int> L(N);
  int sum = 0;
  rep(i,0,N){
    cin >> L[i];
    sum += L[i];
  }
  
  string ans;
  int ML = *max_element(L.begin(),L.end());
  if(ML<sum-ML) ans = "Yes";                    
  else ans = "No";
  cout <<ans<<endl;
}

Measured memory_bytes: 256
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(d)]
t=[int(input()) for _ in range(d)]
l=[0]*26
ans=0
for i in range(1,d+1):
    ans+=s[i-1][t[i-1]-1]
    l[t[i-1]-1]=i
    for j in range(26):
        ans-=c[j]*(i-l[j])
    print(ans)

Measured memory_bytes: 9252
import sys
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
c = t - h[0] * 0.006
k = 1
for i in range(n):
    if abs(a-c) > abs(a-(t - h[i] * 0.006)):
        c = t - h[i] * 0.006
        k = i + 1
print(k)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

const i64 MOD = 1e9 + 7;

i64 mod_pow(i64 x, i64 n = MOD - 2) {
	i64 ret = 1;
	
	while(n) {
		if(n % 2) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	
	return ret;
}

std::vector<i64> fact;
i64 comb(int a, int b) {
	if(a == 0 || b == 0) return 1;
	return fact[a] * mod_pow(fact[b]) % MOD * mod_pow(fact[a - b]) % MOD;
}

int main(){
	i64 n, m; cin >> n >> m;
	
	i64 tmp = m;
	std::vector<std::pair<i64, i64>> prime;
	for(i64 i = 2; tmp != 1; i++) {
		if(tmp % i) continue; prime.push_back({i, 0});
		
		while(tmp % i == 0) {
			prime.back().second++;
			tmp /= i;
		}
	}
	
	fact.resize(200000, 0); fact[0] = 1;
	for(i64 i = 0; i < 200000; i++) fact[i + 1] = fact[i] * (i64)(i + 1) % MOD;
	
	i64 ans = 1;
	for(auto v : prime) {
		assert(v.second);
		(ans *= comb(n + v.second - 1, v.second)) %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 1792
"use strict";
    
const nC2 = (n) => {
    return (n * (n - 1)) / 2  
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let hashMap = {}
    
    // まず全体の答えを把握する
    for(let i=0; i<N; i++) {
        if(!hashMap[A[i]]) {
            hashMap[A[i]] = 1;
        } else {
            hashMap[A[i]]++;
        }
    }
    
    let allAnswer = 0;
    
    for(let key in hashMap) {
        if(hashMap[key] >= 2) {
            allAnswer += nC2(hashMap[key]);
        }
    }
    
    // console.log(allAnswer);
    // console.log(JSON.stringify(hashMap));
    
    let answer = [];
    
    // 抜いた状態で判定していく
    for(let i=0; i<N; i++) {
        let newHashValue = nC2(hashMap[A[i]] - 1);
        // console.log("hashMap[A[i]]" + hashMap[A[i]]);
        // console.log("newHashValue" + newHashValue);
        
        // if(newHashValue === 0) {
        //     newHashValue = 1;
        // }
        
        let diff = nC2(hashMap[A[i]]) - newHashValue;
        // console.log("diff" + diff)
        // console.log("-------");
        answer.push(allAnswer - diff);
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const ll INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    ll MIN = INF;

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

    for (int i = 0; i < N-K+1; i++) {
        ll diff = INF;
        diff = h[i+K-1]-h[i];
        MIN = min(MIN, diff);
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn dsum(x: u64) -> u64{
    let mut x = x;
    let mut res = 0;
    while x > 0{
        res += x%10;
        x /= 10;
    }

    res
}
fn main(){
    let n: u64 = read_as_vec::<u64>()[0];
    let harshed = dsum(n);

    if n%harshed == 0{
        println!("Yes");
    }else{
        println!("No");
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string s; cin >> s;
	int k = inf, n = s.length();
	Rep(i, n - 1){
		if(s[i] != s[i + 1]) k = min(k, max(i + 1, n - i - 1));
	}
	if(k == inf) cout << n << endl;
	else cout << k << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

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

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modInv(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modInv(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

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

  ll bin[n];//binom(i,k-1)
  bin[k-1]=1;
  for(i=k;i<n;i++){
    bin[i]=((bin[i-1]*i)%MOD*modInv(i-k+1))%MOD;
  }

  
  ll maxA[n+1];
  for(i=0;i<=n;i++){
    maxA[i]=0;
  }
  maxA[k]=a[k-1];
  
  for(i=k;i<n;i++){
    maxA[i+1]=(maxA[i]+a[i]*bin[i])%MOD;
  }

  reverse(all(a));
  ll minA[n+1];
  for(i=0;i<=n;i++){
    minA[i]=0;
  }
  minA[k]=a[k-1];
  
  for(i=k;i<n;i++){
    minA[i+1]=(minA[i]+a[i]*bin[i])%MOD;
  }
  cout<<(maxA[n]-minA[n]+MOD)%MOD<<endl;
}


Measured memory_bytes: 2944