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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mod=998244353;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<int,int> ct;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin>>a[i], ct[a[i]]++;
	if(ct[0]!=1) {
		cout<<0<<"\n";
		return 0;
	}
	ll ret=1;
	for (int i=1; i<n; i++)
		ret=(ret*ct[a[i]-1])%mod;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<ll,ll>;

int main(void){
    int n;
    ll K;
    cin >> n >> K;
    vector<P> vp(n);
    rep(i,n) {
        ll t,d;
        cin >> t >> d;
        vp[i] = {d,t};
    }
    sort(all(vp),greater<P>());
    map<ll,bool> mp;
    vector<ll> tops, rems;
    ll rem_sum = 0;
    ll top_sum = 0;

    rep(i,n) {
        ll t = vp[i].second;
        ll d = vp[i].first;
        if (mp[t]) {
            rem_sum += d;
            rems.push_back(rem_sum);
        } else {
            mp[t] = true;
            top_sum += d;
            tops.push_back(top_sum);
        }
    }
    ll X = tops.size();
    ll res = 0;
    for(ll x = 1; x <= min(X,K); x++){
        ll tmp;
        if (K-x-1 < 0) tmp = 0;
        else if (K-x-1 >= (ll)rems.size()) {
            continue;
        }
        else tmp = rems[K-x-1];
        res = max(res, tops[x-1] + tmp + x*x);
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 200;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    if (n < 10)
    {
        cout << 100 * (10 - n) + r;
    }
    else
        cout << r;
}

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

const int MAXN = 310;
const int MAXV = 90010;
const int mod = 998244353;

int n;
int a[MAXN];
int dp[MAXN][MAXV], f[MAXV];

int powmod(int a, int b) {
    int ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = 1ll * ret * a % mod;
        a = 1ll * a * a % mod;
    }
    return ret;
}

void add(int &a, int b) {
    a = (a + b) % mod;
}

int main() {
    scanf("%d", &n);
    int S = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        S += a[i];
    }
    int ans = 0;
    dp[0][0] = f[0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= S; ++j) {
            // to max len
            if (j + a[i] <= S) {
                add(dp[i][j + a[i]], dp[i - 1][j]);
            }
            add(dp[i][j], dp[i - 1][j] * 2 % mod);
        }
        for (int j = S; ~j; --j) {
            if (j + a[i] <= S) {
                add(f[j + a[i]], f[j]);
            }
        }
    }
    for (int j = 0; j <= S; ++j) {
        if (j * 2 < S) continue;
        add(ans, dp[n][j] * 3ll % mod);
    }
    if (S % 2 == 0) {
        ans = ((1ll * ans - 3ll * f[S >> 1]) % mod + mod) % mod;
    }
    printf("%d\n", ((powmod(3, n) - ans) % mod + mod) % mod);
    return 0;
}


Measured memory_bytes: 106368
#include <iostream>
#include <queue>
#include <string.h>
#include <math.h>

using namespace std;

const int N = 1000000;

int prime[N+1];
int table[N+1];
int dish[30];
int n, x;
int max_val;

void setPrime()
{
	memset(&prime[0], 0, sizeof(int) * (N+1));
	prime[2] = 1;
	for(int i=2; i<=N; i++)
	{
		bool is_prime = true;
		int limit = sqrt(i);
		for(int k=2; k<=limit; k++)
		{
			if(i % k == 0)
			{
				is_prime = false;
				break;
			}	
		}
		
		if(is_prime)
		{
			prime[i] = 1;
		}
	}
}

void solve()
{
	int price;
	queue<int> q;
	q.push(0);
	
	while(!q.empty())
	{
		price = q.front();
		q.pop();
		
		if(price > x)
		{
			continue;
		}
		
		if(prime[price] == 1 && max_val < price)
		{
			max_val = price;
		}
		
		for(int k=0; k<n; k++)
		{
			int new_price = price + dish[k];
			if(new_price > N)
				continue;
			if(table[new_price] == 0)
			{
				table[new_price] = 1;
				q.push(new_price);
			}
		}
	}
}

int main()
{
	setPrime();
	
	while( 1 )
	{
		cin >> n >> x;
		if(n==0 && x==0)
		{
			break;
		}
		
		clock_t t = clock();
		for(int i=0; i<n; i++)
		{
			cin >> dish[i];
		}
		
		memset(&table[0], 0, sizeof(int)*(N+1));
		max_val = 0;
		solve();
		
		if(max_val != 0)
		{
			printf("%d\n", max_val);
		}
		else
		{
			printf("NA\n");
		}
	}
}	

