akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main(){
	int n,m;
    cin >> n >> m;
    int s[3];
    int c[9];
    map<int ,int>q;
    bool j = true;
    for(int i = 0; i < m; i++){
    	int t;
    	cin >> s[i] >> t;
    	if(q[s[i]-1] == 0){
    		q[s[i]-1] = t;
    		c[i] = t;
    	}
    	else{
    		if(q[s[i]-1] != t) {
    			j = false;
    		}
    		else{
    			c[i] = t;
    		}
    	}
    }
    if(j == false){
			cout << "-1" << endl;
			return 0;
    }

    int ans_a[3]={1,0,0};
    int ans_b[2]={1,0};
    int ans_c[2]={0,0};
    int ans =0;

    if(n == 3){
    	for(int i = 0; i<m; i++){
    		ans_a[s[i]-1] = c[i];
    	}
    }
    if(n == 2){
    	for(int i = 0; i<m; i++){
    		ans_b[s[i]-1] = c[i];
    	}
    }
    if(n == 1){
    	for(int i = 0; i<m; i++){
    		ans_c[s[i]-1] = c[i];
    	}
    }


    if(n > 1){
    	for(int i = 0; i<m ; i++){
			if((s[i] == 1) && (c[i] == 0)){
				cout << "-1" << endl;
				return 0;
			}
    	}
    }
    if(n == 3){
    	ans = ans_a[0]*100 + ans_a[1]*10 + ans_a[2];
    }
    else if(n == 2){
    	ans = ans_b[0]*10 + ans_b[1];
    }
    else if(n == 1){
    	ans = ans_c[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n,a,b;
  bool yy=true,mm=true;
  cin >> n;
  b=n%100;
  a=(n-b)/100;
  if (a==0||a>12) mm=false;
  if (b==0||b>12) yy=false;
  if (yy||mm){
    if (!yy) cout << "MMYY\n";
    else if (!mm) cout << "YYMM\n";
    else cout << "AMBIGUOUS\n";
  }else cout << "NA\n";
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::pair;using std::set;using std::string;using std::vector;
using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;
#define ff first
#define ss second
#define pb emplace_back
template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}
template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
}}init;

