akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main(void) {
  int A, B, C, K;
  scanf("%d%d%d%d", &A, &B, &C, &K);
  if (A > B) {
    if (A > C) {
      printf("%d\n", (int)(A*pow(2, K)) + B + C);
    } else {
      printf("%d\n", (int)(C*pow(2, K)) + B + A);
    }
  } else {
    if (B > C) {
      printf("%d\n", (int)(B*pow(2, K)) + C + A);
    } else {
      printf("%d\n", (int)(C*pow(2, K)) + B + A);
    }
  }

  return 0;
}

Measured memory_bytes: 128
abm=(input().split(" "))
al1=list(map(int,input().split(" ")))
bl1=list(map(int,input().split(" ")))
#print(al1)
#print(bl1)
minp=min(al1)+min(bl1)


for n in range(0,int(abm[2])):
    a,b,c = map(int,input().split())
    ci=int(al1[a-1])+int(bl1[b-1])-int(c)
    if minp>ci:
        minp=ci

print(minp)

Measured memory_bytes: 18612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int sum(int n)
{
    int cnt = 0;
    while(n)
    {
        cnt += n % 10;
        n /= 10;
    }
    return cnt;
}
int main()
{
    ll n, a, b, cnt = 0;
    cin >> n >> a >> b;
    for(ll i = 1; i <= n; i ++)
    {
        if(sum(i) >= a and sum(i) <= b)
        {
            cnt += i;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
hhh = list(map(int, input().split()))
init_val = 0

dp = [init_val] * N
dp[0] = 0

for i, h in enumerate(hhh):
    s = 0 if i < K else i-K
    if i == 0:
        continue
    dp[i] = \
        min([abs(h - h_k) + dp_k for h_k, dp_k in zip(hhh[s:i], dp[s:i])])

print(dp[-1])


Measured memory_bytes: 13976
#include<iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin >>x >>y;
        if (x == 0 && y == 0)break;
        if (x <= y){
             cout << x <<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std ;
using ll=long long ;
int main(){
 int x,y;
    cin>>x>>y;
    if(y>4*x || y<2*x)
    {
        cout<<"No";
         return 0 ;
    }
    if (y%2 !=0)
    {
        cout<<"No";
 return 0 ;}
 cout << "Yes" ;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){int a;cin>>a;ans+=a-1;}
  cout<<ans<<endl;
}

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

using namespace std;

const int N=1e7+5;

int n,k,jc[N],inv[N];

const int mod=1e9+7;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

inline int ksm(int x,int y)
{
	int ret=1ll;
	while(y)
	{
		if(y&1) ret=ret*x%mod;
		x=x*x%mod;
		y>>=1ll;
	}
	return ret;
}

inline int C(int x,int y)
{
	if (y>x) return 0;
	return jc[x]%mod*inv[y]%mod*inv[x-y]%mod;
}

signed main() 
{
    n=read();
    k=read();
    jc[0]=inv[0]=1;
    for ( int i=1;i<=n;i++ ) jc[i]=jc[i-1]*i%mod;
    for ( int i=1;i<=n;i++ ) inv[i]=ksm(jc[i],mod-2)%mod;
    for ( int i=1;i<=k;i++ ) 
    	printf("%lld\n",(C(n-k+1,i)%mod*C(k-1,i-1)%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	long long int m=1000,st=0;
	for(int i=0;i<n;i++){
		if((i<n-1)&&a[i+1]<=a[i]){
			m+=st*a[i];
			st=0;
		}
		if((i<n-1)&&a[i+1]>a[i]){
			st+=m/a[i];
			m-=(m/a[i])*a[i];
		}
		if(i==n-1){
			m+=st*a[i];
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main() {
	string ans;
	vector<string> v;
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> ans;
		v.push_back(ans);
	}
	ans = "";
	sort(v.begin(),v.end());
	for (auto i : v) {
		cout << i;
	}
	cout << endl;
}

Measured memory_bytes: 256
// #define __LOCAL_DEBUG__
#include<bits/stdc++.h>
using namespace std;
#ifdef __LOCAL_DEBUG__
# define _debug(x) { cerr << "\033[94m" << __func__ << " " << #x << ": " << (x) << "\n\033[0m"; }
#else
# define _debug(x) {((void) 0);}
#endif
#define REP(i, n) for (int i = (0); i < (n); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define EACH(x, arr) for (auto& x : arr) 
#define ITR(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define CLR(x, v) memset(x, v, sizeof (x))
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
using ll = signed long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 700;

int n;
int lb(int x) { return x & -x; }
void go(int mask, int a, int b) {
    if ((mask & (mask - 1)) == 0) { // only one bit in mask
        cout << a << " " << b << " ";
        return;
    }
    int c = lb(a ^ b);
    int d = lb(c ^ mask);
    go(mask ^ c, a, a ^ d);
    go(mask ^ c, a ^ d ^ c, b);
}
void MAIN() {
    int a, b;
    cin >> n >> a >> b;
    if ((__builtin_popcount(a ^ b) & 1) == 0) cout << "NO" << endl;
    else {
        cout << "YES" << endl;
        go((1 << n) - 1, a, b);
    }
} 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int TC = 1;
    // cin >> TC;
    REP(tc, TC) {
    // while (cin >> n, n) {
        // cout << "Case " << tc + 1 << ": ";
        MAIN();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    int res = 0;
    for (int i=0;i<N-2;i++){
        if (S.substr(i,3)=="ABC") res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int A[100][100];
    int B[100];
    int m, n, i, j, Product;
    Product=0;
    scanf("%d%d", &n, &m);
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            scanf("%d", &A[i][j]);
        }
    }
    for (i=0; i<m; i++)
    {
        scanf("%d", &B[i]);
    }
    for (i=0; i<n; i++)
    {
        for (j=0; j<m; j++)
        {
            Product+=A[i][j]*B[j];
        }
        printf("%d\n", Product);
        Product=0;
    }
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, c, k;
	cin >> n >> c >> k;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vint table(n, 0);
	rep(i, n) {
		if (table[i] == 0) {
			rep(j, c) {
				if (i + j >= n) {
					break;
				}
				if (a[i] + k < a[i + j]) {
					break;
				}
				if (i == 0) {
					table[j] = 1;
					continue;
				}
				table[i + j] = table[i - 1] + 1;
			}
		}
		else {
			rep(j, c + 1) {
				if (i + j >= n) {
					break;
				}
				if (a[i] + k < a[i + j]) {
					break;
				}
				table[i + j] = min(table[i] + 1, table[i + j]);
			}
		}
	}
	cout << table[n - 1] << endl;
	return 0;
}


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

using namespace std;
constexpr long long int mod = 1000000007;


//M*X+R=Y

int main() {
	int N;
	map<string, int>U;
	cin >> N;
	string S;
	int ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> S;
		if (U[S] == 0)ans++;
		U[S] = 1;
	}
	cout << ans;
}

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

int main(){
	int n; cin>>n;
	ll cnt=0;
	for(int i=1; i<n; i++){
		for(int j=1; j<n; j++){
			if(i*j<n) cnt++;
			else break;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100010,mod=998244353;
char s[N*3];
int n,ans=1,r,g,b,rg,rb,gb;
int main(){
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n*3;i++){
		if(s[i]=='R'){
			if(gb){
				ans=1ll*ans*gb%mod;
				gb--;
			}
			else if(g){
				ans=1ll*ans*g%mod;
				g--,rg++;
			}
			else if(b){
				ans=1ll*ans*b%mod;
				b--,rb++;
			}
			else r++;
		}
		else if(s[i]=='G'){
			if(rb){
				ans=1ll*ans*rb%mod;
				rb--;
			}
			else if(r){
				ans=1ll*ans*r%mod;
				r--,rg++;
			}
			else if(b){
				ans=1ll*ans*b%mod;
				b--,gb++;
			}
			else g++;
		}
		else{
			if(rg){
				ans=1ll*ans*rg%mod;
				rg--;
			}
			else if(r){
				ans=1ll*ans*r%mod;
				r--,rb++;
			}
			else if(g){
				ans=1ll*ans*g%mod;
				g--,gb++;
			}
			else b++;
		}
	}
	for(int i=1;i<=n;i++)
		ans=1ll*ans*i%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
long long n,a,b,c,rd,rem;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>a>>b;
	c=a+b;
	rd=n/c;
	rem=n%c;
	cout<<(rd*a+min(rem,a))<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 1e5+1;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define FAILNO {printf("NO\n"); return 0;}
#define FAIL1 {printf("-1\n"); return 0;}

int N;
char S[MAXN];

int f(int k) {
	int r = 0;
	for (int i = 0; i < N; i++) {
		char c = '0' + k;
		if (c != S[i]) r++;
		k = 1-k;
	}

	return r;
}

int main() {
#ifdef OJ
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	scanf("%s", S);
	N = strlen(S);

	printf("%d\n", min(f(0),f(1)));

	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#define MA 100000
int main(){


  int n,i,j,A[MA],count=0;

  scanf("%d",&n);

  for(i = 0;i<n;i++)
    scanf("%d",&A[i]);
  for(j = 0;j<n;j++)
    for(i = 2;i*i <=A[j];i++)
      if(A[j] != i){
	if(A[j]%i == 0){
	  count++;
	  break;
	}
	
      }

  printf("%d\n",n-count);


  return 0;
}


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

#define F first
#define S second
#define int long long
#define inf 1000000000

using namespace std;

vector<int> lunlun;

int k;

void prnt(){
    cout << lunlun[k-1] << endl;
    exit(0);
}

void nxt(const int& len, const int& frst, int prv){
    prv = prv*10+frst;
    if (len == 1){
        lunlun.push_back(prv);
        if ((int)lunlun.size() == k){
            prnt();
        }
        return;
    }
    if (frst > 0){
        nxt(len-1, frst-1, prv);
    }
    nxt(len-1, frst, prv);
    if (frst < 9){
        nxt(len-1, frst+1, prv);
    }
}

signed main(){
    cin >> k;
    for (int ln = 1; ln < 11; ln++){
        for (int fr = 1; fr < 10; fr++){
            nxt(ln, fr, 0);
        }
    }
    //cout << (int)lunlun.size() << endl;
    return 0;
}























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

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, k;
    while (scanf("%d%d", &n, &k) == 2) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            a[i] -= k;
        }

        ordered_set<pair<ll, int> > st;
        st.insert({0, 0});
        ll csum = 0;
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            csum += a[i];
            // csum - x >= 0
            // x <= csum
            ans += st.order_of_key(make_pair(csum + 1, -1));
            st.insert({csum, i + 1});
        }
        cout << ans << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long int
using namespace std;


int main(){
 
 string s;cin>>s;
ll cntR=0;
ll cntB=0;

for(int i=0;i<s.size();i++){
  if(s[i]=='0'){
    cntR++;
  } else{
    cntB++;
  }
}

cout<<min(cntB,cntR)*2<<endl;

  return 0;
}
  

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        if (x < 1200)
        {
            Console.WriteLine("ABC");
        }
        else
        {
            Console.WriteLine("ARC");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll P(N);
  vll Q(N);

  rep(i, N) {
    cin >> P[i];
    Q[i] = i + 1;
  }

  ll count = 0;
  rep(i, N) {
    if (P[i] == Q[i]) {
      continue;
    } else {
      count++;
    }
  }

  if (count == 0 || count == 2) {
    COUT("YES");
  } else {
    COUT("NO");
  }

  return 0;
}

Measured memory_bytes: 256
/* You can't connect the dots looking forward 
   you can only connect them looking backwards. */

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
#define N 500007

int test;

int n,m;

VI g[N];

BIT czy;

void dfs(int v){
    czy[v]=1;

    for(auto it:g[v]){
        if (!czy[it]){
            dfs(it);
        }
    }

    return;
}

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

    FOR(i,1,m){
        int a,b;
        cin >> a >> b;
        

        if (a==1 || b==1 || a==n || b==n){
            g[a].pb(b);
            g[b].pb(a);
        }
    }

    dfs(1);

    cout << (czy[n] ? "POSSIBLE" : "IMPOSSIBLE");

    return;
}

int32_t main()
{
    boost

    test=1;

    while(test--)
    {
        solve();
    }

  return 0;
}


Measured memory_bytes: 19816
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n,m;;
    cin >> n >> m;
    int x[m];
    inrep(m,x);
    sort(x,x+m);
    int sa[m-1];
    rep(i,0,m-1)sa[i] = x[i+1]-x[i];
    rsort(sa,sa+m-1,int);

    
    ll ans = 0;
    rep(i,n-1,m-1)ans += sa[i];
    P(ans);
    
	return  0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long a, long long b, long long c){
	if (c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl; else cout << "No" << endl;
}

int main(){	
	long long c;
	long long b;
	long long a;
	scanf("%lld",&a);
	scanf("%lld",&b);
	scanf("%lld",&c);
	solve(a, b, c);
	return 0;
}



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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var A = input[0];
            var B = input[1];
            var ans = 0;
            if (A >= 6 && A <= 12) ans = B / 2;
            else if (A >= 13) ans = B;

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<char> st;
	rep(i, 3) {
		char a;
		cin >> a;
		st.insert(a);
	}
	if (st.size() == 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

pair <int, int> a[1005];
int memo[10005][1005];

int n;

int dp(int h, int pos) {
	if (h <= 0) return 0;
	if (pos == n) return INF;
	if (memo[h][pos] != -1) return memo[h][pos];
	return memo[h][pos] = min(dp(h-a[pos].x, pos)+a[pos].y, dp(h, pos+1));
}

int main() {
	memset(memo, -1, sizeof memo);
	int h;
	scanf("%d%d", &h, &n);
	for (int i=0 ; i<n ; i++) {
		scanf("%d%d", &a[i].x, &a[i].y);
	}
	printf("%d\n", dp(h, 0));
	return 0;
}

Measured memory_bytes: 40064
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

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

	int n;
	cin>>n;
	vector<int> a(n);
	int c=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==0){
			c++;
		}
	}
	cout<<(int)pow(3,double(n))-(int)pow(2,double(c))<<endl;
}

Measured memory_bytes: 256
/*//////////////////////////////////////*/
/*/  NULLCT$ (｀･ω･´) <<"Be accept!!"  /*/
/*//////////////////////////////////////*/
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <type_traits>
#include <cstdint>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;

return 0;
}


Measured memory_bytes: 256
#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000021;
const long long inf = 1LL << 61;
struct edge { int to, cost, id; };
struct edge2 { int to, id; };
struct state { int pos; long long cost; };
bool operator<(const state& s1, const state& s2) { return s1.cost > s2.cost; }
int N, M, dp[100009], dp2[100009], va[100009]; bool vis1[100009], vis2[100009]; vector<int> a, b, c;
vector<long long> shortest_path(vector<vector<edge> > g, int src) {
	vector<long long> ret(g.size(), inf); ret[src] = 0;
	priority_queue<state> que; que.push(state{ src, 0 });
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		for (edge e : g[u]) {
			long long nd = ret[u] + e.cost;
			if (ret[e.to] > nd) {
				ret[e.to] = nd;
				que.push(state{ e.to, nd });
			}
		}
	}
	return ret;
}
vector<int> solve() {
	vector<vector<edge> > g(N);
	vector<vector<edge> > rg(N);
	for (int i = 0; i < M; i++) {
		g[a[i]].push_back(edge{ b[i], c[i], i });
		rg[b[i]].push_back(edge{ a[i], c[i], i });
	}
	vector<long long> ds = shortest_path(g, 0);
	vector<long long> dt = shortest_path(rg, 1);
	vector<bool> ok(M);
	vector<vector<edge2> > sg(N), sr(N);
	for (int i = 0; i < M; i++) {
		if (ds[a[i]] + c[i] + dt[b[i]] == ds[1]) {
			sg[a[i]].push_back(edge2{ b[i], i });
			sr[b[i]].push_back(edge2{ a[i], i });
			ok[i] = true;
		}
	}
	fill(vis1, vis1 + N, false);
	fill(vis2, vis2 + N, false);
	fill(dp, dp + N, 0);
	fill(dp2, dp2 + N, 0);
	vector<int> dpm1(M), dpm2(M);
	priority_queue<state> que; que.push(state{ 0, 0 }); dp[0] = 1;
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		if (!vis1[u]) {
			vis1[u] = true;
			for (edge2 i : sg[u]) {
				dp[i.to] += dp[u];
				dpm1[i.id] = dp[u];
				if (dp[i.to] >= mod) dp[i.to] -= mod;
				que.push(state{ i.to, ds[i.to] });
			}
		}
	}
	que.push(state{ 1, 0 }); dp2[1] = 1;
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		if (!vis2[u]) {
			vis2[u] = true;
			for (edge2 i : sr[u]) {
				dp2[i.to] += dp2[u];
				dpm2[i.id] = dp2[u];
				if (dp2[i.to] >= mod) dp2[i.to] -= mod;
				que.push(state{ i.to, dt[i.to] });
			}
		}
	}
	for (int i = 0; i < N; i++) va[i] = 1LL * dp[i] * dp2[i] % mod;
	map<tuple<int, int, int>, int> cnts;
	for (int i = 0; i < M; i++) {
		cnts[make_tuple(a[i], b[i], c[i])]++;
	}
	vector<int> ret(M);
	for (int i = 0; i < M; i++) {
		if (!ok[i]) {
			ret[i] = (ds[b[i]] + dt[a[i]] + c[i] < ds[1] ? 2 : 1);
		}
		else {
			if (ds[b[i]] + dt[a[i]] + c[i] < ds[1]) ret[i] = 2;
			else if (ds[b[i]] + dt[a[i]] + c[i] == ds[1]) ret[i] = 1;
			else {
				if (1LL * dpm1[i] * dpm2[i] % mod == va[0] && cnts[make_tuple(a[i], b[i], c[i])] == 1) ret[i] = 0;
				else ret[i] = 1;
			}
		}
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	a = vector<int>(M);
	b = vector<int>(M);
	c = vector<int>(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--;
	}
	vector<int> ret = solve();
	for (int i = 0; i < M; i++) {
		if (ret[i] == 2) cout << "HAPPY\n";
		else if (ret[i] == 1) cout << "SOSO\n";
		else cout << "SAD\n";
	}
	return 0;
}

Measured memory_bytes: 36184
#include<stdio.h>
int main()
{
    int n,a[100000],i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0; i<n-1; i++)
        if(a[i]<=a[i+1])
        {
            if(a[i]<a[i+1])
                a[i+1]--;
        }
        else if(a[i]>a[i+1])
        {
            printf("No\n");
            return 0;
        }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

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

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n)

	ans1 := 0
	for i, sum, pos := 0, 0, true; i < n; i, pos = i+1, !pos {
		var d int
		if pos && (sum+a[i]) <= 0 {
			d = abs(1 - (sum + a[i]))
			ans1 += d
		} else if !pos && (sum+a[i]) >= 0 {
			d = -abs(-1 - (sum + a[i]))
			ans1 -= d
		}
		sum += a[i] + d
	}

	ans2 := 0
	for i, sum, pos := 0, 0, false; i < n; i, pos = i+1, !pos {
		var d int
		if pos && (sum+a[i]) <= 0 {
			d = abs(1 - (sum + a[i]))
			ans2 += d
		} else if !pos && (sum+a[i]) >= 0 {
			d = -abs(-1 - (sum + a[i]))
			ans2 -= d
		}
		sum += a[i] + d
	}

	puts(min(ans1, ans2))
}