Measured memory_bytes: 8960
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	int N, Y;

	cin >> N >> Y;
	Y /= 1000;

	for (int a = 0; a * 9 <= Y - N; a++) {
		for (int b = 0; a + b <= N && a * 9 + b * 4 <= Y - N; b++) {
			if (9 * a + 4 * b == Y - N) {
				int c = N - a - b;
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
	//end = clock();
	//printf("%d msec.\n", end - start);
}


Measured memory_bytes: 384
// B - 105
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

//約数の個数を出力
ll divisor_counter(ll n){
	if(n==1) return 1L;
	ll count = 0L;
	for(ll i=1L; i*i<=n; ++i) if(n%i == 0L) count++;
	return count*2L;
}

int main(){
	int N; cin>>N;
	ll ans = 0;
	for(int n=1; n<=N; n+=2)
		if(divisor_counter(n) == 8) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    ll ans = 360;
    while (true)
    {
        if (ans % n == 0)
        {
            cout << ans / n << endl;
            return 0;
        }
        ans += 360;
    }

    return 0;
}

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

using namespace std;

int main() {
  long long n, x = 0, i;
  string s;
  map<string, long long> m;
  map<string, long long>::iterator itr;
  cin >> n;
  for (i = 0; i<n; i++) {
    cin >> s;
    sort(s.begin(),s.end());
    itr = m.find(s);
    if (itr == m.end()) {
      m.insert(make_pair(s,1));
    } else {
      x += itr->second;
      itr->second += 1;
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Collections.Generic;


namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);
                //if(n==0){break;}

                string[] strs = Console.ReadLine().Split(' ');
                int[] ints = new int[n];
                for (int i = 0; i < n; i++) { ints[i] = int.Parse(strs[i]); }
                Array.Sort(ints);

                int sum = 0;
                int sumTotal = 0;
                for (int i = 0; i < n; i++) {
                    sum += ints[i];
                    sumTotal += sum;
                }
                Console.WriteLine(sumTotal);
            }   
        }   
    }
}

Measured memory_bytes: 5964
#include<stdio.h>
#define NUM 20
int main(void)
{
	int i, j;
	double str[NUM];
	double minas;
	double num;
	int a;
	scanf("%lf", &num);
	if (num < 10)  a = 1;
	else if (num < 100) a = 2;
	else if (num < 1000) a = 3;
	else if (num < 10000) a = 4;
	else if (num < 100000) a = 5;
	else if (num < 1000000) a = 6;
	else if (num < 10000000) a = 7;
	else if (num < 100000000) a = 8;
	else if (num < 1000000000) a = 9;
	else if (num < 10000000000) a = 10;
	else if (num <100000000000) a = 11;
	else if (num < 1000000000000) a = 12;
	else if (num < 10000000000000) a = 13;
	else if (num < 100000000000000) a = 14;
	else if (num < 1000000000000000) a = 15;
	else if (num < 10000000000000000) a = 16;
	else if (num < 100000000000000000) a = 17;
	else if (num < 1000000000000000000) a = 18;

	for (i = 0; i <= a - 1; i++)    //str配列を作る
	{
		if (i == a - 1)
		{
			str[i] = num;
			str[i] = (int)str[i];
		}
		else if (i != a - 1)
		{
			for (j = i; j <= a - 2; j++)
			{
				if (j == i)
				{
					minas = num / 10;
				}
				else if (j != i)
				{
					minas = minas / 10;
				}
			}
			str[i] = minas;
			str[i] = (int)str[i];
			for (j = i; j <= a - 2; j++)						//minas*10の形を作る
			{
				if (j == i)
				{
					minas = str[i];
					minas = minas * 10;
				}
				else if (j != i)
				{
					minas = minas * 10;
				}
			}
			num = num - minas;                        //num=num-（作り終えたminas）    
		}
	}
	for (i = a - 1; i>0; i--)
	{
		if (str[i] != 9)
		{
			str[i] = 9;
			if (str[i - 1] == 0)
			{
				str[i - 1] = 9;
				str[i - 2] = str[i - 2] - 1;
			}
			else if (str[i - 1] != 0)
			{
				str[i - 1] = str[i - 1] - 1;
			}
		}
	}
	double sum = 0;
	for (i = a - 1; i >= 0; i--)
	{
		sum = sum + str[i];
	}
	sum = (int)sum;
	printf("%.0lf\n", sum);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)

def padding(n)
  ("    " + n.to_s)[-4, 4]
end