#define int ll
const int MAXN = 3e5 + 1;
const ll MOD = 998244353;
int gcd (int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd (b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
 
bool find_any_solution (int a, int b, int c, int & x, int & y, int & g) {
    g = gcd (abs(a), abs(b), x, y);
    if (c % g != 0)
        return false;
    x *= c / g;
    y *= c / g;
    if (a < 0)   x *= -1;
    if (b < 0)   y *= -1;
    return true;
}

#define sqr(x) ((x)*(x))

ll bp(ll a, ll pw) { 
    ll res(1);
    for (; pw; a = sqr(a) % MOD, pw /= 2) 
        if (pw & 1) 
            res = (res * a) % MOD;
    return res;
}
ll reverse(ll a) {return bp(a, MOD - 2); }

const int MAXC = MAXN + 5;

ll f[MAXC], rev[MAXC];

struct __prepare{
    __prepare() {
        f[0] = 1;
        for (int i = 1; i < MAXC; ++i) f[i] = (f[i - 1] * i) % MOD;
        rev[MAXC - 1] = reverse(f[MAXC - 1]);
        for (int i = MAXC - 2; i >= 0; --i) rev[i] = (rev[i + 1] * (i + 1)) % MOD;
    }
} __prepare;
ll C(ll n, ll k) {
    if (k > n) return 0;
    return (((f[n] * rev[k]) % MOD) * rev[n - k]) % MOD;
}


int32_t main() {
    
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    int ans = 0;
    for (int r = 0; r <= n; ++r) {
        int s = k - r * a;
        if (s % b) continue;
        int c = s / b;
        if (c < 0 || c > n) continue;
        ans += C(n, r) * C(n, c) % MOD;
    }
    ans %= MOD;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
int min(int a,int b){return a<b?a:b;}
int n,odd[maxn],uno[maxn],a[maxn];
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(register int i=2;i<=n;i+=2){
		++uno[a[i-1]];
		++odd[a[i]];
	}
	register int max_odd=0,ci_odd=0,odd_data=-1,ci_odd_data=-1;
	register int max_uno=0,ci_uno=0,uno_data=-1,ci_uno_data=-1;
	for(register int i=0;i<maxn;i++){
		if(odd[i]>max_odd){
			ci_odd_data=odd_data;
			odd_data=i;
			ci_odd=max_odd;
			max_odd=odd[i];
		}else if(odd[i]>ci_odd){
			ci_odd_data=i;
			ci_odd=odd[i];
		}
		if(uno[i]>max_uno){
			ci_uno_data=uno_data;
			uno_data=i;
			ci_uno=max_uno;
			max_uno=uno[i];
		}else if(uno[i]>ci_uno){
			ci_uno_data=i;
			ci_uno=uno[i];
		}
	}
	if(odd_data!=uno_data)
		printf("%d",n-max_odd-max_uno);
	else{
		int minn=2147483647;
		minn=min(minn, n-max_odd-ci_uno );
		minn=min(minn, n-ci_odd-max_uno );
		printf("%d",minn);
	}
	return 0;
}

Measured memory_bytes: 1408
def solve(S):
    N = len(S)
    res = 0
    xa = 0
    bx = 0
    ba = 0

    for s in S:
        if s[-1] == 'A' and s[0] == 'B':
            ba += 1
        else:
            xa += int(s[-1] == 'A')
            bx += int(s[0] == 'B')
        res += s.count('AB')

    if ba == 0:
        return res + min(xa,bx)

    if xa > 0 and bx > 0:
        res += ba + 1
        xa -= 1
        bx -= 1
    elif xa > 0:
        res += ba
        xa -= 1
    elif bx > 0:
        res += ba
        bx -= 1
    else:
        res += ba - 1

    return res + min(xa,bx)

from itertools import permutations
def naive(S):
    
    return max(''.join(x).count('AB') for x in permutations(S))

from random import randrange

# N = 5
# for i in range(100000):
#     print(i)

#     S = [''.join(chr(ord('A')+randrange(3)) for _ in range(3)) for _ in range(N)]

#     r1 = solve(S)
#     r2 = naive(S)
#     if r1 != r2:
#         print(r1,r2)
#         print(S)
#         break

N = int(input())
S = [input() for _ in range(N)]
print(solve(S))

Measured memory_bytes: 100192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    UnionFind uft(n);
    while(q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c) {
            cout << uft.same(x, y) << '\n';
        } else {
            uft.unite(x, y);
        }
    }
}


Measured memory_bytes: 3268
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum(arr[:n]))


Measured memory_bytes: 41628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;



long long int n,m,k,a[200005],b[200005],c,d,count=0,res=0,tmp;
int main() {
    int count=0;
    string str;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=n+1;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    if(a[1]<=b[1]){
        res+=a[1];
        b[1]=b[1]-a[1];
    }else{
        res+=b[1];
        b[1]=0;
    }
    for(int i=2;i<=n+1;i++){
        if(a[i]<=b[i-1]){
            res+=a[i];
        }else if(a[i]<=b[i]+b[i-1]){
            res+=a[i];
            b[i]-=a[i]-b[i-1];
        }else{
            res+=b[i-1]+b[i];
            b[i]=0;
        }
    }
    
    cout<<res<<endl;
    
} 


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#include<algorithm>
 int a[10000];
 int main()
   {
     int t,k,s=0;
     cin>>t>>k;
     int a[t];
   for(int i=0;i<t;i++)
      {
        cin>>a[i];
      }
      sort(a,a+t);
    for(int i=0;i<k;i++)
      {
        s+=a[i];
      }
      cout<<s<<endl ;
   }

Measured memory_bytes: 3636
package main
import "fmt"
import "math"
func main(){
    // Your code here!
    var n int
    fmt.Scan(&n)
    t := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&t[i])
    }
    sum := 0
    for i := 0; i < n; i++{
        sum += t[i]
    }
    
    f := float64(sum)/float64(n)
    b := f - float64(int(f))
    var y int
    if b >= 0.5{
        y = int(math.Ceil(f))
    }else{
        y = int(math.Floor(f))
    }
    csum := 0
    for i := 0; i < n; i++{
        csum += (t[i] - y) * (t[i] - y)
    }
    fmt.Println(csum)
}


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