Measured memory_bytes: 3072
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next();
		
		// 計算
		int result = 0;
		int l = 0;
		int r = s.length()-1;
		while(l < r){
		    while(l < r && s.charAt(l) == 'R'){
		        l++;
		    }
		    while(l < r && s.charAt(r) == 'W'){
		        r--;
		    }
		    if(l < r){
		        result++;
		        l++;
		        r--;
		    }
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

using namespace std;


int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

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

	sort(a.rbegin(), a.rend());

	long long res = 0;
	res += a[0];
	int cur = 1;
	int cnt = 0;
	for(int i = 2; i < n; ++i){
		if(cnt == 0){
			res += a[cur];
			cnt++;
		}else if(cnt == 1){
			res += a[cur];
			cnt = 0;
			cur++;
		}
	}

	cout << res << endl;

    return 0;
}


Measured memory_bytes: 4008
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n, d = list(map(int,input().split()))
    ans = 0
    for _ in range(n):
        x, y = list(map(int,input().split()))
        if x**2 + y**2 <= d**2:
            ans += 1
    print(ans)

    return 0

if __name__ == "__main__":
    main()

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

const int N=2e+5+50;
int n,k;
long long int a[N];

bool ispos(long long int x)
{
	long long int cans=0;
	for(int i=1;i<=n;i++)
		cans+=(a[i]-1)/x;
	return cans<=k;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	long long int l=1,r=1e+9;
	while(l<r)
	{
		int m=(l+r)/2;
		if(ispos(m))
			r=m;
		else
			l=m+1;
	}
	cout<<l;
}