def solve(n)
  f = Array.new(n)
  for i in 0...n
    f[i] = Array.new(n, 0)
  end

  x = 1 + n/2
  y = n/2
  for k in 1..(n*n)
    while f[x][y] > 0
      x += 1
      y += n-1
      x %= n
      y %= n
    end
    f[x][y] = k
    x += 1
    y += 1
    x %= n
    y %= n
  end

  for i in 0...n
    for j in 0...n
      print padding(f[i][j])
    end
    puts ''
  end
end

while true
  n = STDIN.gets.to_i
  if n == 0
    break
  else
    solve(n)
  end
end

Measured memory_bytes: 6124
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,r; cin>>n>>r;

    if(n>=10)cout<<r<<endl;
    else
    {
        cout<<r+100*(10-n)<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e6+1;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846

std::map<char, int> cnt;
char ans[200000];
string s[200000];

signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n;
    cin>>n;
    int a, b, c;
    cin>>a>>b>>c;
    cin>>s[0];
    cnt['A']=a;
    cnt['B']=b;
    cnt['C']=c;
    if(a+b+c==0){
    	cout<<"No"<<endl;
    	return 0;
    }
    else if(a+b+c==1){
    	int nn=n;
    	n--;
    	int i=1;
    	while(n--){
	    	cin>>s[i];
	    	i++;
	    }
	    n=nn;
	    bool bb = true;
	    for(i=0;i<n;i++){
	    	if(cnt[s[i][0]]==0&&cnt[s[i][1]]==0){
	    		bb=false;
	    		break;
	    	}
	    	if(cnt[s[i][0]]>cnt[s[i][1]]){
	    		cnt[s[i][0]]--;
	    		cnt[s[i][1]]++;
	    		ans[i] = s[i][1];
	    	}
	    	else{
	    		cnt[s[i][0]]++;
	    		cnt[s[i][1]]--;
	    		ans[i]=s[i][0];
	    	}
	    }
	    if(!bb){
	    	cout<<"No"<<endl;
	    	return 0;
	    }
	    cout<<"Yes"<<endl;
	    for(i=0;i<n;i++){
	    	cout<<ans[i]<<endl;
	    }
    }
    else if(s[0]=="AB"&&a==0&&b==0){
    	cout<<"No"<<endl;
    	return 0;
    }
    else if(s[0]=="BC"&&c==0&&b==0){
    	cout<<"No"<<endl;
    	return 0;
    }
    else if(s[0]=="AC"&&c==0&&a==0){
    	cout<<"No"<<endl;
    	return 0;
    }
    else{
    	cout<<"Yes"<<endl;
    	int nn=n;
    	n--;
    	int i=1;
    	while(n--){
	    	cin>>s[i];
	    	i++;
	    }
	    n=nn;
	    for(i=0;i<n;i++){
	    	if(cnt['A']+cnt['B']+cnt['C']==2&&cnt[s[i][0]]==1&&cnt[s[i][1]]==1&&i<n-1&&s[i+1]!=s[i]){
	    		if((s[i][0]==s[i+1][0])||(s[i][0]==s[i+1][1])){
	    			cnt[s[i][0]]++;
	    			cnt[s[i][1]]--;
	    			ans[i]=s[i][0];
	    		}
	    		if((s[i][1]==s[i+1][0])||(s[i][1]==s[i+1][1])){
	    			cnt[s[i][1]]++;
	    			cnt[s[i][0]]--;
	    			ans[i]=s[i][1];
	    		}
	    		continue;
	    	}
	    	if(cnt[s[i][0]]>cnt[s[i][1]]){
	    		cnt[s[i][0]]--;
	    		cnt[s[i][1]]++;
	    		ans[i] = s[i][1];
	    	}
	    	else{
	    		cnt[s[i][0]]++;
	    		cnt[s[i][1]]--;
	    		ans[i]=s[i][0];
	    	}
	    }
	    for(i=0;i<n;i++){
	    	cout<<ans[i]<<endl;
	    }
    }
}

Measured memory_bytes: 9992
n,k = map(int, input().split())
xl = list(map(int, input().split())) 

xlm = []
xlp = []
for x in xl:
    if x < 0: xlm.append(x*(-1))
    elif x == 0: k-=1
    else: xlp.append(x)

xlm.sort()
ans = 10**9
for i in range(min(k,len(xlm))+1):
    if i == 0: lv = 0
    else: lv = xlm[i-1]
    
    rem = k-i
    if rem > len(xlp): continue
    if rem == 0: rv = 0
    else: rv = xlp[rem-1]
    v = lv*2+rv
    ans = min(ans,v)

