akhauriyash/Code-Regression huggingface dataset:
#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>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int n,m,cnt;

main()
{
        cin>>n>>m;
        vector<pair<int,int>> p(n+10);
        p[0].second=1;
        for(auto &it : p)it.first=true;

        rep(i,m)
        {
                int t;
                cin>>t;
                p[t].first=false;
        }

        rep(i,n)
        {
                if(!p[i].first)continue;

                p[i+1].second=(p[i+1].second+p[i].second%mod)%mod;
                p[i+2].second=(p[i+2].second+p[i].second%mod)%mod;
        }

        //debug
        //for(auto it : p)printf("%d %d %d\n",cnt++,it.first,it.second);

        cout<<p[n].second<<endl;
}


Measured memory_bytes: 1024
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  string s;
  cin>>s;
  n=s.size();
  ll t=0;
  ll f=-1;
  vector<ll>v;
  for(ll i=0;i<n;i++){
    if(s[i]=='>'){
      if(f==0){
        t++;
      }
      else{
        if(f==1){
          v.push_back(t);
        }
        t=1;
        f=0;
      }
    }
    else{
      if(f==1){
        t++;
      }
      else{
        if(f==0){
          v.push_back(t);
        }
        t=1;
        f=1;
      }
    }
  }
  v.push_back(t);
  ll i=0;
  if(s[0]=='>'){
    ans+=v[0]*(v[0]+1)/2;
    i++;
  }
  for(;i+1<(ll)v.size();i+=2){
    ans+=(v[i]*(v[i]+1)/2)+(v[i+1]*(v[i+1]+1)/2)-min(v[i],v[i+1]);
  }
  if(i==v.size()-1){
    ans+=v[v.size()-1]*(v[v.size()-1]+1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void f(vector<int> v){
	sort(v.begin(), v.end(), greater<int>());
	int sum=0;
	for(int i=1; i<v.size(); i++){
		sum+=v[i];
	}
	if(v[0] > sum){
		cout<<v[0]-sum-1<<endl;
	}else if(v[0]==sum){
		cout<<0<<endl;
	}else{
		int minus=v[0];
		v[0]=0;
		int i=1;
		while(minus>0){
			if(v[i] <= minus){
				minus-=v[i];
				v[i]=0;
			}else{
				v[i]-=minus;
				minus=0;
			}
			i++;
		}
		f(v);
	}
}


int main(){
	int K, T;
	vector<int> v;

	cin>>K>>T;
	v.resize(T);
	for(int i=0; i<T; i++){
		cin>>v[i];
	}

	f(v);

	return 0;
}


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

int main(){
  string str;
  getline(cin,str);

  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a' && str[i]<='z'){
      str[i]+='A'-'a';
    }else if(str[i]>='A' && str[i]<='Z'){
      str[i]-='A'-'a';
    }
  
  }
    cout << str << endl;
}
  


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

