akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    string s,ss;
    cin>>s>>ss;
    reverse(all(ss));
    if(s==ss)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
int main() {
    cin>>a>>b;
    if(a<=0 && b>=0) cout<<"Zero"<<endl;
    else if(a<0 && b<0){
        if((b-a)%2==0) cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    else cout<<"Positive"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define int long long
using namespace std;

const int N = 60;

signed main () {
  boost();
  int n, m; cin >> n >> m;
  if (m >= n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;





int main(){
    ll n,z,w,l,b;
    cin>>n>>z>>w;
    for(int i=0;i<n;i++){
        ll c;
        cin>>c;
        if(i==n-1){l=c;}
        if(i==n-2){b=c;}
    }
    if(n==1){cout<<abs(w-l)<<endl; return 0;}
    cout<<max(abs(w-l),abs(l-b))<<endl;
    
    
    return 0;
}

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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	while(getline(cin, s), s!="."){
		bool ok = true;
		int a = 0, b = 0;
		int state = 0;
		stack<char> st;
		rep(i,s.size()){
			if(s[i] == '('){
				st.push(s[i]);
			}
			else if(s[i] == ')'){
				if(st.empty() || st.top() != '('){
					ok=false;
				}
				else{
					st.pop();
				}
			}
			if(s[i] == '['){
				st.push(s[i]);
			}
			else if(s[i] == ']'){
				if(st.empty() || st.top() != '['){
					ok=false;
				}
				else{
					st.pop();
				}
			}
		}
		if(st.size()) ok=false;
		cout << (ok?"yes":"no") << endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, x;
	cin >> n >> x;
	vi m(n);
	rep(i, n) cin >> m[i];

	int ans = n;
	int sum = 0;
	rep(i, n) sum += m[i];
	sort(all(m));
	while(sum <= x)
	{
		ans++;
		sum += m[0];
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if (A.back() == B[0] && B.back() == C[0]) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

bool which_is_max(int a, int b, int c, int d) {
    return (double)b/(double)a > (double)d/(double)c;
}

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    set<int> st;
    for(int i=0; i*A*100<=F; i++) {
        for(int j=0; j*B*100<=F-i*A*100; j++) {
            st.insert(i*A+j*B);
        }
    }
    
    int Allans=A*100, Sans=0;
    int Alltmp, Stmp;
    int CDmax=max(C, D), CDmin=min(C, D);
    for(auto i=st.begin(); i!=st.end(); i++) {
        // cout << *i << endl;
        for(int j=0; (j*CDmax<=F-(*i)*100 && j*CDmax<=*i*E); j++) {
            Stmp = j*CDmax;
            Stmp += (min((F-(*i)*100-Stmp), *i*E-Stmp)/CDmin)*CDmin;

            Alltmp = (*i)*100;
            Alltmp += Stmp;
            // cout << Alltmp << " " << Stmp << ", " << Allans << " " << Sans << endl;
            if(which_is_max(Alltmp, Stmp, Allans, Sans)) {
                Allans = Alltmp;
                Sans = Stmp;
            }
        }
    }
    
    cout << Allans << " " << Sans << endl;


    return 0;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <queue>
#include <vector>
#include <memory.h>
using namespace std;

typedef pair<int, int> P;
#define rep(i,n) for(int i= 0; i < n;i++)
int ice[100010];

int main(){
  int n, l;
  while(cin >> n >> l && (n || l)){
    memset(ice, 0, sizeof(ice));
    priority_queue<P, vector<P>, greater<P> > que;
    rep(i, n) cin >> ice[i+2];
    rep(i, n){
      if(ice[i+2] > ice[i+1] && ice[i+2] > ice[i+3]){
	que.push(P(l - ice[i+2], i+2));
      }
    }
    int res = 0;
    while(!que.empty()){
      P p = que.top();
      que.pop();
      int tim = p.first;
      int pos = p.second;
      ice[pos] = 0;
      res = max(tim, res);
      if(ice[pos-1] > ice[pos] && ice[pos-1] > ice[pos-2]){
	que.push(P(tim + l - ice[pos-1], pos-1));
	
      }
      if(ice[pos+1] > ice[pos] && ice[pos+1] > ice[pos+2]){
	que.push(P(tim + l - ice[pos+1], pos+1));
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const ll INF=0x3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m,k;
string s;
ll arr[N];
ll dp[10010][110][2];

ll dfs(ll a,ll b,ll c){
	ll d,ans=0,bb;
	if(dp[a][b][c]!=-1){
		return dp[a][b][c];
	}
	if(a==n+1){
		if(b==0){
			return dp[a][b][c]=1;
		}
		else{
			return dp[a][b][c]=0;
		}
	}
	if(c==1){
		d=arr[a];
	}
	else{
		d=9;
	}
	for(ll i=0;i<=d;i++){
		bb=(b+i)%k;
		dp[a+1][bb][c&(i==d)]=dfs(a+1,bb,c&(i==d));
		ans=(ans+dp[a+1][bb][c&(i==d)])%mod;
	}
	return dp[a][b][c]=ans;
}

int main(){
	cin>>s>>k;
	n=s.size();
	for(ll i=1;i<=n;i++){
		arr[i]=s[i-1]-'0';
	}
	memset(dp,-1,sizeof(dp));
	
	printf("%lld\n",(dfs(1,0,1)-1+mod)%mod);

	return 0;
}





Measured memory_bytes: 19584
lines = readlines.map(&:strip)

n, a, b, c, d = lines.shift.split.map(&:to_i)
s = lines.shift.chomp.chars

blocker_index = []
(n-1).times do |index|
  blocker_index.push(index) if (s[index..index+1].join)=='##'
end

blocker_index.each do |index|
  if (a-1 <= index && index <= c-1) || (b-1 <= index && index <= d-1)
    puts 'No'
    exit
  end
end

if (d < c)
  space_index = []
  (n-2).times do |index|
    space_index.push(index) if (s[index..index+2].join)=='...'
  end

  space_index.each do |index|
    if ((b-2 <= index && index <= d-2))
      puts 'Yes'
      exit
    end
  end
  puts 'No'
else
  puts 'Yes'
end




Measured memory_bytes: 20420
// taskkill -im A.exe -f
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        PBDS;

#define int long long
#define endl "\n"
#define MOD 10
#define pb push_back
const int mxN = 1e6 + 500;
int ar[mxN];


int32_t main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int T;
	// cin >> T;
	T = 1;

	while (T--) {

		int n, k, c = 0, ans = 0, l = 0;

		string s;
		cin >> s;
		
		for (int i = 0; i < s.size(); ++i) {
			s[i] -= '0';
			ans += s[i];
		}

		// cout << ans << " ";

		if (ans % 9 == 0) {
			cout << "Yes";
		}
		else
			cout << "No";

		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3720
N,K = map(int,input().split())
As = [int(e)-1 for e in input().split()]
visited=[0]*N

town = 0
for k in range(K):
    town = As[town]

    if visited[town] > 0:
        break
    
    visited[town] = k+1

else:
    print(town+1)
    exit()

K = K-visited[town]
K=K%((k+1)-visited[town])


for _ in range(K):
    town = As[town]

print(town+1)

Measured memory_bytes: 32324
s = input()

dic = ["dream","dreamer","erase","eraser"]

while s != "":
  if s.endswith(dic[0]):
    s = s[:-5]
  elif s.endswith(dic[1]):
    s = s[:-7]
  elif s.endswith(dic[2]):
    s = s[:-5]
  elif s.endswith(dic[3]):
    s = s[:-6]
  else:
    break
else:
  print("YES")
  exit()
print("NO")

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int a,b,c;
  string st;
  cin >> a >> st;
  b = a;
  a = 0;
  c = 0;
  for(int i=0;i<b;i++){
    if(st.at(i)=='D') a--;
    else a++;
    c = max(c,a);
  }
  cout << c << endl;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
if(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]) cout << "Yes" << endl;
else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


int main() {
	ll K, A, B; cin >> K >> A >> B;
	if (K <= A - 1) {
		cout << K + 1 << endl;
		return 0;
	}
	ll ans = A;
	ans += (K - A + 1) / 2 * max(B - A, 2LL);
	ans += (K - A + 1) % 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

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

int main() {
    char c;
    cin >> c;
    cout << char(int(c) + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
     
    using namespace std;
     
    int main(){
      int n,t,c,tc,fc=100000;
      cin >> n >> t;
      for(int i=0;i<n;i++){
        cin>>c>>tc;
    	if(tc<=t)
          fc=min(fc, c);
      }
      if(fc < 100000)
        cout << fc << endl;
      else
        cout << "TLE" << endl;
      return 0;
    }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();

        if (t * s >= d)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32768
#include<stdio.h>
#include<string.h>
int main()
{
    int a[200005]={0};
    int i,x,n;
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
        scanf("%d",&x);
        a[x]++;
    }
    for(i=1;i<=n;i++)
        printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"YES":"NO");
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  vector<int> s(11);
  s[a]++;
  s[b]++;
  s[c]++;
  bool ans=false;
  if(s[5]==2&&s[7]==1){
    ans=true;
  }
  cout<<yesno(ans)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, l; cin >> n >> l;
    vint a(n);
    rep(i,n) cin >> a[i];
    bool ans = false;
    int last;
    rep(i,n-1) if (a[i]+a[i+1] >= l) {ans = true; last = i;}
    if (ans) {
        cout << "Possible" << endl;
        for (int i = 0; i <= last-1; i++) {
            cout << i + 1 << endl;
        }
        for (int i = n-2; i >= last+1; i--) {
            cout << i + 1 << endl;
        }
        cout << last + 1 << endl;
    }
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 3796
n=int(input())
A=[]
B=[]
sum=0
for i in range(n):
    a,b=map(int,input().split())
    A+=[a]
    B+=[b]
for i in range(n):
    for j in range(n):
        if i<j:
            sum+=((A[i]-A[j])**2+(B[i]-B[j])**2)**(1/2)
print(2*sum/n)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll ans = 0;
  ll n,m;cin>>n>>m;
  reps(_k,n){
    ll k = _k;
    ans += nCr(n,k) * kaijo(m) %MOD * gyaku_kaijo(m-k) %MOD * kaijo(m-k) %MOD * kaijo(m-k) % MOD * gyaku_kaijo(m-k-(n-k)) % MOD
          * gyaku_kaijo(m-k-(n-k)) % MOD * ((k%2*2 - 1));
    ans += MOD;
    ans %= MOD;
  }
  cout<<(kaijo(m) * gyaku_kaijo(m-n) % MOD * kaijo(m) % MOD * gyaku_kaijo(m-n) % MOD - ans + MOD) % MOD<<endl;
  return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int n,ans=0,sum=0;
int a[MAX]={};

int main()
{
  cin>>n;
  FOR(i,0,n){
    int b;
    cin>>b;
    a[b]++;
  }
  FOR(i,0,MAX){
    if(a[i]==0)continue;
    if(a[i]%2)ans++;
    else sum++;
  }
  cout<<ans+(sum/2)*2<<endl;
  return 0;
}



Measured memory_bytes: 640
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		if ("Sunny".equals(s)) {
			System.out.println("Cloudy");
		} else if ("Cloudy".equals(s)) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}	
}

Measured memory_bytes: 21332
x, y, z, k = map(int, input().split())
a = list(map(int, input(). split()))
b = list(map(int, input(). split()))
c = list(map(int, input(). split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

seen = [(0, 0, 0)]
stack = [((0, 0, 0), a[0]+b[0]+c[0])]
for _ in range(k):
    (na, nb, nc), s = stack.pop()
    print(s)
    if na<x-1 and (na+1, nb, nc) not in seen:
        seen.append((na+1, nb, nc))
        stack.append(((na+1, nb, nc), a[na+1]+b[nb]+c[nc]))
    if nb<y-1 and (na, nb+1, nc) not in seen:
        seen.append((na, nb+1, nc))
        stack.append(((na, nb+1, nc), a[na]+b[nb+1]+c[nc]))
    if nc<z-1 and (na, nb, nc+1) not in seen:
        seen.append((na, nb, nc+1))
        stack.append(((na, nb, nc+1) ,a[na]+b[nb]+c[nc+1]))
    stack.sort(key=lambda x:x[1])


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

#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  char c; cin >> c; 
  if (c=='A') END('T');
  if (c=='T') END('A');
  if (c=='C') END('G');
  if (c=='G') END('C');
}


Measured memory_bytes: 256
A, B = map( int, input().split())
Board = [ ['#']*100 for _ in range(50)] + [['.']*100 for _ in range(50)]
i = 0
nowj = 0
for _ in range(A-1):
    Board[i][nowj] = '.'
    if nowj == 98:
        nowj = 0
        i += 2
    else:
        nowj += 2
i = 51
nowj = 0
for _ in range(B-1):
    Board[i][nowj] = '#'
    if nowj == 98:
        nowj = 0
        i += 2
    else:
        nowj  += 2
print( '{} {}'.format(100, 100))
for i in range(100):
    print( ''.join(Board[i]))


Measured memory_bytes: 3188
s=input()+"q"
n=len(s)
l=[0 for i in range(n)]
cl,cr=0,0
c=1
for i in range(n):
  
  if s[i]=="R":
    
    if c==0:
      c=1
      l[A]=cr//2+cr%2+cl//2
      l[A+1]=cr//2+cl//2+cl%2
      cl,cr=0,0
    cr+=1
  elif s[i]=="L":
    
    if c==1:
      A=i-1
      c=0
    cl+=1
  else:
    l[A]=cr//2+cr%2+cl//2
    l[A+1]=cr//2+cl//2+cl%2
print(*l[:n-1])

Measured memory_bytes: 47772
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a,b,ans;

signed main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	ans=n/(a+b)*a;
	ans+=min(a,n%(a+b));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << v[n - 1] - v[0] << endl;
}


Measured memory_bytes: 256
import sys
ABCD = input() 
base_liste = [] 
for i in range(2**3):
    sous_liste = []
    for j in range(3):
        if ((i>>j) & 1):
            sous_liste.append('+')
        else: #not equal to ((i>>j)& 0)
            sous_liste.append('-')
    base_liste.append(sous_liste)
for sous_liste in base_liste:
    sum = 0
    Candidate = ABCD[0] 
    for i in range(3):
        if sous_liste[i] == '+':
            sum += int(ABCD[i+1])
            Candidate += '+' + ABCD[i+1]
        else:
            sum -= int(ABCD[i+1])
            Candidate += '-' + ABCD[i+1]
    if sum == 7-int(ABCD[0]):
        print(Candidate + '=7')
        sys.exit(0)

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

int main() {
    int n;
    cin >> n;
    int p[n], cnt = 0;
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 1; i < n - 1; i++) {
        vector<int> v;
        v.push_back(p[i - 1]);
        v.push_back(p[i]);
        v.push_back(p[i + 1]);
        sort(v.begin(), v.end());
        if (v[1] == p[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(void){
  int number, manipulate_number;
  cin >> number >> manipulate_number;

  string s;
  cin >> s;

  vector<int> nums;
  int now = 1;
  int cnt = 0;
  for(int i = 0; i < number; i++){
    if(s[i] == (char)('0' + now)) cnt++;
    else{
      nums.emplace_back(cnt);
      now ^= 1;
      cnt = 1;
    }
  }
  if(cnt != 0) nums.emplace_back(cnt);

  if(nums.size() % 2 == 0) nums.emplace_back(0);


  int add_range = 2 * manipulate_number + 1;
  vector<int> sum(nums.size() + 1);
  for(int i = 0; i < nums.size(); i++){
    sum[i + 1] = sum[i] + nums[i];
  }
  int ans = 0;

  for(int i = 0; i < nums.size(); i += 2){
    int left = i;
    int right = min(i + add_range, (int)nums.size());
    int tmp = sum[right] - sum[left];

    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>

using namespace std;

int main() {
    int i, m, f, r;
    int n = 0;
    int score[50][3] = {};

    for (i = 0; i < 50; i++) {
        cin >> m >> f >> r;

        score[i][0] = m;
        score[i][1] = f;
        score[i][2] = r;

        if (m == -1 && f == -1 && r == -1) break;

        n++;
    }
    
    for (i = 0; i < n; i++) {
        m = score[i][0];
        f = score[i][1];
        r = score[i][2];

        if (m == -1 || f == -1) cout << "F" << endl;
        else if (m + f >= 80) cout << "A" << endl;
        else if (m + f >= 65) cout << "B" << endl;
        else if (m + f >= 50) cout << "C" << endl;
        else if (m + f >= 30) {
            if (r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" << endl;
    }


    return 0;
}


Measured memory_bytes: 3100
A, B, C, D, E, F = gets.split.map(&:to_i)
answer = []

0.upto(F / (100 * A)) do |a_num|
  0.upto(F / (100 * B)) do |b_num|
    sugar_limit = F - (100 * A * a_num + 100 * B * b_num)
    next if sugar_limit.negative?

    0.upto(sugar_limit / C) do |c_num|
      0.upto(sugar_limit / D) do |d_num|
        sugar = C * c_num + D * d_num
        water = 100 * (A * a_num + B * b_num)
        weight = sugar + water

        if weight <= F && 100 * sugar <= E * water
          answer << [weight, sugar] unless weight.zero?
        end
      end
    end
  end
end

puts answer.max_by { |w, s| s.to_f / w }.join(' ')

Measured memory_bytes: 39036
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int A=kbd.nextInt();
   int B=kbd.nextInt();
   int x=-1;
   for(int i=13;i<=1010;i++){
     double n=Math.floor(i*0.08);
     double m=Math.floor(i*0.1);
     if(A==n&&B==m){
       x=i;
       break;
     }
   }
    System.out.println(x);
 }
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int n,ans;
pair<int,int> a[55];
map<pair<int,int>,int> m;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j) continue;
			m[{a[i].first-a[j].first,a[i].second-a[j].second}]++;
			ans=max(ans,m[{a[i].first-a[j].first,a[i].second-a[j].second}]);	
		}
	}
	cout<<n-ans;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");

			int n=Integer.parseInt(inp.readLine());
			int arr[][]=new int[n][3];
			for(int i=0;i<n;i++)
			{
				String h[]=inp.readLine().split(" ");
				for(int j=0;j<3;j++)
				{
					arr[i][j]=Integer.parseInt(h[j]);
				}
				if(i>0)
				{
					arr[i][0]+=Math.max(arr[i-1][1],arr[i-1][2]);
					arr[i][1]+=Math.max(arr[i-1][0],arr[i-1][2]);
					arr[i][2]+=Math.max(arr[i-1][0],arr[i-1][1]);
				}
			}
			System.out.println(Math.max(Math.max(arr[n-1][0],arr[n-1][1]),arr[n-1][2]));			
		
	}
	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 49372
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;


int main() {
  string a;
  cin >> a;
  int b = 0;
  for (int i=0; i<3; ++i){
    if(a[i] == '1'){
      b++;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
ll int sum(ll int a, ll int b)
{
    return (b - a + 1) * (a + b) / 2;
}
void findAns()
{
    ll int n, k;
    cin >> n >> k;

    ll int ans = 0;
    ll int  mod = 1e9 + 7;
    ll int minSum;
    ll int maxSum;
    for (int i = k; i <= n + 1; i++)
    {
        minSum = sum(0, i - 1);
        maxSum = sum(n - i + 1, n);
        ans = (ans + (maxSum - minSum + 1) ) % mod;
    }
    cout << ans % mod;

}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;,
    findAns();
}

Measured memory_bytes: 3656
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def main():
    N = int(input())
    g = [[] for _ in range(N)]
    edge_order = []
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append((i, b))
        edge_order.append(b)
    # 頂点1からBFS
    queue = deque([0])
    color = [0] * N
    while queue:
        v = queue.popleft()
        c = 1  # 色の初期値は一からスタート
        for i, u in g[v]:
            if c == color[v]:  # 親と色が同じ時
                c += 1
            color[u] = c
            c += 1
            queue.append(u)
    print(max(color))
    for i in edge_order:
        print(color[i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 28076
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

struct point{
    int x,y;
}p[200050];
int top;
int t[1000000];
int n;
int x[200050];
point sta,endd;

void write(int index,int l,int r,int aim,int num){
    if (l==r){
        t[index]=max(t[index],num);
        return;
    }
    int mid=(l+r)>>1;
    if (mid>=aim)       write(index<<1,l,mid,aim,num);
    else                write(index<<1|1,mid+1,r,aim,num);
    t[index]=max(t[index<<1],t[index<<1|1]);
}

int read(int index,int l,int r,int aiml,int aimr){
    if (aiml<=l&&r<=aimr){
        return t[index];
    }
    int mid=(l+r)>>1,ans=0;
    if (mid>=aiml)  ans=max(ans,read(index<<1,l,mid,aiml,aimr));
    if (mid<aimr)   ans=max(ans,read(index<<1|1,mid+1,r,aiml,aimr));
    return ans;
}

bool mmp1(point a,point b){
	return a.y<b.y||(a.y==b.y&&a.x<b.x);
}

bool mmp2(point a,point b){
	return a.y>b.y||(a.y==b.y&&a.x<b.x);
}

int main(){
    memset(t,0,sizeof(t));
    sta.x=read();sta.y=read();
    endd.x=read();endd.y=read();
    if (endd.x<sta.x)   swap(sta,endd);
    n=read();
    top=0;
    if (sta.y<endd.y){
        for (int i=1,tmpx,tmpy;i<=n;i++){
            tmpx=read();tmpy=read();
            if (tmpx>=sta.x&&tmpx<=endd.x
                &&tmpy>=sta.y&&tmpy<=endd.y)
                top++;
            else    continue;
            p[top].x=tmpx;p[top].y=tmpy;
        }
        sort(p+1,p+top+1,mmp1);
    }
    else{
        for (int i=1,tmpx,tmpy;i<=n;i++){
            tmpx=read();tmpy=read();
            if (tmpx>=sta.x&&tmpx<=endd.x
                &&tmpy<=sta.y&&tmpy>=endd.y)
                top++;
            else    continue;
            p[top].x=tmpx;p[top].y=tmpy;
        }
        sort(p+1,p+top+1,mmp2);
    }
    n=top;
    //加上同行或同列的特判
    if (sta.x==endd.x||sta.y==endd.y){
        double anns=0.0;
        if(n>0)     anns=anns+pi*10.0-20.0;
        anns=anns+fabs(sta.y-endd.y)*100.0+fabs(sta.x-endd.x)*100.0;
        printf("%.15lf\n",anns);
        return 0;
    }
    
    n=top;
    for (int i=1;i<=n;i++){
            x[i]=p[i].x;
    }
    sort(x+1,x+n+1);
    for (int i=1;i<=n;i++)  p[i].x=lower_bound(x+1,x+n+1,p[i].x)-x;
    for (int i=1;i<=n;i++){
        int num=read(1,1,n,1,p[i].x);
        write(1,1,n,p[i].x,num+1);
    }
    long long diff1=abs(sta.x-endd.x),diff2=abs(endd.y-sta.y);
    double ans=(pi*5-2*10)*t[1]+diff1*100.0+diff2*100.0;
    if (min(abs(sta.x-endd.x),abs(sta.y-endd.y))+1==t[1]) ans+=5.0*pi;
    printf("%.15lf\n",ans);
    return 0;
}

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

using namespace std;

int main(void) {
    int num[3];
    cin >> num[0] >> num[1] >> num[2];

    sort(num, num + 3);

    cout << num[0] << ' ' << num[1] << ' ' << num[2] << endl;

    return 0;
}

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

using namespace std;

int main(void){
    int N,X ,T;
    int iBuf1;
    int iBuf2;
    cin >> N >> X >> T;
    iBuf1 = N/X;
    iBuf2 = N % X;
    if(iBuf2 == 0)
    {
        cout << iBuf1*T << endl;
    }
    else
    {
        cout << (iBuf1+1)*T << endl;
    }
    
   
    
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n; cin >> n;
	int ans = int(sqrt(n));
	cout << ans * ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> x(N,0);
	rep(i, N) cin >> A[i];

	ll sum = 0;
	rep(i, N) {
		sum += A[i];
	}
	//cout << "sum " << sum << endl;

	ll sum_even = 0;
	for(int i=0; i<N-1; i=i+2) {
		sum_even += A[i]; 
	}
	//cout << "se " << sum_even << endl;
	x[N-1] = sum/2 - sum_even;
	x[0] = A[N-1] - x[N-1];
	for(int i=1; i<N-1; i++) {
		x[i] = A[i-1] - x[i-1]; 
	}

	rep(i, N) {
		cout << (x[i]*2) << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void) {
    int H, W, K, F, A[305], B[305], S[305], X[305][305], i, j;
    char s[305][305];
    scanf("%d%d%d", &H, &W, &K);
    for (i=0; i<H; i++) {
        A[i]=0;
        scanf("%s", s[i]);
        for (j=0; j<W; j++) {
            if (s[i][j]=='#') A[i]++;
            X[i][j]=0;
        }
        if (i==0) S[i]=A[i];
        else S[i]=S[i-1]+A[i];
    }
    i=0;
    while (A[i]==0) i++;
    F=i;
    for (i=0; i<H; i++) {
        if (A[i]!=0) {
            for (j=0; j<W; j++) {
                if (j==0) {
                    B[j]=0;
                    if (s[i][j]=='#') B[j]=1;
                }
                else {
                    B[j]=B[j-1];
                    if (s[i][j]=='#') B[j]++;
                }
                if (i==0) {
                    if (B[j]!=0) X[i][j]=B[j];
                    else X[i][j]=1;
                }
                else {
                    if (B[j]!=0) X[i][j]=S[i-1]+B[j];
                    else X[i][j]=S[i-1]+1;
                }
            }
        }
    }
    for (i=F; i<H; i++) {
        if (X[i][0]==0) {
            for (j=0; j<W; j++) X[i][j]=X[i-1][j];
        }
    }
    for (i=F; i>=0; i--) {
        if (X[i][0]==0) {
            for (j=0; j<W; j++) X[i][j]=X[i+1][j];
        }
    }
    for (i=0; i<H; i++) {
        for (j=0; j<W; j++) {
            printf("%d ", X[i][j]);
            if (j!=W-1) printf(" ");
            else if (i!=H-1) printf("\n");
        }
    }
    // printf("[%d]", F);
    return 0;
}


Measured memory_bytes: 1280
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N=int(input())
ans=factorization(N)
cnt=0
if N==1:
  print("0")
  exit()
for i in ans:
  num=i[1]
  j=1
  while num-j>=0:
    num=num-j
    j+=1
    cnt+=1
print(cnt)
    
  

Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 5555;

void lcs( string X, string Y, int m, int n ) { 
   int L[m+1][n+1];
   for (int i=0; i<=m; i++) { 
		for (int j=0; j<=n; j++) { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   int index = L[m][n]; 
   char lcs[index+1]; 
   lcs[index] = '\0';
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1];
          i--; j--; index--;
      }
      else if (L[i-1][j] > L[i][j-1]) i--;
      else j--;
   }
   cout << lcs << endl;
}
int main(){
	
	iofast;
	string X, Y;
	
	cin>>X>>Y;
	int m = X.size();
	int n = Y.size();
	lcs(X, Y, m, n);
	
	return 0;
}

Measured memory_bytes: 35456
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a:usize,
        b:usize,
    };

    let mut sums = [0; 999 + 1];
    for i in 1..1000 {
        sums[i] = sums[i-1] + i;
    }

    println!("{}", sums[b - a] - b);
}



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

map<int,int> m;
vector<int> v;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(m[x]==0) v.push_back(x);
		m[x]++;
	}
	
	int ans=0;
	for(int i=0;i<v.size();i++)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	
	cout<<ans;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll x[3], y[3];

int main(){
    cin >> N;
    for(int i = 0; i < 3; i++) cin >> x[i];
    for(int i = 0; i < 3; i++) cin >> y[i];
    vector<ll> dp;
    dp.resize(N + 1, 0);
    dp[N] = N;

    ll ans = 0;
    ll mx = N;
    for(int i = N; i >= 0; i--){
        chmax(mx, dp[i]);
        for(int j = 0; j < 3; j++){
            int to = i - x[j];
            if(to  < 0) continue;
            chmax(dp[to], dp[i] - x[j] + y[j]);
        }
    }
    chmax(ans, mx); 
    dp.resize(mx + 1, 0);
    dp[mx] = mx;

    for(int i = mx; i >= 0; i--){
        chmax(ans, dp[i]);
        for(int j = 0; j < 3; j++){
            int to = i - y[j];
            if(to < 0) continue;
            chmax(dp[to], dp[i] - y[j] + x[j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 195584