int h, w;
set<int> st;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	for(int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < w; j++) if(s[j] == '#') {
			if(st.count(i+j)) {
				cout << "Impossible";
				return 0;
			}
			st.insert(i+j);
		}
	}
	cout << "Possible";
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string S; cin >>S;
    set<char> chars;    

    for (char ch: S)
        chars.insert(ch);

    yes(S.size()==chars.size());
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 100005
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n, m, k;

int main(){
	scanf("%d %d %d", &n, &m, &k);
	
	FI(i, 0, n) FI(j, 0, m){
		if(k == i * m + j * n - (i * j) * 2){
			puts("Yes");
			return 0;
		}
	}
	
	puts("No");
	return 0;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

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


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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a==b)cout << "Draw";
    else if(a==1) cout << "Alice";
    else if(b==1) cout << "Bob";
    else if(a>b)cout << "Alice";
    else            cout << "Bob";
}


Measured memory_bytes: 3588
#include<iostream>
using namespace std;

int main() {
        int n[100], x[100], result[100], i, j, k, l, m;
        for (i = 0; i < 100; i++) {
                result[i] = 0;
                cin >> n[i] >> x[i];
                if (n[i] == 0 && x[i] == 0) break;
        }
        for (m = 0; m < i; m++) {
                for (j = 1; j < n[m] + 1; j++) {
                        for (k = 1; k < n[m] + 1; k++) {
                                for (l = 1; l < n[m] + 1; l++) {
                                        if (j != k && k != l && j != l) {
                                                if (j + k + l == x[m]) {
                                                        result[m]++;
                                                }
                                        }
                                }
                        }
                }
        }
        for (m = 0; m < i; m++) {
                cout << result[m] / 6 << endl;
        }
        return 0;
}

Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int dp[1000009];
int main(){
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n/i;j++){
            if(i*j!=n)

            ans++;
                                      
        }
    }
    cout<<ans<<endl;
    system("pause");
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		int p;
		cin >> p >> s;
		if (u[p]) {
			continue;
		}
		if (s == "AC") {
			u[p] = 1;
			ans++;
			res += a[p];
			continue;
		}
		a[p]++;
	}
	cout << ans << ' ' << res << '\n';
   	return Accepted;
}

// B...a

Measured memory_bytes: 19072
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)


void Main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int c = 0;
	rep(i, N+1)
	{
		int d = 0;
		int M = i;
		while (M != 0)
		{
			d += M % 10;
			M /= 10;
		}

		if (A <= d && d <= B) c += i;
	}

	cout << c << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;


string decToBinary(int n)
{
    // array to store binary number
    string binaryNum="000000";

    // counter for binary array
    int i = 0;
    while (n > 0)
    {

        // storing remainder in binary array
        //binaryNum[i] = char (n % 2);

        if(n%2)
        {
            binaryNum[i]='1';
        }
        else
        {
            binaryNum[i]='0';
        }

        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    //reverse(binaryNum.begin(),binaryNum.end());
    return binaryNum;
}


int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    cin>>n>>m>>k;

    char arr[n+1][m+1];

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>arr[i][j];
        }
    }

    ans=0;
    x=y=1;
    for(int i=0; i<n; i++)
        x*=2;
    for(int i=0; i<m; i++)
        y*=2;

    for(int l=0; l<x; l++)
    {
        for(int r=0; r<y; r++)
        {
            c=0;
            string s1= decToBinary(l);
            string s2= decToBinary(r);
            //cout<<s1<<endl<<s2<<endl;
            for(int i=1; i<=n; i++)
            {
                for(int j=1; j<=m; j++)
                {

                    if( (s1[i-1]=='0' && s2[j-1]=='0') && arr[i][j]=='#')
                    {
                        c++;
                    }
                }
            }
            //cout<<c<<endl;
            if(c==k)
            {
                ans++;
            }
        }
    }






    cout<<ans<<endl;

}



Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main()
{
    long long a[200001], amax=-1, amax2=-1, i, amaxidx, n;
    cin >>n;
    for(i=0;i<n;i++){
        cin >>a[i];
        if(a[i]>amax){
            amax2=amax;
            amax=a[i];
            amaxidx=i;
        }
        else if(a[i]>amax2){
            amax2=a[i];
        }
    }
    for(i=0;i<n;i++){
        if(amaxidx==i) cout << amax2 <<endl;
        else cout << amax <<endl;
    }
    return 0;
}
    

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int solve(int a) {
	return a * (a - 1) / 2;
}
int main() {
	int n, m;
	cin >> n >> m;
	cout << solve(n) + solve(m);
 }


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// 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();
}

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

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

  int n;
  cin >> n;
  vector<lint> H(n);
  rep(i, n) cin >> H[i];

  bool flag = true, f = true;
  rep(i, n - 1) {
    if(f) H[i]--;
    if (H[i] > H[i + 1]) flag = false;
    if(H[i] == H[i+1]) f = false;
    else f = true;
  }

  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}