lint gcd(lint a, lint b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K; cin >> K;
    lint ans = 0;
    range(a, 1, K + 1) range(b, 1, K + 1) range(c, 1, K + 1) {
        lint g = gcd(gcd(a, b), c);
        ans += g;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
    priority_queue<pair<int, int> > pq;
    int color[MAX];
    int d[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    pq.push(make_pair(0, 0));
    color[0] = GRAY;

    while (!pq.empty()) {
        pair<int, int> f = pq.top();
        pq.pop();
        int u = f.second;

        color[u] = BLACK;

        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                pq.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();
}



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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int sumLeft = 0, sumRight = 0;
    for(int i = 0; i < m ; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < m ; i++) {
        if(a[i] < x) sumLeft++;
        else sumRight++;
    }
    if(sumLeft < sumRight) {
        cout << sumLeft << endl;
    }
    else {
        cout << sumRight << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    rep(i,N) {
        int A; cin >> A;
        if (A % 2 == 0) if (A % 3 == 0 || A % 5 == 0) continue;
        else {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


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

int main()
{
    int A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main() {
	vector<int> into[100000];
	vector<int> out[100000];
	int innum[100000],ans[100000];
	int n, m;
	queue<int> que;

	cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		into[b].push_back(a);
		out[a].push_back(b);
		innum[b]++;
	}
	for (int i = 0; i < n; i++) {
		if (innum[i] == 0) {
			que.push(i);
			break;
		}
	}
	while (!que.empty()) {
		int now = que.front();
		que.pop();
		for (int i = 0; i < out[now].size(); i++) {
			innum[out[now][i]]--;
			if (innum[out[now][i]] == 0) {
				ans[out[now][i]] = now + 1;
				que.push(out[now][i]);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 12544
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
m = max(l)
ans = [m]*n
if len(set(l)) == 1 or l.count(m) > 1:
    for i in ans:
        print(i)
else:
    x = sorted(set(l))[-2]
    a = l.index(m)
    ans[a] = x
    for i in ans:
        print(i)


Measured memory_bytes: 20712
matrix = []

for i in range(0,3):
  matrix.append( list(map(int,input().split())) )
  
num = int(input())
num_list = []

for i in range(0,num):
  num_list.append(int(input()))
  
for i in range(0,3):
  for j in range(0,3):
    if matrix[i][j] in num_list :
      matrix[i][j] = 1
    elif matrix[i][j] not in num_list:
      matrix[i][j] = 0
  
sign = []
sign.append(matrix[0][0]*matrix[0][1]*matrix[0][2])
sign.append(matrix[1][0]*matrix[1][1]*matrix[1][2])
sign.append(matrix[2][0]*matrix[2][1]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][0]*matrix[2][0])
sign.append(matrix[0][1]*matrix[1][1]*matrix[2][1])
sign.append(matrix[0][2]*matrix[1][2]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][1]*matrix[2][2])
sign.append(matrix[2][0]*matrix[1][1]*matrix[2][0])

if 1 in sign:
  ans = "Yes"
else:
  ans = "No"
  
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
const int MAX=1e6+7;
typedef long long ll;
int n;
int c[3][3], a[MAX];
bool b[3][3];
bool check(){
    for(int i=0; i<3;i++){
        if(b[i][0]==true&&b[i][1]==true&&b[i][2]==true){
            return true;
        }
        else if(b[0][i]==true&&b[1][i]==true&&b[2][i]==true){
            return true;
        }
    }
    if(b[1][1]==true&&b[0][0]==true&&b[2][2]==true) return true;
    if(b[1][1]==true&&b[2][0]==true&&b[0][2]==true) return true;
    return false;
}
int main()
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3 ;j++)
            cin>>c[i][j];
    cin>>n;
    memset(b,false,sizeof(b));
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++){
                if(a[i]==c[j][k])
                    b[j][k]=true;
            }
    }
    check();
    if(check()){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<int> g[1<<20];

ll dfs(int s) {
    int n = g[s].size();

    if(n == 0) return 0;

    vector<ll> A(n);
    for(int i = 0;i < n;i++) {
        A[i] = dfs(g[s][i]);
    }

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

    ll answer = 0;
    rep(i, n) {
        answer = max(answer, n-i+A[i]);
    }

    return answer;
}

int main() {

    //freopen("lazy_loading.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);
    int n, x;cin>>n;

    for(int i = 2;i <= n;i++) {
        cin>>x;
        g[x].pb(i);
    }

    cout<<dfs(1)<<endl;


    return 0;
}


Measured memory_bytes: 40448
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  ll n=s.size();
  ll dp[n+1][13];
  mem(dp);
  dp[0][0]=1;
  rep(i,n) {
    rep(j,13) {
      if(s[i]=='?') {
        rep(k,10) {
          ll x=j*10+k;
          dp[i+1][x%13]+=dp[i][j];
          dp[i+1][x%13]%=MAX;
        }
      } else {
        ll x=j*10+s[i]-'0';
        dp[i+1][x%13]+=dp[i][j];
        dp[i+1][x%13]%=MAX;
      }
    }
  }
  pr(dp[n][5]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 10576
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    rep(i,n) --a[i];

    vector<ll> ball(n,0);
    rep(i,n){
        ++ball[a[i]];
    }

    ll sum = 0;
    rep(i,n){
        sum += ball[i]*(ball[i]-1)/2;
    }

    rep(i,n){
        cout << sum + 1 - ball[a[i]] << endl;
    }

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
pair = []
l = -1
r = -1
flg = False
for i in range(n-1):
    if flg == False:
        if a[i+1]-a[i]>=0:
            l = i
            flg = True
        else:
            pass
    else:
        if a[i+1]-a[i]>=0:
            pass
        else:
            r = i
            flg = False
            pair.append((a[l],a[r]))
if flg:
    r = i+1
    pair.append((a[l],a[r]))
# print(pair)
money = 1000
stock = 0
max_rate = 0
for fr,to in pair: 
    # if to/fr > max_rate:
    max_rate = to/fr
    #
    buy = money//fr
    stock += buy
    money -= buy*fr
    #
    sold = stock
    money += sold*to
    stock -= sold
    # else:
    #     continue
print(money)


# money

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)

using LL = long long;
using Node = struct {
  LL num, val, bonus;
};

const int maxn = 111;
int D, G;
int vis[maxn];
Node q[maxn];
 
signed main() {
  // freopen("in", "r", stdin);
  while(~scanf("%d%d",&D,&G)) {
    for(int i = 0; i < D; i++) {
      scanf("%lld%lld",&q[i].num,&q[i].bonus);
      q[i].val = (i + 1) * 100;
    }
    LL ret = 1E18;
    for(int i = 0; i < D; i++) {
      LL cur = 0, cnt = 0;
      for(int j = 1; j < q[i].num; j++) {
        cur += q[i].val; cnt++;
        if(cur >= G) {
          ret = min(ret, cnt);
          break;
        }
      }
    }
    vector<Node> tmp;
    int dd = 1 << D;
    for(int i = 1; i < dd; i++) {
      LL tot = 0, cnt = 0;
      memset(vis, 0, sizeof(vis));
      for(int j = 0; j < D; j++) {
        if(i & (1 << j)) {
          tot += q[j].num * q[j].val + q[j].bonus;
          cnt += q[j].num;
          vis[j] = 1;
        }
      }
      LL remain = G - tot;
      if(remain <= 0) ret = min(ret, cnt);
      else {
        tmp.clear();
        for(int i = 0; i < D; i++) {
          if(!vis[i]) tmp.push_back(q[i]);
        }
        sort(tmp.begin(), tmp.end(), [](Node x, Node y) {
          return x.val > y.val;
        });
        for(int i = 0; i < tmp.size(); i++) {
          LL fuck = 0, tcnt = 0;
          for(int j = 0; j < tmp[i].num; j++) {
            fuck += tmp[i].val; tcnt++;
            if(fuck >= remain) {
              ret = min(ret, cnt + tcnt);
            }
          }
        }
      }
    }
    printf("%lld\n", ret);
  }
  return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = [-int(_) for _ in input().split()]

heapq.heapify(a)

for i in range(m):
    tmp = heapq.heappop(a)
    a.append(tmp / 2)

res_list = [int(-_) for _ in a]
print(sum(res_list))

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

string s;

int main() {
	cin >> s;
	for(char x = 'a' ; x <= 'z' ; x++) {
		int mins = 1e9;
		int pos = -1;
		int cnt = 0;

		for(int i = 0 ; i < s.length() ; i++) {
			if(s[i] != x) continue;
			int sekarang = 2*cnt - i + 1;
			cnt++;
			
			if(sekarang > mins) {
				cout << pos+1 << " " << i+1 << endl;
				return 0;
			}

			sekarang--;
			if(sekarang < mins) {
				mins = sekarang;
				pos = i;
			}
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>

int main(){

int a,b;

scanf("%d %d",&a,&b);

if(0<=b && b<10) a*=10;
else if(b>=10 && b<100) a*=100;
else if(b==100) a*=1000;

for(int i=1;i<=400;i++){

if(i*i == a+b){
printf("Yes\n");
return 0;
}

}

printf("No\n");
return 0;
}

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

int main(){
int N;
cin >> N;

vector<long long> A(N), B(N), C(N);
for(int i = 0; i < N; i++){ 
      cin >> A.at(i);
}

for(int i = 0; i < N; i++){ 
      cin >> B.at(i);
}

for(int i = 0; i < N; i++){ 
      cin >> C.at(i);
}

sort(A.begin(), A.end());
sort(C.begin(), C.end());

// long long a_cnt = 0, b_cnt = 0;
long long ans = 0;
for(int i = 0; i < N; i++){ 
        long long a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        long long b = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
      ans += a * b;
}


cout << ans << endl;

}


Measured memory_bytes: 2560
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=105;
int L,n,m,bin[N],a[N];
struct data{int x,y,w;} ans[N];

void add(int x,int y,int w)
{
	ans[++m]=(data){x,y,w};
}

int main()
{
	scanf("%d",&L);
	n=20,bin[0]=1;
	rep(i,1,20) bin[i]=bin[i-1]*2;
	repd(i,n-1,2) add(i,i+1,bin[n-i-1]),add(i,i+1,0);
	int top=0,sum=0;
	while(L>=262144) add(1,2,sum),sum+=262144,L-=262144;
	while(L) a[++top]=L&1,L>>=1;
	repd(i,top,1)
	{
		if(!a[i]) continue;
		add(1,n-i+1,sum);
		sum+=bin[i-1];
	}
	printf("%d %d\n",n,m);
	rep(i,1,m) printf("%d %d %d\n",ans[i].x,ans[i].y,ans[i].w);
	return 0;
}


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

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

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second

/*-------------------------------------------------*/




int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];

  sort(all(L));

  for(int i = 0; i < n - 2; i++){
    for(int j = i + 1; j < n - 1; j++){
      for(int k = j + 1; k < n; k++){
        if(L[k] < L[i] + L[j] &&
           L[i] != L[j] &&
           L[j] != L[k] &&
           L[k] != L[i] )
          ans++;
      }
    }
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3628
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N+1)
M = 0
for i in range(N, 0, -1):
    temp_sum = sum([b[j] for j in range(i, N+1, i)]) - b[i]
    if temp_sum % 2 == 0 and a[i] == 0:
        b[i] = 0
    if temp_sum % 2 == 1 and a[i] == 0:
        b[i] = 1
        M += 1
    if temp_sum % 2 == 0 and a[i] == 1:
        b[i] = 1
        M += 1
    if temp_sum % 2 == 1 and a[i] == 1:
        b[i] = 0


print(M)
ans_list = [i for i in range(1, N+1) if not b[i] == 0]
print(*ans_list)

Measured memory_bytes: 92008
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i, stop) for(int i = 0; i < (stop); i++)
#define PI 3.141592653589793
using namespace std;

int main(){
  
  int n;
  cin >> n;
  ll a[n];
  FOR(i,n) cin >> a[i];

  ll ans=0;
  FOR(i,n-1){
    if(a[i] > a[i+1]){
      ans += a[i] - a[i+1]; 
      a[i+1] = a[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[101010];
	while(scanf("%s",s)!=EOF);
	int len=strlen(s);
	int flag=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C')
		{
			flag=1;
		}
		if(s[i]=='F'&&flag==1)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

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

int main()
{
  string s, t;
  int tmp = 0;

  cin >> s >> t;

  for (int i = 0; i < s.size(); i++)
  {
    for (int j = 0; j < t.size(); j++)
    {
      if(s[i] - t[j] < 0)
      {
        cout << "Yes" << endl;
        exit(0);
      }
      if (s[i] == t[j])
      {
        tmp++;
      }
    }
  }

  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != t[i]) break;
    if (i == s.size() - 1 && s.size() != t.size())
    {
      cout << "Yes" << endl;
      exit(0);
    }
  }

  cout << "No" << endl;

}


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

int main()
{
    int S,h,m,s;
    
    cin >> S;
    
    h += S / 3600;
    m += (S % 3600)/60;
    s += S % 60;
    
    cout << h << ':' << m << ':' << s << endl;
    
    return 0;
}


Measured memory_bytes: 3132
s=input()
q=int(input())
que=[]
count=0
left=[]
right=[]
for i in range(q):
  qu=list(map(str,input().split()))
  if qu[0]=="1":
    count+=1
  que.append(qu)
han=0
for i in range(q):
  if que[i][0]=="1":
    han+=1
  else:
    if que[i][1]=="1":  
      if (count-han)%2==0:
        left.append(que[i][2])
      else:
        right.append(que[i][2])
    elif que[i][1]=="2":  
      if (count-han)%2==0:
        right.append(que[i][2])
      else:
        left.append(que[i][2])
ls="".join(left[::-1])
rs="".join(right)
if count%2==0:
  print(ls+s+rs)
else:
  print(ls+s[::-1]+rs)

Measured memory_bytes: 42372
#include<stdio.h>
int main()
  { 
    int H,A,s,i,count=0;
    scanf("%d %d",&H,&A);
    s=H-A;
    while(s>0)
      { 
       for(i=1;s>0;i++)
        { 
          s=H-i*A;
          count++;
         } 
      } 
  if(H-A<=0)
    printf("1");
  else
    printf("%d",count);
  return 0;
  }
    
      
  


Measured memory_bytes: 128
class NullNode():
    def __init__(self):
        self.id = None

null_node = NullNode()
class Node():
    def __init__(self, id):
        global null_node
        self.id = id
        self.parent = null_node
        self.left = null_node
        self.right =  null_node

def preorder(node, out_list=[]):
    if node.id is not None:
        out_list.append(str(node.id))
        out_list = preorder(node.left, out_list)
        out_list = preorder(node.right, out_list)
    return out_list

def inorder(node, out_list=[]):
    if node.id is not None:
        out_list = inorder(node.left, out_list)
        out_list.append(str(node.id))
        out_list = inorder(node.right, out_list)
    return out_list

def insert(node, root_node):
    temp_node_parent = root_node.parent
    temp_node = root_node

    while temp_node.id is not None:
        temp_node_parent = temp_node
        if node.id < temp_node.id:
            temp_node = temp_node.left
        else:
            temp_node = temp_node.right

    node.parent = temp_node_parent
    if node.id < temp_node_parent.id:
        temp_node_parent.left = node
    else:
        temp_node_parent.right = node

def find(id,root_node):
    node = root_node
    while node.id is not None:
        if id < node.id:
            node = node.left
        elif id > node.id:
            node = node.right
        else:
            print('yes')
            break
    else:
        print('no')

def get_successor(node):
    successor = node.right
    while(successor.left.id is not None):
        successor = successor.left
    return successor

def delete(id, root_node):
    global null_node
    node = root_node
    while node.id != id:
        if id < node.id:
            node = node.left
        else:
            node = node.right

    if node.left.id is None or node.right.id is None:
        del_node = node

    else:
        del_node = get_successor(node)
        node.id = del_node.id

    if del_node.left.id is not None:
        change_node = del_node.left
    else:
        change_node = del_node.right

    if change_node.id is not None:
        change_node.parent = del_node.parent

    if del_node.parent.id is None:
        root_node = change_node
    elif del_node.id == del_node.parent.left.id:
        del_node.parent.left = change_node
    else:
        del_node.parent.right = change_node




import sys

n = int(sys.stdin.readline())
input_lines = sys.stdin.readlines()
root_node = NullNode()
for i in range(n):
    input_line = input_lines[i].split()
    command = input_line[0]
    if command == 'insert':
        id = int(input_line[1])
        id_node = Node(id)
        if root_node.id is None:
            root_node = id_node
        else:
            insert(id_node, root_node)

    elif command == 'find':
        id = int(input_line[1])
        find(id, root_node)

    elif command == 'delete':
        id = int(input_line[1])
        delete(id, root_node)
    else:
        inorder_list = inorder(root_node, [])
        preorder_list = preorder(root_node, [])
        out = ' ' + ' '.join(inorder_list)
        print(out)
        out = ' ' + ' '.join(preorder_list)
        print(out)



Measured memory_bytes: 186144
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

//#include <chrono>
//using namespace std::chrono;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);


int solve(int n) {
    int num = 0;

    int xmax = static_cast<int>(round(sqrt(n)));
    for (int x=1; x<=xmax; ++x) {
        int resx = n - x * x;
        if (resx <= 0) continue;

        int ymax = static_cast<int>(round(sqrt(resx - 4)));
        for (int y=1; y<=ymax; ++y) {
            int resy = resx - y * y - x * y;
            if (resy <= 0) continue;

//            int a = 1;
//            int b = (x + y);
//            int c = -resy;
//            int rootpow = b * b - 4 * a * c;

//            if (rootpow > 0) {
//                double droot = sqrt(rootpow);
//                int rootpowFromd = round((droot * droot));
//                if (rootpowFromd == rootpow) {
//                    // 整数解
//                }
//            }
//            bool check = true;

            int zmax = static_cast<int>(round(sqrt(resy - 2)));
            for (int z=1; z<=zmax; ++z) {
                int lhs = z * z + z * (y + x);
                if (lhs == resy) {
                    ++num;
                }
            }
        }
    }

    return num;
}

int main() {
    int N;
    cin >> N;

    //auto t0 = high_resolution_clock::now();

    for(int n=1; n<=N; n++) {
        int num = solve(n);
        cout << num << endl;
    }

    //auto t1 = high_resolution_clock::now();
    //cout << duration_cast<milliseconds>(t1 - t0).count() / 1000. << "s." << endl;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a, ll b) {
	if (b == 0) return 1;
	ll pp = power(a, b/2);
	pp = (pp*pp) % mod;
	if(b%2 == 0) return pp;
	return (pp*a)%mod;
}

int main() {
    //freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);

	ll x, y;
	cin>>x>>y;
	if(x == y || max(x, y)-min(x, y) == 1) {
		cout<<"Brown"<<endl;
		return 0;
	}

	cout<<"Alice"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		//入力を配列化
		char[] array = scanner.next().toCharArray();

		//かぶった数
		int count = 0;

		for(int i = 0; i < array.length; i++) {
          
			for(int l = 0; l < array.length; l++) {
              
				//同じ要素を比較しない
				if(i == l) {
					continue;
				}
              
				count += array[i] == array[l] ? 1 : 0;
              
			}
          
		}
		
		System.out.println(count == 4 ? "Yes" : "No");

		scanner.close();
	}

}


Measured memory_bytes: 22740
#include<iostream>
using namespace std;
int main(){
  int X;
  cin >> X;
  int all=0;
  for(int i=1;i<=X;i++){
    all = all+i;
    if (all >= X && all-X <i){
      cout << i;
      return 0;
    }
  }
  cout << X <<  endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
map<int,int,greater<int> > a;
int main() {
  int n,m;
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int A;
    cin >> A;
    a[A]++;
  }
  for(int i = 0; i < m; i++) {
    int b,c;
    cin >> b >> c;
    a[c] += b;
  }

  /* for(auto itr = a.begin(); itr != a.end(); ++itr) {
    cout << itr->first<<"   "<<itr->second << endl;
    }*/

  ll ans = 0;
  int k = 0;
  for(auto itr = a.begin(); itr != a.end(); ++itr) {
    ll s = itr->first;
    int t = itr->second;
    if(k + t > n) {
      ans += s * (n - k);
      break;
    }
    else {
      ans += s * t;
      k += t;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    int n,
        num,
        cnt;

    scanf("%d", &n);

    cnt = n;

    for (int i = 0; i != n; ++i)
    {
        scanf("%d", &num);

        for (int j = 2; j <= sqrt(num); ++j)
        {
            if (num%j == 0)
            {
                --cnt;
                break;
            }
        }
    }
    
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 3208
#include<stdio.h>

int main(){
    char s[101];
    scanf("%s", s);
    int n = 0, flag = 1;
    while(s[n] != '\0'){
        if((n%2 == 0 && s[n] == 'L') || (n%2 == 1 && s[n] == 'R')){
            flag = 0;
            break;
        }
        n++;
    }
    if(flag == 1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

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

int main() {
	int n, k;
	scanf("%d%d", &k, &n);
	if (k == 1) {
		for (int i = 0; i < (n + 1) / 2; i++)
			printf("1 ");
	} else if (k % 2) {
		int64_t num = 0, cur = 1;
		int i = 0;
		for (; i < n && num < 100000000000LL; i++)
			num += cur *= k;
		if (i == n) {
			int64_t t = (num - 1) / 2;
			std::vector<int> res;
			for (int i = 0; i < n; i++) {
				if (i) {
					if (!t) break;
					t--, num--;
				}
			  num /= k;
				res.push_back(t / num);
				t %= num;
			}
			for (auto j : res) printf("%d ", j + 1);
		} else {
			int shift = 0;
			std::vector<int> res;
			for (int j = 0; j < n - i; j++) {
        if (j && (n - j) % 2) shift++;
				res.push_back((k + 1) / 2);
			}
			num++;
			int64_t t = (num - 1) / 2 - shift;
			assert(t >= 0);
      for (int j = n - i; j < n && t; j++) {
				t--, num--;
				num /= k;
				res.push_back(t / num + 1);
				t %= num;
			}
      for (auto j : res) printf("%d ", j);

		}
	} else {
		printf("%d", (k + 1) / 2);
		for (int i = 0; i + 1 < n; i++)
			printf(" %d", k);
	}
  return 0;
}


Measured memory_bytes: 3568
#include<stdio.h>

int N,M;
int d[1001];
int a[1001];

int main(){
	int i,cor;
	
	while(1){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)break;
		
		cor = 0;
		for( i = 0;i < N;i++ ){
			scanf("%d",d+i);
		}
		for( i = 0;i < M;i++ ){
			scanf("%d",a+i);
		}
		for( i = 0;i < M;i++ ){
			//printf("%d回目 cor = %d\n",i,cor);
			cor += a[i];
			if( cor >= N-1 )
				break;
			cor += d[cor];
			if( cor >= N-1 )
				break;
		}
		//printf("%d回目 cor = %d\n",i,cor);
		printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    string s; cin >> s;

    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    } else if (s=="Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,c;
int i,j,k,n,m; 
int main(){
	cin>>s;
	cin>>c;
	if(s.size()==c.size()){
		for(i=0;i<s.size();i++){
			cout<<s[i]<<c[i];
		}
		cout<<endl;
	}
	else {
		for(i=0;i<s.size()-1;i++){
			cout<<s[i]<<c[i];
		}
		cout<<s[s.size()-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using P = pair<int, int>;

const int INF = 1001001001;
const int NIL = -1;

P dfs(const vector<int> &A, vector<int>& way, vector<int>& time, int node, int t)
{
    time[node] = t;
    if(way[A[node]] != NIL)
    {
        return make_pair(time[A[node]], t+1);
    }
    way[node] = A[node];
    return dfs(A, way, time, A[node], t+1);
}


int main()
{
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N), way(N, NIL), time(N, INF);
    for(int i=0;i<N;++i){
        cin >> A[i];
        --A[i];
    }
    // 時間とたどった道筋を保存
    int t1, t2;
    tie(t1, t2) = dfs(A, way, time, 0, 0);
    if(K < t2){
        for(int i=0;i<N;++i)
        {
            if(time[i] == K)
            {
                cout << i + 1 << endl;
                break;
            }
        }
    }
    else{
        K -= t1;
        K %= (t2 - t1);
        for(int i=0;i<N;++i)
        {
            if(time[i] == t1 + K)
            {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

double PI=acos(-1.0);

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

    double a,b,x;
    cin>>a>>b>>x;

    double c,d,e,f,arad,ans,xo;

    arad = PI * 90.0 / 180.0;

    if(x-(a*b*a/2)<=0) {

        c = 2.0 * x/(a*b);

        //余弦定理
        d = sqrt((b * b) + (c * c) - (2.0 * b * c * cos(arad)));

        ans = acos(((c * c) + (d * d) - (b * b)) / (2 * c * d));
        ans = ans * (180 / PI);

    } else {
        xo = (a*a*b)-x;

        e = 2 * xo/(a*a);

        f = sqrt((a * a) + (e * e) - (2.0 * a * e * cos(arad)));

        ans = acos(((a * a) + (f * f) - (e * e)) / (2 * a * f));
        ans = ans * (180 / PI);

    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)
        cout<<"Possible";
    else 
        cout<<"Impossible";
    cout<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    vector<ll> A(N);
    double div = 1;
    rep(i, N) {
        A[i] = i;
        div *= i + 1;
    }
    double cnt = 0;
    do {
        ll p_x = -1;
        ll p_y = -1;
        rep(i, N) {
            ll x = items[A[i]].first;
            ll y = items[A[i]].second;
            if (i != 0) {
                cnt += pow((pow(abs(x - p_x), 2) + pow(abs(y - p_y), 2)), 0.5);
            }
            p_x = x;
            p_y = y;
        }
    } while (next_permutation(A.begin(), A.end()));
    cout << cnt / div << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
long long read()
{
    char s;
    long long k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
long long l,r,ll,rr,a[100100];
int n,flag,f1,f2; 
int main()
{
	n=read();l=2;r=2;flag=1;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=n;i>=1;i--)
	{
		ll=l;rr=r;f1=f2=1;
		if (l%a[i]==0)
		{
			rr=max(r,l+a[i]-1);
			ll=l;
		} else
		{
			if ((r/a[i])>(l/a[i]))
			{
				ll=((l/a[i])+1)*a[i];
			} else f1=0;
		}
		if (r%a[i]==0)
		{
			ll=min(ll,r);
			rr=max(rr,r+a[i]-1);
		} else
		{
			if ((r/a[i])>(l/a[i]))
			{
				rr=(r/a[i])*a[i]+a[i]-1;
			} else f2=0;
		}
		if (!f1&&!f2) flag=0;
		l=ll;r=rr;
	}	
	if (!flag) printf("-1"); else printf("%lld %lld",l,r);
	return 0;
} 

Measured memory_bytes: 1024
A, B, C, X, Y = map(int, input().split())

ans = A * X + B * Y
if X >= 1 and Y >= 1:

    z = min(X, Y)
    ans = min(ans, A * (X - z) + B * (Y - z) + C * (z * 2))

    z = max(X, Y)
    ans = min(ans, A * max(0, (X - z)) + B * max(0, (Y - z)) + C * (z * 2))

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
//str.substr(開始位置, 取り出す長さ);
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c;
	char d,e;
	cin >> a >> d >> b >> e >>c;
	if (b <=4) {
		cout << "Heisei" << endl;
	} else {
		cout << "TBD" << endl;
	}

	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 998244353;

ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if(b == 0){
        return 1;
    }
    if(a == b){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
int main() {
    //cout.precision(10);
    init_combination();
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for(ll i = 0; i <= n; i++){
        if(i * a > k){
            break;
        }
        if((k - i * a) % b != 0){
            continue;
        }
        ll j = (k - i * a) / b;
        if(j > n){
            continue;
        }
        ans += (combination(n, i) * combination(n, j)) % mod;
        ans = ans % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
static const int MAX=10000;
static const int INFTY = (1<<21);

vector< pair<int,int> >M[MAX]; //?????\??¨
priority_queue< pair<int,int> > PQ; //????????§??????, first???d[i], second???i??? ?????¨??¶?????????first???????????°
bool visited[MAX]; //???????¢??????????
int d[MAX]; //?????????????????¬

void dijkstra_implementsPQ(int n)
{
    //init
    for(int i=0;i<n;i++)
    {
        d[i]=INFTY;
        visited[i]=false;
    }
    //select node 0
    d[0]=0;
    PQ.push(make_pair(0,0));

    while(!PQ.empty())
    {
        //currently the top of PQ is the shortest one
        pair<int,int> temp=PQ.top();PQ.pop();
        int u=temp.second;

        visited[u]=true;
        if(d[u]<temp.first*(-1)) continue;

        //update
        for(int j=0;j<M[u].size();j++)
        {
            int v=M[u][j].first;
            if(visited[v]==true) continue;
            //else try updating
            if(d[v]>d[u]+M[u][j].second)
            {
                d[v]=d[u]+M[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    //print
    for(int i=0;i<n;i++)  cout<<i<<' '<<(d[i]==INFTY?-1:d[i])<<endl;

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

    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int v,d;
            cin>>v>>d;
            M[u].push_back(make_pair(v,d));
        }
    }

    dijkstra_implementsPQ(n);
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
int a[MAX_N];

int frd[MAX_N];
int brd[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  frd[0] = a[0];
  for (int i = 1; i < n; ++i) {
    frd[i] = max(a[i], frd[i - 1]);
  }

  brd[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    brd[i] = max(brd[i + 1], a[i]);
  }

  printf("%d\n", brd[1]);

  for (int i = 1; i < n - 1; ++i) {
    int ans = max(frd[i - 1], brd[i + 1]);

    printf("%d\n", ans);
  }

  printf("%d\n", frd[n - 2]);

  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int N, K, C; cin >> N >> K >> C;
    string S; cin >> S;

    vector<int> L(K), R(K);

    int p = 0;
    for (int i = 0; i < K; i++) {
        while (S[p] != 'o') p++;
        L[i] = p;
        p += C+1;
    }
    p = S.size()-1;
    for (int i = K-1; i >= 0; i--) {
        while (S[p] != 'o') p--;
        R[i] = p;
        p -= C+1;
    }

    for (int i = 0; i < K; i++) {
        if (L[i] == R[i]) {
            cout << L[i] + 1 << endl;
        }
    }
}


Measured memory_bytes: 3332