for i in range(min(k,len(xlp))+1):
    if i == 0: rv = 0
    else: rv = xlp[i-1]
    
    rem = k-i
    if rem > len(xlm): continue
    if rem == 0: lv = 0
    else: lv = xlm[rem-1]
    v = lv+rv*2
    ans = min(ans,v)

print(ans)

Measured memory_bytes: 90580
#include<iostream>
int GCD(long long int x,long long int y){
	while(x%y!=0){
		long long int z=x%y;
		x=y;
		y=z;
	}
	return y;
}
int main(){
	long long int a=0,b=0;
	while(std::cin>>a>>b){
		int c=GCD(a,b);
		long long int d=a*b/c;
		std::cout<<c<<" "<<d<<std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
a, b, c, d, e, f = map(int, input().split())
W = set(); S = set()
sa = 0; wsa = a * 100
for i in range(0, f + a * 100, a * 100):
    for j in range(0, f + b * 100, b * 100):
        w = i + j
        if w <= f:
            W.add(w)
        else:
            break
for i in range(0, f // 2 + c, c):
    for j in range(0, f // 2 + d, d):
        s = i + j
        if s <= f // 2:
            S.add(s)
        else:
            break
S.remove(0)
for i in W:
    for j in S:
        if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:
            sa, wsa = j, i + j
print(wsa, sa)

Measured memory_bytes: 9152
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (N == -1)break;
		int num;
		if (N <= 10)num = 1150;
		else if (N <= 20)num = 1150 + (N - 10) * 125;
		else if (N <= 30)num = 1150 + 1250 + (N - 20) * 140;
		else num = 1150 + 1250 + 1400 + (N - 30) * 160;
		cout << 4280- num << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<map>

/*
素因数分解をする
自然数xは素因数を持てばそれは\sqrt{x}以下なのでそこまで調べ上げれば良い
*/

typedef long long ll;
const ll mod = 1e9 + 7;

ll decompositPrime(int x){
    std::map<int, int> mp;
    for(int i = 2; i <= x; i++){
        int j = i;
        int a = 2;
        while(j >= a * a){
            if(j % a == 0){
                j /= a;
                mp[a]++;
            }else{
                a++;
            }
        }
        // 最後に残ったjは素因数
        mp[j]++;
    }
    // メイン処理はここ↑
    // ここからは問題に応じて
    // 今回はxの正の約数の個数を求める
    ll sum = 1;
    for(auto iter = mp.begin(); iter != mp.end(); iter++){
        sum = sum * (iter->second + 1) % mod;
    }

    return sum;
}

int main(){
    int N;
    scanf("%d%*c", &N);
    std::cout << decompositPrime(N) << std::endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1) return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  // グループの数
  ll root_num()
  {
    ll num = 0;
    for(ll x : p) num += (x < 0);
    return num;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  UnionFind uf(n);
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }

  cout << uf.root_num() - 1;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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



int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k, x, y; cin >> n >> k >> x >> y;
	int ans = min(n, k) * x;
	n -= min(n, k);
	ans += n * y;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int n;
  cin >> n;
  bool ok12 = false;
  bool ok34 = false;
  if (n%100 <= 12 && n%100 >= 1) ok12 = true;
  if (n/100 <= 12 && n/100 >= 1) ok34 = true;
  if (ok12 && ok34) cout << "AMBIGUOUS" << endl;
  if (!ok12 && ok34) cout << "MMYY" << endl;
  if (ok12 && !ok34) cout << "YYMM" << endl;
  if (!ok12 && !ok34) cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[101];int j;
int main(){
	cin>>a;
	int l=strlen(a);
	for (int i=0;i<=l;i++){if (j==1&&a[i]=='F'){printf("Yes");return 0;}if (j==0&&a[i]=='C') j=1;}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
function move(y,x,str){
   if(yx[tank[0]+y][tank[1]+x]=="."){
      yx[tank[0]+y][tank[1]+x]=str;
      yx[tank[0]][tank[1]]=".";
      tank[0]+=y;
      tank[1]+=x;
   }else{
     yx[tank[0]][tank[1]]=str;
   }
}
function shot(y,x){
   var i=0;
   while(true){
      i++;
      if(yx[tank[0]+(y*i)][tank[1]+(x*i)]=="#")break;
      else if(yx[tank[0]+(y*i)][tank[1]+(x*i)]=="*"){yx[tank[0]+(y*i)][tank[1]+(x*i)]=".";break;}
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input.replace(/\^/g,"U").replace(/v/g,"D").replace(/\</g,"L").replace(/\>/g,"R");
var arr=input.trim().split("\n");
var t=arr.shift()-0;
for(var i=0;i<t;i++){
   if(i!=0)console.log("");
   var hw=arr.shift().split(" ").map(Number);
   var yx=[];
   yx.push("####################".split(""));
   var tank=[0,0];
   for(var j=0;j<hw[0];j++){
      var ary=arr.shift().split("");
      var w=-1;
      ary.forEach(function(v,index){
         if(v=="U" || v=="D" || v=="L" || v=="R")w=index;
      });
      if(w!=-1)tank=[j+1,w+1];
      ary.unshift("#");
      ary.push("#");
      yx.push(ary);
   }
   yx.push("####################".split(""));
   arr.shift();
   var n=arr.shift().split("");
   n.forEach(function(v){
      if(v=="U")move(-1,0,v);
      else if(v=="D")move(1,0,v);
      else if(v=="L")move(0,-1,v);
      else if(v=="R")move(0,1,v);
      else if(v=="S"){
         var udlr=yx[tank[0]][tank[1]];
         if(udlr=="U")shot(-1,0);
         else if(udlr=="D")shot(1,0);
         else if(udlr=="L")shot(0,-1);
         else if(udlr=="R")shot(0,1);
      }
   });
   yx.shift();
   yx.pop();
   var ans=yx.join("\n").replace(/\,/g,"").replace(/^#|#$/mg,"");
   console.log(ans.replace(/U/g,"^").replace(/D/g,"v").replace(/L/g,"<").replace(/R/g,">"));
}

Measured memory_bytes: 17808
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<int> A,B;
int n;
int main(){
//	fastio;
	cin>>n;
	rb(i,1,n)
	{
		int a,b;
		cin>>a>>b;
		A.PB(a);
		B.PB(b);
	}
	sort(ALL(A));
	sort(ALL(B));
	if(n&1){
		cout<<B[n/2]-A[n/2]+1<<endl;
	}
	else{
		double l,r;
		l=A[n/2-1]+A[n/2];
		r=B[n/2-1]+B[n/2];
		l/=2.0;
		r/=2.0;
		r-=l;
		r*=2.0;
		r++;
		printf("%lld\n",(LL)r);
	}
	return 0;
}
/*
2
1000000000
1000000000
1000000000
1000000000
*/

Measured memory_bytes: 4992
from collections import Counter
n,*a=map(int,open(0).read().split())
b=[i for i in Counter(a).items() if i[1]>1]
b.sort()
c=[0]
for i in b[::-1]:
    if i[1]>=4:
        c.append(i[0]**2)
if len(b)>=2:
    c.append(b[-1][0]*b[-2][0])
print(max(c))

Measured memory_bytes: 18528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char c = s.charAt(0);
		if (c == 'a' || c == 'i' || c == 'u' ||c == 'e' ||c == 'o') {			
			System.out.println("vowel");
		}
		else
		System.out.println("consonant");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
using namespace std;
int main() {
int a, b, h, m, x ;
double y,z;
cin >> a >> b >> h >> m;
x = 60 * h + m;
y = (11.0 / 360.0) * PI * x;
z = sqrt(a*a+b*b-2*a*b * cos(y));
cout << fixed << setprecision(15) << z << endl;
return (0);
}

Measured memory_bytes: 4228
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res*=a;
        a*=a;
        x>>=1;
    }
    return res;
}

int popcount(int x){
    int res=0;
    while(x>0){
        if(x&1) res++;
        x>>=1;
    }
    return res;
}

ll f(ll x){
    ll res=0;
    while(x>0){
        res+=x%10;
        x/=10;
    }
    return res;
}

int main(){
    int H,W,N;cin>>H>>W>>N;
    int sr,sc;cin>>sr>>sc;
  sr--;sc--;
    string S,T;cin>>S>>T;
    for(int t=0;t<2;t++){
        int X=(t==0?H:W);
        int st=(t==0?sr:sc);
        int mn=0,mx=X-1;
        char add=(t==0?'D':'R');
        char sub=(t==0?'U':'L');
        for(int i=N-1;i>=0;i--){
            if(T[i]==add) mn=max(0,mn-1);
            else if(T[i]==sub) mx=min(X-1,mx+1);
            if(S[i]==add) mx--;
            else if(S[i]==sub) mn++;
            if(mn<0||mx>=X||mn>mx){
                cout<<"NO"<<endl;
                return 0;
            }
        }
        if(mn>st||st>mx){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 3920
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt(), m = fs.nextInt();
		ArrayList<Integer>[] adj = new ArrayList[n];
		for(int i = 0; i < n; i++) adj[i] = new ArrayList<>();
		for(int i = 0; i < m; i++) {
			int u = fs.nextInt()-1, v = fs.nextInt()-1;
			adj[u].add(v);
		}
		int s = fs.nextInt()-1, t = fs.nextInt()-1;
		int[][] dist = new int[3][n];
		for(int[] a : dist) Arrays.fill(a, -1);
		dist[0][s] = 0;
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		dq.add(0); dq.add(s);
		while(!dq.isEmpty()) {
			int j = dq.poll();
			int u = dq.poll();
			for(int v : adj[u]) {
				int j2 = (j+1); if(j2 >= 3) j2 -= 3;
				if(dist[j2][v] == -1) {
					dist[j2][v] = (j2 == 0 ? 1 : 0)+dist[j][u];
					dq.add(j2); dq.add(v);
				}
			}
		}
		out.println(dist[0][t]);
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

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

int n;

bool isOK_a(int index, int b, vector<int> &vec){
  return vec[index]<b;
}
ll nibutan_a(int b, vector<int> &vec){
  int ok=-1, ng=n;
  while(ng-ok>1){
    int mid=(ok+ng)/2;
    if(isOK_a(mid,b,vec)) ok=mid;
    else ng=mid;
  }
  return (ll)ng;
}

bool isOK_c(int index, int b, vector<int> &vec){
  return vec[index]>b;
}
ll nibutan_c(int b, vector<int> &vec){
  int ng=-1, ok=n;
  while(ok-ng>1){
    int mid=(ok+ng)/2;
    if(isOK_c(mid,b,vec)) ok=mid;
    else ng=mid;
  }
  return (ll)n-ok;
}

int main(){
  cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll ans=0;
  rep(i,n){
    ans+=nibutan_a(b[i],a)*nibutan_c(b[i],c);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4580
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

struct card {
    char suit;
    int value;
};

void bubbleSort(card A[], const int N)
{
    int flag = 1;

    for( int i = 0; flag; ++i ){
        flag = 0;

        for( int j = N-1; i < j; --j )
            if( A[j].value < A[j-1].value ){
                swap(A[j], A[j-1]);
                flag = 1;
            }
    }
}

void selectionSort(card A[], const int N)
{
    for( int i = 0; i < N; ++i ){
        int min = i;
      
        //iより後でA[i]より最も小さい値の添字を求める
        for( int j = i; j < N; ++j )
            if( A[j].value < A[min].value )
                min = j;
       
        //iとminが異なれば交換
        if( i != min ) swap(A[i], A[min]);
    }
}

int main()
{
    //入力
    int N;
    scanf("%d%*c", &N);
    card A[N], B[N]; //A:bubbleSort, B:selectionSort
    for( int i = 0; i < N; ++i ){
        scanf("%c%d%*c", &A[i].suit, &A[i].value);
        B[i] = A[i];
    }


    bubbleSort(A, N);
    selectionSort(B, N);


    //バブルソートの結果を出力
    for( int i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%c%d", A[i].suit, A[i].value);
    }
    printf("\n");
    printf("Stable\n");

    //選択ソートの結果を出力
    int flag = 1;
    for( int i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%c%d", B[i].suit, B[i].value);
        if( !(B[i].suit == A[i].suit && B[i].value == A[i].value) ) flag = 0;
    }
    printf("\n");
    if( flag ) printf("Stable\n");
    else printf("Not stable\n");

    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int M;
  while (cin >> M) {
    ll D = 0, S = 0;
    for (int i = 0; i < M; i++) {
      int d;
      ll c;
      cin >> d >> c;
      D += c;
      S += c * d;
    }
    ll res = D - 1 + (S - 1) / 9;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<ll> a,b;
  vector<ll> mi,ov;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    a.push_back(p);
  }
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    b.push_back(p);
  }
  ll msum=0,osum=0;
  for(int i=0;i<n;i++){
    if(a[i]-b[i]<0){
      mi.push_back(b[i]-a[i]);
      msum+=b[i]-a[i];
    }
    else if(a[i]-b[i]>0){
      ov.push_back(a[i]-b[i]);
      osum+=a[i]-b[i];
    }
  }
  //cout<<msum<<" "<<osum<<endl;
  if(msum>osum){
    cout<<-1<<endl;
    return 0;
  }
  sort(ov.begin(),ov.end());
  int ans=mi.size(),pos=ov.size()-1;
  while(msum>0){
    msum-=ov[pos];
    pos--;
    ans++;
  }
  cout<<ans<<endl;
}


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

int main() {
    int K, S;
    cin >> K >> S;

    int ans = 0;

    rep (x, K+1) {
        rep (y, K+1) {
            int z = S - x - y;
            if (z <= K && z >= 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define ll long long 
#define N 200005
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define piii pair<int, pii>
#define print(x) cout << #x << "=" << x << "\t";
#define endl "\n"
#define newline cout << endl;

int n;
int h[N];
int b[N];
ll tree[4 * N];

void update(int idx, int lup, int rup, ll val, int l, int r) {
    if (lup <= l && r <= rup) {
        tree[idx] = max(tree[idx], val);
        return;
    }
    if (lup > r || l > rup)
        return;
    int mid = (l + r) / 2;
    update(2 * idx, lup, rup, val, l, mid);
    update(2 * idx + 1, lup, rup, val, mid + 1, r);
    tree[idx] = max(tree[2 * idx], tree[2 * idx + 1]);
}

ll query(int idx, int lup, int rup, int l, int r) {
    if (lup <= l && r <= rup)
        return tree[idx];
    if (lup > r || l > rup)
        return 0;
    int mid = (l + r) / 2;
    return max(query(2 * idx, lup, rup, l, mid), query(2 * idx + 1, lup, rup, mid + 1, r));
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); 
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> h[i];
    for(int i=1;i<=n;i++)
        cin >> b[i];

    for(int i=1;i<=n;i++) {
        if (h[i] == 1)
            update(1, 1, 1, b[i], 1, n);
        else {
            ll beauty = query(1, 1, h[i] - 1, 1, n);
            update(1, h[i], h[i], beauty + b[i], 1, n);
        }
    }

    cout << tree[1];
    return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,j,k=0;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>j;
        if(j>=m)
        {
            k++;
        }
    }
    printf("%d",k);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	static Set<Long> divideSet = new TreeSet<Long>();

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();

		// 最大公約数を求める
		long gcd = GCD(A, B);
		calcDivide(gcd);

		System.out.println(divideSet.size());
	}

	// 最大公約数を求める
	public static long GCD(long a, long b) {
		if (b == 0) {
			return a;
		} else {
			return GCD(b, a % b);
		}
	}

	// 約数を求める
	public static void calcDivide(long num) {
		// 初期化
		divideSet.add(1l);

		for (long i = 2; i < Math.sqrt(num); i++) {
			while (num % i == 0) {
				divideSet.add(i);
				num /= i;
			}
		}
		if (num != 1) {
			divideSet.add(num);
		}
	}
}


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

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

    if(n%2==0){
        for(int i=n-1;i>=0;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=0;i<n;i+=2){
            cout<<a[i]<<" ";
        }
    }

    else {
        for(int i=n-1;i>=0;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=1;i<n;i+=2){
            cout<<a[i]<<" ";
        }
    }

}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    string s;
    cin>>s;
    int c[26] = {0};
    for(char ch : s)
    {
        ++c[ch - 'a'];
    }

    int f = 1;
    loop(i,0,26) if(c[i] & 1) {f = 0; break;}

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

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<ll>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define alll(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) ll a; cin >> a
#define rrd rdd(a); rep(i, a)
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it << endl; } }

int main() {
    int a;
    while(cin>>a){
        if (a==0) {
            return 0;
        }
        vector<string> v(a);
        rep(i, a){
            cin>>v[i];
        }
        int ml =0;
        rep(i, a){
            string s;
            
            ml=max(ml,int(v[i].size()));
            rep(j, v[i].size()){
                if (j==0) {
                    s.push_back(v[i][j]);
                }else if(v[i][j-1]=='a'||v[i][j-1]=='i'||v[i][j-1]=='u'||v[i][j-1]=='e'||v[i][j-1]=='o'){
                    s.push_back(v[i][j]);
                }
            }
            v[i]=s;
        }
        int flag =0;
        rep(i, ml){
            unordered_set<string> ss;
            rep(j, a){
                string s;
                rep(k, min(int(i+1),int(v[j].size()))) s.push_back(v[j][k]);
                ss.insert(s);
            }
            if (ss.size()==a) {
                pr(i+1);
                flag =1;
                break;
            }
        }
        if (flag==0) {
            pr("-1");
        }
    }
    return 0;
}

Measured memory_bytes: 3148
import sys

def landsearch(i,j):
    result=[]
    if i>0:
        if j>0:
            for x in range(-1,2):
                for y in range(-1,2):
                    try:
                        if (not (x==0 and y==0)) and atlas[i+x][j+y][0]==1:
                            result.append([i+x,j+y])
                    except:
                        pass
        else:
            for x in range(-1,2):
                for y in range(2):
                    try:
                        if (not (x==0 and y==0)) and atlas[i+x][j+y][0]==1:
                            result.append([i+x,j+y])
                    except:
                        pass
    elif j>0:
        for x in range(2):
            for y in range(-1,2):
                try:
                    if (not (x==0 and y==0)) and atlas[i+x][j+y][0]==1:
                        result.append([i+x,j+y])
                except:
                    pass
    else:
        for x in range(2):
            for y in range(2):
                try:
                    if (not (x==0 and y==0)) and atlas[i+x][j+y][0]==1:
                        result.append([i+x,j+y])
                except:
                    pass
    return result           


while True:
    w,h=[int(i) for i in input().split(" ")]
    if w==0 and h==0:
        sys.exit()


    atlas=[]
    for i in range(h):
        atlas.append([[int(j),0] for j in input().split(" ")])


    how_many_island=0
    for i in range(h):
        for j in range(w):
            if atlas[i][j][0]==1 and atlas[i][j][1]==0:
                how_many_island+=1
                dis_list=[[i,j]]
                while len(dis_list)!=0:
                    dis_list_cash=[]
                    for k in dis_list:
                        land=landsearch(k[0],k[1])
                        for l in land:
                            if atlas[l[0]][l[1]][1]==0:
                                atlas[l[0]][l[1]][1]=1
                                dis_list_cash.append([l[0],l[1]])
                    dis_list=dis_list_cash

    print(how_many_island)
                               

Measured memory_bytes: 7812
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(n):
        t += (a[i] - 1)
    print(t)


if __name__ == '__main__':
    slove()


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

using namespace std;


#define int long long
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)


using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;


signed main() {
    int n;
    cin >> n;

    bitset<64> mask[n];
    for (int i = 0; i < n; i++) {
        int k, b;
        cin >> k;
        while (k--) {
            cin >> b;
            mask[i].set(b);
        }
    }

    bitset<64> bs;
    int q, op, m;

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> op >> m;
        if (op == 0) cout << bs[m] << endl;
        if (op == 1) bs |= mask[m];
        if (op == 2) bs &= ~mask[m];
        if (op == 3) bs ^= mask[m];
        if (op == 4) cout << ((bs & mask[m]) == mask[m]) << endl;
        if (op == 5) cout << (bs & mask[m]).any() << endl;
        if (op == 6) cout << (bs & mask[m]).none() << endl;
        if (op == 7) cout << (bs & mask[m]).count() << endl;
        if (op == 8) cout << (bs & mask[m]).to_ullong() << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
	int N, K;
	int B[1001];
	int S;
	int i, j;
	
	while (1){
		scanf("%d%d", &N, &K);
		if (N == 0 && K == 0){
			break;
		}
		
		for (i = 0; i < K; i++){
			scanf("%d", &B[i]);
		}

		for (i = 0; i < N; i++){
			for (j = 0; j < K; j++){
				scanf("%d", &S);
				B[j] -= S;
			}
		}
		
		for (i = 0; i < K; i++){
			if (B[i] < 0){
				break;
			}
		}
		if (i == K){
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	return (0);
}

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

int main(){
  long long H,W; cin >> H >> W;
  
  long long sdiff;
  //=型、||型
  if(H%3==0||W%3==0){
    sdiff=0;
  }else{
    sdiff=min(H,W);
    //ト型
    if(H%2==0){
      for(int i=1; i<W; i++){
        sdiff=min(sdiff,abs(H*(W-i)-i*H/2));
      }
    }else{
      for(int i=1; i<W; i++){
        sdiff=min(sdiff,max({H*(W-i),i*(H+1)/2,i*(H-1)/2})-min({H*(W-i),i*(H+1)/2,i*(H-1)/2}));
      }
    }
    //T型
    if(W%2==0){
      for(int i=1; i<H; i++){
        sdiff=min(sdiff,abs(W*(H-i)-i*W/2));
      }
    }else{
      for(int i=1; i<H; i++){
        sdiff=min(sdiff,max({W*(H-i),i*(W+1)/2,i*(W-1)/2})-min({W*(H-i),i*(W+1)/2,i*(W-1)/2}));
      }
    }
  }
  cout << sdiff << endl;
}

Measured memory_bytes: 256