Measured memory_bytes: 1024
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;
#define ll long long
#define endl '\n'
#define x first
#define y second
#define pb push_back
#define all(k) (k).begin(),(k).end()
#define fr(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define db(k) cerr << #k<< " = " << k << endl



#define get(a) scanf("%d",&a)
int32_t main(){
 	//ios::sync_with_stdio(0); cin.tie(0);
	int n;
	get(n);
	stack<int> q;
	fr(i,1,n){
		int a;
		get(a);
		q.push(a);
	}	
	int ans=0,c=0;
	while(q.size()){
		c=0;
		int aux = q.top();
		q.pop();
		while(q.size() and aux<=q.top()){
			aux = q.top();
			q.pop();
			c++;
		}
		ans=max(ans,c);


	}


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


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    
    double p[N];
    int i;
    for(i = 0; i < N; i++) {
        cin >> p[i];
        p[i] = ((double)p[i] + 1.0) / 2.0;
    }

    double wa = 0.0;
    for (i = 0; i < K; i++) {
        wa += p[i];
    }
    double max = wa;

    for (i = 0; i < N - K; i++) {
        wa = wa + p[K+i] - p[i];
        if (max < wa) max = wa;
    }

    std::cout.setf(std::ios::left, std::ios::adjustfield);
    cout << setw(25) << setprecision(15) << max << endl;

    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K,N; cin >> N >> K ;
  vi x(N),y(N);
  rep(i,N) cin >> x[i] >> y[i] ;
  vi posx,posy;
  posx = x; posy = y;
  sort(ALL(posx)); sort(ALL(posy));
  vvi s(N,vi(N));
  rep(i,N){
    int idx1 = int(lower_bound(posx.begin(),posx.end(),x[i])-posx.begin());
    int idx2 = int(lower_bound(posy.begin(),posy.end(),y[i])-posy.begin());
    s[idx1][idx2]++;
  }
  rep(i,N) rep(j,N-1) s[i][j+1] += s[i][j];
  rep(i,N-1) rep(j,N) s[i+1][j] += s[i][j];
  dump(s);
  auto rsum = [&](int x1,int y1,int x2,int y2){
    int a2 = (y1!=0 ? s[x2][y1-1] : 0);
    int a3 = (x1!=0 ? s[x1-1][y2] : 0);
    int a4 = ((x1!=0 && y1!=0) ? s[x1-1][y1-1] : 0);
    return s[x2][y2] - a2 - a3 + a4;
  };
  unsigned long long ansx,ansy;
  using ld = long double;
  ld anss = 4e20;
  rep(x1,N-1) REP(x2,x1+1,N) rep(y1,N-1) REP(y2,y1+1,N) {
    dump(x1,y1,x2,y2,rsum(x1,y1,x2,y2));
    if(rsum(x1,y1,x2,y2)<K) continue;
    if(ld(posx[x2]-posx[x1])*ld(posy[y2]-posy[y1])>anss) continue;
    ansx = posx[x2] - posx[x1];
    ansy = posy[y2] - posy[y1];
    anss = ld(posx[x2]-posx[x1])*ld(posy[y2]-posy[y1]);
  }
  cout << ansx * ansy << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*A[N-1]から見ていって、B[N-1] > A[N-1]ならans += B[N-1]-A[N-1]
B[N-1] == A[N-1]ならans += 0, B[N-1] < A[N-1]ならans += (A/B + 1)*B - B
A[N-2]以降について、A[i] += ans として同様の操作を行う
*/


int main() {
  string S,T;
  cin >> S >> T;
  cout << T+S <<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int main(){
    long long n;
    cin >> n;
    map<long long, long long> T;

    long long sum = 0;

    for(long long i = 0; i < n; i++){
        long long a;
        cin >> a;
        sum += a;
        if(T.find(a) == T.end()){
            T[a] = 1;
        }
        else{
            T[a]++;
        }
    }

    long long q;
    cin >> q;
    vector<long long> result(q);

    for(long long i = 0; i < q; i++){
        long long b, c;
        cin >> b >> c;
        if(T.find(b) == T.end()){
            result[i] = sum;
        }
        else{
            sum += (c-b)*T[b];
            
            if(T.find(c) == T.end()){
                T[c] = T[b];
            }
            else{
                T[c] += T[b];
            }

            T.erase(b);
            result[i] = sum;
        }
    }

    for(long long i = 0; i < q; i++){
        printf("%lld\n", result[i]);
    }
    return 0;

}

Measured memory_bytes: 7824
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.exception : enforce;

int n, p;
int[] a;

void main() {
    scan(n, p);
    a = readln.split.to!(int[]);

    auto dp = new long[][](2, 2);
    dp[0][0] = 1L;

    foreach (i, ai; a) {
        i &= 1;
        dp[i ^ 1][0] = dp[i][0] + dp[i][ai & 1];
        dp[i ^ 1][1] = dp[i][1] + dp[i][ai & 1 ^ 1];
    }

    writeln(dp[n & 1][p]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b) printf("%d\n",c);
  if(b==c) printf("%d\n",a);
  if(c==a) printf("%d\n",b);
  return 0;
}

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

int main() {
  string s,t;
  int i,j,a;
  cin>>s>>t;
  for(i=0;i<s.size()-1;i++){
    for(j=i+1;j<s.size();j++){
      if(s.at(i)>s.at(j)){
        a=s.at(i);
        s.at(i)=s.at(j);
        s.at(j)=a;
      }
    }
  }
  
  //cout<<s<<endl;
  
  for(i=0;i<t.size()-1;i++){
    for(j=i+1;j<t.size();j++){
      if(t.at(i)<t.at(j)){
        a=t.at(i);
        t.at(i)=t.at(j);
        t.at(j)=a;
      }
    }
  }
  
 // cout<<t<<endl;
  
  if(s<t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
      
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using namespace boost::icl;

int main() {
	string S;

	cin >> S;
  
    vector<int> r(S.length(), 1);
  
    for (int i = 0; i < S.length() - 1; i++)
    	if (S[i] == 'R') {
          if (S[i+1] != 'L') {
            r[i + 2] += r[i];
            r[i] = 0;
          }
    }
  
    for (int i = S.length() - 1; i >= 1; i--)
    	if (S[i] == 'L') {
          if (S[i-1] != 'R') {
            r[i - 2] += r[i];
            r[i] = 0;
          }
    }

  cout << r[0];
  
  for (int i = 1; i < r.size();i++)
	cout << " " << r[i];
  cout << endl;

	return 0;
}


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

int main() {
	int n;
	int a[114514];
	int c[114514]{};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		c[a[i]]++;
		c[a[i] + 1]++;
		c[a[i] - 1]++;
	}
	int ans = 0;
	for (int i = 0; i < 100001; i++) {
		ans = max(ans, c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
using namespace std;
int n;
bitset <4000010> b;
int a[2010];
int main() {
    scanf("%d",&n);
    int sum=0;
    for (int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    b[0]=1;
    for (int i=1;i<=n;i++) b=b|(b<<a[i]);
    sum=(sum+1)/2;
    while (b[sum]==0) sum++;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 2304
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class Log {
		int t, n, s;
		Log(int t, int n, int s) {
			this.t = t;
			this.n = n;
			this.s = s;
		}
	}
	
	void run() {
		int N, M, r, q;
		while (true) {
			N = sc.nextInt(); M = sc.nextInt();
			if (N == 0) break;
			boolean[][] students = new boolean[M][721];
			r = sc.nextInt();
			Map<Integer,List<Log>> log = new HashMap<Integer, List<Log>>();
			for (int i = 0; i < r; i++) {
				int t = sc.nextInt(), n = sc.nextInt(), m = sc.nextInt(), s = sc.nextInt();
				if (log.containsKey(m)) {
					log.get(m).add(new Log(t,n,s));
				} else {
					List<Log> list = new ArrayList<Log>();
					list.add(new Log(t,n,s));
					log.put(m, list);
				}
			}
			
			for (int i = 1; i <= M; i++) {
				if (log.containsKey(i)) {
					List<Log> list = log.get(i);
					for (int j = 0; j < list.size()-1; j++) {
						if (list.get(j).s == 1) {
							int pc = list.get(j).n;
							for (int k = j+1; k < list.size(); k++) {
								if (list.get(k).n == pc) {
									for (int l = list.get(j).t; l <= list.get(k).t; l++) {
										students[i-1][l-540] = true;
									}
									break;
								}
							}
						}
					}
				}
			}
			
			q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int ts = sc.nextInt(), te = sc.nextInt(), m = sc.nextInt();
				int count = 0;
				boolean f = false;
				for (int j = ts; j <= te; j++) {
					if (students[m-1][j-540]){
						if (f)
							count++;
						else
							f = true;
					} else {
						f = false;
					}
				}
				out.println(count);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main(void)
{
	char in_str[12];	/* ??\????????????????´? ??????????????¨????????????????????? */ 
	int num_pattern[10];	/* ?¨?????????????????´? */	
	int i,j;
	
	while(fgets(in_str, 12, stdin) != NULL)
	{
		/* ??????????????°???????????? */
		for(i=0; i<10; i++)
		{
			num_pattern[i] = in_str[i] - '0';
		}
	
		/* ??°???????????????????¨???? */
		for(i=1; i<10; i++)
		{
			for(j=0; j<(10-i); j++)
			{
				num_pattern[j] = (num_pattern[j]
					  	 +num_pattern[j+1])
					 	 %10;		
			}

		}
		/* ?¨???????????????¨??? */
		printf("%d\n", num_pattern[0]);

	}	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	map<int, int> p;
	cin >> n >> m;
	REP(i, n) REP(j, m){
		char c;
		cin >> c;
		if(c == '#'){
			if(p[i+j] ++){
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool issame(vector<pair<int,int>> &v, int i)
{
	return v[i].first==v[i].second;
}
const int maxN=1e6+10;
int prime[maxN];
void seive(int n)
{
	for(int i=0;i<=n;i++) prime[i]=0;
	prime[1]=1;
	prime[0]=1;
	for(long long int i=2;i<n;i++)
	{
		if(prime[i]==0)
		{
			prime[i]=i;
			for(long long int j=i*i;j<=n;j+=i)
			{
				prime[j]=i;
			}
		}
	}
}
int find(int n)
{
	int cnt=1;
	if(n==1) return 1;
	while(n>1)
	{
		int p=0;
		int k=prime[n];
		while(n%k==0)
		{
			n/=k;
			p++;
		}
		cnt*=(p+1);
	}
	return cnt;
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	seive(n);
	// for(int i=0;i<n;i++)
	// cout<<prime[i]<<" ";
	long long int cnt=0;
	for(int i=1;i<n;i++)
	{
		cnt+=find(n-i);
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 7484
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

#define MAXN   100001

int spf[MAXN];

void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

vector<int> getFactorization(ll x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

vector<ll> primeFactors(ll n)  {
	vector<ll> res;
    while (n % 2 == 0)  {
    	res.push_back(2);
        n = n/2;
    }
    for (ll i = 3; i * i <= n; i = i + 2)  {
        while (n % i == 0)  {
            res.push_back(i);
            n = n/i;
        }
    }
    if (n > 2)
        res.push_back(n);
    return res;
}

void testcase() {
	//sieve();
    ll n; cin >> n;
    vector<ll> fac = primeFactors(n);
    sort(fac.begin(), fac.end());
    int m = fac.size();

    int i=0;
    int res = 0;
    while (i < m) {
    	ll cur = fac[i];
    	int ct = 0;
    	while (i < m && cur == fac[i]) {
    		ct++;
    		i++;
    	}
    	int sum = 0, c = 0;
    	while (true) {
    		sum += c;
    		if (sum  > ct) {
    			c--;
    			break;
    		}
    		c++;
    	}
    	res += c;
    }
    cout << res;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}


Measured memory_bytes: 3660
fun main(args: Array<String>) {
  val line = readLine()
  if (line != null) {
    val A = Integer.parseInt(line.split(" ")[0])
    val B = Integer.parseInt(line.split(" ")[1])
    if ((A+B) % 2 == 0) {
      println((A+B)/2)
    } else {
      println("IMPOSSIBLE")
    }
  }
}
    

Measured memory_bytes: 35952
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [n, _, x] <- map read . words <$> getLine :: IO [Int]
  (ls, gs) <- partition (> x) . map read . words <$> getLine
  print . minimum $ map length [ls, gs]

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

int main() {
  long long A, B, K; cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      A /= 2;
      B += A;
    }
    else {
      B /= 2;
      A += B;
    }
  }
  cout << A << " " << B << endl;
}

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

int main(void) {
    long long N, M;
    cin >> N >> M;
    if (N >= 2 && M >= 2) {
        cout << (N - 2) * (M - 2) << endl;
    } else if (N >= 2 || M >= 2) {
        cout << -(N - 2) * (M - 2) << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

map<string, int> mp;

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    long long ans = 0;
    for (map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it)
    {
        ans += ((it->second * 1LL * (it->second - 1)) / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    double half = a*b/2;
    double ans;
    if (s >= half){
        double r = (b - s/a)*2;
        ans = atan2(r,a)/M_PI*180.0;
    } else {
        double r = s/b*2;
        ans = atan2(r,b)/M_PI*180.0;
        ans = 90.0 - ans;
    }
    cout << fixed << setprecision(7) << ans << endl;

    return 0;
}

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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

const int N = 510;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n, m;
char a[N][N], ans[N][N][2];

int main() {
    n = read(), m = read();
    Rep(i, 1, n) gets(a[i] + 1);
    Rep(i, 1, n) {
        int pos = i & 1;
        Rep(j, 1, m) {
            ans[i][j][pos] = '#', ans[i][j][pos ^ 1] = a[i][j];
        }
    }
    Rep(i, 1, n) {
        ans[i][1][0] = '#', ans[i][m][0] = '.';
        Rep(j, 1, m) putchar(ans[i][j][0]);
        putchar('\n');
    }
    putchar('\n');
    Rep(i, 1, n) {
        ans[i][m][1] = '#', ans[i][1][1] = '.';
        Rep(j, 1, m) putchar(ans[i][j][1]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include<string.h>

int main()
{
    long long int n,sum=0,sh,max;
    scanf("%lld",&n);
    long long int s[n];
    //len = sizeof(s)/sizeof(s[0]);
    for(int i=0; i<n; i++){
        scanf("%lld",&s[i]);
    }
    max = s[0];
    for(int i=1; i<n; i++ ){
        if(max>s[i]){
            sh = max-s[i];
            sum += sh;}
        else
            max = s[i];
    }
    printf("%lld\n",sum);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int ans = 1;
  while(ans*2 <= N){
    ans *= 2;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,l[3],m=100000001,f;
	scanf("%d\n",&n);
	rep(i,n){
		scanf("%d",l+i);
		m=min(m,l[i]);
	}
	reps(i,1,m){
		f=1;
		rep(j,n)if(l[j]%i!=0)f=0;
		if(f)printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1188
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e;
    for (ll j = 0, i = k; i < n; i++, j++)
    {
        if (a[i] > a[j])
            cout << "Yes";
        else
            cout << "No";
        cout << '\n';
    }
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int64_t> a(200001), b(200001, 0);
    
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    for (int i = 0; i < N; i++){
        b.at(a.at(i) - 1)++;
    }
    int64_t sum = 0;
    for (int i = 0; i < N; i++){
        if (b.at(i) >= 2) {
            sum += (b.at(i) - 1) * b.at(i) / 2;
        }
    }
    
    for (int i = 0; i < N; i++){
        cout << sum - b.at(a.at(i) - 1) + 1 << endl;
    }
}

Measured memory_bytes: 5760