Measured memory_bytes: 5060
s = input() #str
weather_circle = ("Sunny", "Cloudy", "Rainy") #天気の周期
def next_day_weather(s) :
    s_number = weather_circle.index(s)
    if s_number < 2 :
        s_number += 1
    else :
        s_number = 0
    print(weather_circle[s_number])
next_day_weather(s)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (int i = 0; i < n; i++)
int main()
{
	int H, N;
	int A[100000];
	cin >> H >> N;
	REP(i, N)
	{
		cin >> A[i];
	}
	REP(i, N)
	{
		H = H - A[i];
		if (H <= 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};

template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};

int main() 
{ 
    fast_io
    go();
    intt n;cin>>n;
    vi v(n);
    for0(i,n)
    {
      cin>>v[i];
    }
    intt money=1000,st=0;
    vi temp(n,0);
    

    for(int i=1;i<n;i++)
    {
      if(v[i]>v[i-1])
      {
        st+=(money/v[i-1]);
        money=(money%v[i-1]);

        money+=(st*v[i]);
        st=0;
      }
    }
    cout << money <<"\n";
} 











Measured memory_bytes: 3644
import math

A, B, H, M = map(int, input().split())
theta = M * math.pi / 30 - H * math.pi / 6 - M * math.pi / 360

C_2 = A ** 2 + B ** 2 - 2*A*B*math.cos(theta)
C = C_2 ** (1/2)
print(C)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
template<class tp>
tp F() {
	tp x = 0, ch = getchar(), f = 0;
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
template<class tp>
bool chkmax(tp &a, tp b) {
	return a < b ? a = b, 1 : 0;
}
template<class tp>
bool chkmin(tp &a, tp b) {
	return a > b ? a = b, 1 : 0;
}
inline void file_io(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
const int MAXN = 2e5 + 10;
int n;
ll a[MAXN], sum[MAXN], xorsum[MAXN];
ll (*rd)() = F<ll>;
int main() {
	n = rd(), sum[0] = xorsum[0] = a[0] = rd();
	for(reg int i = 1; i < n; ++i) a[i] = rd(), sum[i] = sum[i - 1] + a[i], xorsum[i] = xorsum[i - 1] ^ a[i];
	ll l = 0, ans = 0;
	for(reg int r = 0; r < n; ++r) {
		while((sum[r] - sum[l - 1]) != (xorsum[r] ^ xorsum[l - 1])) ++l;
		ans += r - l + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int examin_money(int *x, int *y, int *z, int N, int SUM) {
	for (int i = 0; i <= N; i++) {
		if (10000 * i > SUM) {
			break;
		}
		for (int j = 0; j <= N - i; j++) {
			if (10000 * i + 5000 * j > SUM) {
				break;
			}
			int total = 10000 * i + 5000 * j + 1000 * (N - i - j);
			if (total == SUM) {
				*x = i;
				*y = j;
				*z = N - i - j;
				return 0;
			}
		}
	}
	*x = *y = *z = -1;
	return 0;
}

int main(void) {
	int x, y, z, n, sum;
	scanf("%d %d", &n, &sum);
	examin_money(&x, &y, &z, n, sum);
	printf("%d %d %d\n", x, y, z);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

bool check(int a[], int b[], int p[], int n){
  for(int i = 0; i < n; i++){
    if(a[i] <= 0) return false;
  }
  for(int i = 0; i < n; i++){
    if(b[i] <= 0) return false;
  }
  for(int i = 0; i + 1 < n; i++){
    if(a[i] >= a[i + 1]) return false;
  }
  for(int i = n - 1; i - 1 >= 0; i--){
    if(b[i - 1] <= b[i]) return false;
  }
  for(int i = 0; i + 1 < n; i++){
    if(a[p[i]] + b[p[i]] >= a[p[i + 1]] + b[p[i + 1]])
      return false;
  }
  return true;
}

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

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

  int r[n];
  for(int i = 0; i < n; i++) r[p[i]] = i + 1;

  int m = 40000;
  int a[n], b[n];
  for(int i = 0; i < n; i++){
    a[i] = m * (i + 1);
    b[i] = m * (n - (i + 1)) + r[i];
  }

  string buf;
  for(int i = 0; i < n; i++){
    buf += to_string(a[i]);
    if(i != n - 1) buf += " ";
  }
  buf += "\n";
  for(int i = 0; i < n; i++){
    buf += to_string(b[i]);
    if(i != n - 1) buf += " ";
  }

  cout << buf << endl;

  //cout << check(a, b, p, n) << endl;

  return 0;
}


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

int main(){
  int i, len, h0, h1, h2, h3, in;
  char str[20];
  
  h0 = h1 = h2 = h3 = 0;

  scanf("%s", str);

  len = strlen(str);

  if(len >= 6) h0 = 1;

  for(i=0; i<len; i++){
    in = str[i];
    if(in >= 48 && in <=57) h1 = 1;
    else if(in <= 90 && in >=65) h2 = 1;
    else if(in >= 97 && in <=122) h3 = 1;
  }
  
  if(h0==1 && h1==1 && h2==1 && h3==1) printf("VALID\n");
  else printf("INVALID\n");

  return 0;
}

Measured memory_bytes: 524
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[fastout]

fn calc_score(d: usize, c: &Vec<i64>, s: &Vec<[i64; 27]>, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=d {
        let now_contest = t[day];
        res += s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= c[contest] * (day - last[contest]) as i64;
        }
        println!("{}", res);
    }
    res
}

fn main() {
    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
        _t: [usize; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let mut t = vec![0];
    t.extend(_t.iter());

    // process
    calc_score(d, &c, &s, &t);
}


Measured memory_bytes: 2372
import numpy as np

X = int(input())
#print(X)


def MaxPow(X):
    Max = 1

    if int(np.sqrt(X)) ==1:
        return Max
    
    for b in range(2,int(np.sqrt(X))+1):
        #print(np.log(X)/np.log(b))
        for p in range(2,int(np.log(X)/np.log(b))+2):
            tmp = b**p
            if tmp<=X:
                Max = max(Max,tmp)
    return Max

print(MaxPow(X))


# for i in range(1000):
#     print(MaxPow(i))




Measured memory_bytes: 21516
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

//--------------
//#define DEBUG
//--------------

#ifdef DEBUG
	#define debugprint(x) cout<<x<<" "
	#define debugendl cout<<endl
	#define debug(x) x
#else
	#define debugprint(x)
	#define debugendl
	#define debug(x)
#endif

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	zahyo operator*(int t){
		zahyo temp;
		temp.x=this->x*t;
		temp.y=this->y*t;
		return temp;
	}
	zahyo operator%(int t){
		zahyo temp(this->x%t,this->y%t);
		return temp;
	}
	zahyo operator/(int t){
		zahyo temp(this->x/t,this->y/t);
		return temp;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

zahyo ways[4];

bool IsInBoard(int x,int maxx, int y,int maxy){
	if(x>=0 and x<maxx and y>=0 and y<maxy){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	ways[0].x=1;
	ways[1].x=-1;
	ways[2].y=1;
	ways[3].y=-1;
	int h,w;
	int blackcount=0;
	int board[50][50]={};
	int arrived[50][50]={};
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char temp;
			cin>>temp;
			if(temp=='#'){
				board[i][j]=1;
				blackcount++;
			}
			else{
				board[i][j]=0;
			}
		}
	}
	zahyo start(0,0);
	zahyo goal(h-1,w-1);
	queue<zahyo> widesearch;
	widesearch.push(start);
	int counter=1;
	arrived[0][0]=1;
	bool unreach=true;
	while(widesearch.size()>0 and unreach){
		counter++;
		int size=widesearch.size();
		for(int i=0;i<size;i++){
			zahyo temp=widesearch.front();
			widesearch.pop();
			for(int j=0;j<4;j++){
				zahyo now=temp+ways[j];
				if(IsInBoard(now.x,h,now.y,w)){
					if(now==goal){
						unreach=false;
					}
					if(board[now.x][now.y]==0 and arrived[now.x][now.y]==0){
						arrived[now.x][now.y]=1;
						widesearch.push(now);
					}
				}
			}
		}
	}
	if(unreach){
		cout<<-1<<endl;
	}
	else{
		cout<<h*w-counter-blackcount<<endl;
	}
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main() 
{ 
   int A,B,m;
   scanf("%d%d",&A,&B);
   
   if (A>9 || B>9)
    {
    m=-1;
    printf("%d",m);
    }
    else{
    m=A*B;
    printf("%d",m);
     }
   
 return 0;
}

Measured memory_bytes: 128
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k :
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k]+abc[i][j])

print(max(dp[N][0], dp[N][1], dp[N][2]))


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

int main()
{
	int n;
	long sum =0;
	cin >> n;
	
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		sum += a;
	}
	
	cout << sum / n << endl;
	
	return (0);
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int h, w;
  cin>>h>>w;
  vvec<int> s(h,vec<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin>>c;
      if(c=='#'){
        s[i][j]=-2;
      }else{
        s[i][j]=-1;
      }
    }
  }
  int nyan=0;
  for (int h0 = 0; h0 < h; h0++) {
    for (int w0 = 0; w0 < w; w0++) {
      if (s[h0][w0]!=-2){
        vvec<int> s0 = s;
        queue<pair<int,int>> q0;
        s0[h0][w0]=0;
        q0.push(make_pair(h0,w0));
        int h1=h0, w1=w0;
        while(!q0.empty()){
          h1 = q0.front().first; w1 = q0.front().second;
 //         cout<<h1<<" "<<w1<<" "<<s0[h1][w1]<<endl;
          q0.pop();
          for (int h2: {h1-1, h1+1}){
            int w2 = w1;
            if(0<=h2&&h2<h && s0[h2][w2]==-1){
              s0[h2][w2] = s0[h1][w1] + 1;
              q0.push(make_pair(h2,w2));
            }
          }
          for (int w2: {w1-1, w1+1}){
            int h2 = h1;
            if(0<=w2&&w2<w && s0[h2][w2]==-1){
              s0[h2][w2] = s0[h1][w1] + 1;
              q0.push(make_pair(h2,w2));
            }
          }
        }
 //       cout<<h0<<" "<<w0<<" "<<h1<<" "<<w1<<endl<<s0[h1][w1]<<endl;
        nyan = max(nyan, s0[h1][w1]);
      }
    }
  }
  cout<<nyan;
}


/* きょむ〜 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
 
 
 
int main(){
	ll n;
    cin >> n;
    ll a[n] = {0};
    rep(i,1,n){
        ll x;
        cin >> x;
        a[x - 1]++;
    }
    rep(i,0,n){
        cout << a[i] << endl;
    }
    
    
}

Measured memory_bytes: 5192