akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    long N = nextInt();
	    long K = nextInt();
	    long total = K; 
	    
	    for(long i=1; i<N; i++){
	        total *= (K-1);
        }
        out.println(total);
	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

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


int main(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int cnt = 0;
    for(int i=0;i<n-2;i++){
        if(p[i]<p[i+1] && p[i+1]<p[i+2]){
            cnt++;
        }if(p[i]>p[i+1] && p[i+1]>p[i+2]){
            cnt++;
        }
    }
    cout << cnt << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  vp x(5);
  rep(i,5) {
    cin >> x[i].first;
    x[i].second=i;
  }
  sort(rng(x));
  cout << x[0].second+1 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

void add(LL& a, LL b) { a = (a + b) % kMod; }

LL dp[22][1 << 21] = {};
int main() {
  int N; cin >> N;
  vector<vector<int>> a(N);
  for (int i = 0; i < N; ++i) {
    a[i].resize(N); cin >> a[i];
  }

  dp[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (!a[i][j]) continue;
      int mask = (1 << j);
      for (int S = 0; S < (1 << N); ++S) {
        if (S & mask) continue;
        add(dp[i + 1][S|mask], dp[i][S]);
      }
    }
  }
  cout << dp[N][(1 << N) - 1] << endl;
}


Measured memory_bytes: 347664
//====================== Author Info ===================
//    Khaled Alam (Ninjo)   ~   khaledalam.net@gmail.com
//======================================================
#include <bits/stdc++.h>
using namespace std;
#define  sz           size()
#define  fi           first
#define  se           second
#define  mp           make_pair
#define  pb           push_back
#define  ll           long long int
#define  ones         __builtin_popcount
#define  all(a)       (a).begin(), (a).end()
#define  iFile(a)     freopen(#a, "r", stdin)
#define  oFile(a)     freopen(#a, "w", stdout)
#define  rep(i,a,z)   for(auto i=(a);i<(z);i++)
#define  ios          ios_base::sync_with_stdio(false)
#define  tm           fprintf(stderr,"%.3f s\n",(float)clock()/1000);

int main() {
//iFile(input.txt);
//oFile(output.txt);

	string s;
	cin >> s;
	map<char, int> mop;
	for (char it : s) {
		if (tolower(it)) {
			mop[it]++;
		}
	}
	for (auto i : mop)
		if (i.se % 2 == 0) {
		} else {
			cout << "No";
			return 0;
		}

	cout << "Yes";

}


Measured memory_bytes: 256
/*林檎が A個、林檎の欠片が P個
林檎 1個は、砕くことで林檎の欠片 3個に。
また、林檎の欠片 個を鍋で煮込むことで、アップルパイが 1個作れます。
今ある材料で作れるアップルパイの最大数を求めてください。

*/
#include <stdio.h>


int main (void){
  int m,s;
scanf("%d %d",&m,&s);

printf("%d",(m*3+s)/2);
return 0;
}


Measured memory_bytes: 128
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e7 + 10; 

int cnt[N];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   for(int i = 1; i < N; i++){
      for(int j = i; j < N; j += i){
         cnt[j]++;
      }
   }
   int ans = 0;
   int n;
   cin >> n;
   f(i,1,n+1){
      ans += i*cnt[i];
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 81756
require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# 特殊な隣接リストを構築
graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << [b, c]
  r_graph[b] << [a, c]
end

# スタートとゴールから到達可能なノードを列挙
def reachable(graph, s)
  visit = Set.new
  visit.add(s)
  q=[s]
  until q.empty?
    u=q.shift
    graph[u].each do |n, _|
      next if visit.include?(n)
      visit.add(n)
      q.push(n)
    end
  end
  visit
end

from_1 = reachable(graph, 1)
from_n = reachable(r_graph, n)

available_nodes = from_1 & from_n
available_roads = abc.select {|a, b, _| available_nodes.include?(a) || available_nodes.include?(b) }

# ベルマンフォードで経路探索、最短経路を算出
INF = 1 << 60
dist=Array.new(n+1, INF)
dist[1]=0
updated=false

available_nodes.each do
  updated=false
  available_roads.each do |from, to, cost|
    if dist[from] != INF && dist[to] > dist[from] + cost
      dist[to] = dist[from] + cost
      updated = true
    end
  end
  break unless updated
end

if updated
  p -1
  exit
end

#p abc
#p [from_1, from_n]
#p available_roads
#p dist
p [-1*dist[n], 0].max



Measured memory_bytes: 5756
n = int(input())
a = [int(i) for i in input().split()]
cnt = [0,0]
s = [0,0]
for i in range(n):
    s[0] += a[i]
    s[1] += a[i]
    if i%2 == 0:
        if s[0] <= 0:
            cnt[0] += -s[0]+1
            s[0] = 1
        if s[1] >= 0:
            cnt[1] += s[1]+1
            s[1] = -1
    else:
        if s[1] <= 0:
            cnt[1] += -s[1]+1
            s[1] = 1
        if s[0] >= 0:
            cnt[0] += s[0]+1
            s[0] = -1
ans = min(cnt)
print(ans)

Measured memory_bytes: 63216
S=input()
QN=int(input())
front=''
rear=''
rev=False

for i in range(QN):
    op=input()
    if op[0]=='1':
        rev=not(rev)
    else:
        if op[2]=='1':
            if rev:
                rear+=op[4]
            else:
                front+=op[4]
        else:
            if rev:
                front+=op[4]
            else:
                rear+=op[4]

if rev:
    print(rear[::-1]+S[::-1]+front)
else:
    print(front[::-1]+S+rear)

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> a(n);
  REP(i,n)cin>>a[i];
  int masu[101][101]={};
  int r=0,c=0,k=0;
  REP(i,n){
    int tmp=a[i];
    for(int j=0;j<tmp;j++){
      if((r+1)%2==1){
      masu[r][c]=i+1;
        //c++;
        if(c==w-1){
          if(j<tmp){
            //masu[r][c]=i+1;
            //j++;
            r+=1;
          }
        }else c++;
      }else if((r+1)%2==0){
        masu[r][c]=i+1;
    //    c--;
        if(c==0){
          if(j<tmp){
            //masu[r][c]=i+1;
            //j++;
            r+=1;
          }
        }else c--;
      }
    }
  }

  REP(i,h){
    REP(j,w){
      cout<<masu[i][j];
      if(j<w-1)cout<<' ';
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)
int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

vector<vector<int>> mat(8, vector<int>(8));
int h, w, c, ans = 0;

void dfs(int cur){
    if(cur == 5){
        vector<vector<int>> cp = mat;
        int from = mat[0][0], to = c;
        queue<pair<int,int>> q;
        q.push({0,0});
        while(!q.empty()){
            pair<int,int> p = q.front();    q.pop();
            int i = p.first, j = p.second;
            if(mat[i][j]==to)   continue;
            mat[i][j] = to;
            for(int k = 0; k < 4; k++){
                int ni = i+di[k], nj = j+dj[k];
                if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]==from) q.push({ni,nj});
            }
        }
        int tmp = 0;
        vector<vector<bool>> visit(8, vector<bool>(8,0));
        q.push({0,0});
        while(!q.empty()){
            pair<int,int> p = q.front();    q.pop();
            int i = p.first, j = p.second;
            if(visit[i][j])   continue;
            visit[i][j] = true;
            tmp++;
            for(int k = 0; k < 4; k++){
                int ni = i+di[k], nj = j+dj[k];
                if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]==to) q.push({ni,nj});
            }
        }
        ans = max(ans, tmp);
        mat = cp;
        return;
    }

    for(int to = 1; to <= 6; to++){
        if(mat[0][0] == to) continue;
        vector<vector<int>> cp = mat;
        int from = mat[0][0];
        queue<pair<int,int>> q;
        q.push({0,0});
        while(!q.empty()){
            pair<int,int> p = q.front();    q.pop();
            int i = p.first, j = p.second;
            if(mat[i][j]==to)   continue;
            mat[i][j] = to;
            for(int k = 0; k < 4; k++){
                int ni = i+di[k], nj = j+dj[k];
                if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]==from) q.push({ni,nj});
            }
        }
        dfs(cur+1);
        mat = cp;
    }

    return;
}

int main(){
    while(cin >> h >> w >> c, h+w+c){
        ans = 0;
        mat.resize(8, vector<int>(8,0));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> mat[i][j];
            }
        }
        dfs(1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve

// int D
void solve(void)
{
  int N; cin>>N;
  int A,B; cin>>A; cin>>B;
  int C,D; cin>>C; cin>>D;
  string str; cin>>str;
  bool pass = 0;
  str += "#";
  bool ok = 1;
  for (int i =  A- 1; i < C-1; i++)
  {
    if(str[i] == '#' && str[i+1] == '#') ok = 0;
  }
  for (int i =  B- 1; i < D-1; i++)
  {
    if(str[i] == '#' && str[i+1] == '#') ok = 0;
  }
  int check = 0;
    for (int i = B - 2; i <= D - 2; i++)
  {
    if(str[i] == '.' && str[i+1] == '.' && str[i+2] == '.') check = 1;
  }
  if(C > D) ok &= check;
  cout<<(ok?"Yes":"No")<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}
*/


void solve(){
  string S, T;
  ll a, b;
  string U;
  cin >> S >> T >> a >> b >> U;
  if(S == U){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,n,a[25][25],d[5000000];
long long dp(int i,int x){
    if(i==n) return 1;
    if(d[x]!=-1) return d[x];
    d[x]=0;
    for(int j=0;j<n;j++)
        if(a[i][j]&&(x&(1<<j))==0) d[x]+=dp(i+1,x|(1<<j));
    d[x]%=1000000007;
    return d[x];
}
int main()
{
    memset(d,-1,sizeof d);
    cin>>n;
    for(i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    cout<<dp(0,0);
    return 0;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ss second
#define ff first
#define mit map<ll,ll>::iterator
#define it(x,type) x<type>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define printf __mingw_printf
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vec2d(nam,type,row,col,fix) vector<vector<type>> nam(row,vector<type>(col,fix))
#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))

int main()
{
     io;
    //string hudai(1000000,'a');
    int T=1;
    //cin>>T;
     for(int cas=1;cas<=T;cas++)
    {
        ll n,i,j,k,l    ;
        cin>>n;
        vl sum(n+3);vec2d(dp,ll,n+2,n+2,1e18);
        sum[0]=0,sum[n+1]=1e18;
        for(i=1;i<=n;i++)
        {
            cin>>k;
            sum[i]=sum[i-1]+k;
        }

        for(i=1;i<=n;i++)
        {
            dp[i][i]=0;
            dp[i][i+1]=sum[i+1]-sum[i-1];
        }
        for(k=2;k<=n-1;k++)
        {
            for(i=1;i+k<=n;i++)
            {
                for(l=i;l<i+k;l++)
                {
                    dp[i][i+k]=min(dp[i][i+k],dp[i][l]+dp[l+1][i+k]);
                }
                dp[i][i+k]=dp[i][i+k]+(sum[i+k]-sum[i-1]);
            }
        }
        cout<<dp[1][n];

    }
    return 0;
}


Measured memory_bytes: 4524
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	string str;
	int i = 0;
	while (i < s.size()){
		if (s.substr(i, 2) == "BC"){
			str += "D";
			i += 2;
		} else {
			str += s.substr(i, 1);
			i++;
		}
	}
	i = s.size() - 1;
	long long res = 0;
	long long ans = 0;
	while (i >= 0){
		if (str[i] != 'A' and str[i] != 'D') {
			res = 0;
			i--;
		} else if (str[i] == 'A'){
			ans += res;
			i--;
		} else {
			res++;
			i--;
		}
	}

	cout << ans << endl;



}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,b1,b2,ans=0;
    cin>>n;
    cin>>b1;
    ans+=b1;
    rep(i,n-2){
        b2=b1;
        cin>>b1;
        ans+=min(b1,b2);
    }
    ans+=b1;
    cout<<ans<<endl;
    return 0;
}

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

void CountingSort(int);
		  
int A[2000000];
int B[2000000]={};

int main(){
  int n, i;

  scanf("%d",&n);
  if( n<1 || 2000000<n ) exit(0);

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
    if( A[i]<0 || 10000<A[i] ) exit(1);
  }

  CountingSort(n);
  
  for( i=0 ; i<n ; i++ ){
    if( i==n-1 ){
      printf("%d\n",B[i]);
    }
    else{
      printf("%d ",B[i]);
    }
  }
  
  return 0;
}

void CountingSort(int n){
  int i, j;
  int C[10000]={};

  for( j=0 ; j<n ; j++ ){
    C[A[j]]++;
  }
  
  for( i=0 ; i<10000 ; i++ ){
    C[i] = C[i] + C[i-1];
  }

  for( j=n-1 ; j>=0 ; j-- ){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    ll A;
    double B;
    cin >> A >> B;
    ll B_ll = B * 100 + 0.5;
    cout << A*B_ll / 100 << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int R, G;
	cin >> R >> G;

	cout << 2 * G - R << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n;
int a[100000];
int main(){
	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	sort(a,a + n);

	int ans = 0;
	int i = 0;
	while(i < n) {
		int c = 1;
		while(i + 1 < n && a[i] == a[i + 1]) {
			i++;c++;
		}
		if(c < a[i]) {
			ans += c;
		}
		if(c > a[i]) {
			ans += (c - a[i]);
		}
		i++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

void solve() {
  int n, r;
  cin >> n >> r;
  if(n >= 10) cout << r << "\n";
  else cout << r + 100 * (10 - n) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXL = 5 + 3000;
string s,t;
int memo[MAXL][MAXL];

int dp(int i, int j) {
    if(i == -1 || j == -1) return 0;
    int& ans = memo[i][j];
    if(ans == -1) {
        if(s[i] == t[j]) {
            ans = 1 + dp(i - 1, j - 1);
        } else {
            ans = max(dp(i - 1, j), dp(i, j - 1));
        }
    }
    return ans;
}

string ans;
void solve(int i, int j) {
    if(i == -1 || j == -1) return;
    if(s[i] == t[j]) {
        ans += s[i];
        solve(i - 1, j - 1);
    } else {
        if(dp(i - 1, j) >= dp(i, j - 1)) {
            solve(i - 1, j);
        } else {
            solve(i, j - 1);
        }
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> s >> t;
    memset(memo, -1, sizeof memo);
    solve(s.size() - 1, t.size() - 1);
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 35968
#include<iostream> 
#include<cstdio> 
#include<algorithm> 
#include<cstring> 

using namespace std; 

const int maxn = 4e5+5; 
const int inf = 0x3f3f3f3f; 
int n; 
int a[maxn]; 
int h[maxn]; 
int rt,ls[maxn],rs[maxn],tot,mx[2][maxn]; 

void maketree(int &p,int l,int r) { 
	p = ++tot;
	mx[0][p] = mx[1][p] = -inf; 
    if(l==r) { 
        return; 
    } 
    int mid = (l+r)>>1; 
    maketree(ls[p],l,mid); 
    maketree(rs[p],mid+1,r); 
} 
void update(int ii,int &p,int l,int r,int x,int dd) { 
    if(l==r) { 
        mx[ii][p] = dd; 
        return; 
    } 
    int mid = (l+r)>>1; 
    if(x<=mid) update(ii,ls[p],l,mid,x,dd); 
    else if(x>mid) update(ii,rs[p],mid+1,r,x,dd); 
    mx[ii][p] = max(mx[ii][ls[p]],mx[ii][rs[p]]); 
} 
int query(int ii,int p,int l,int r,int x,int y) {
	if(x<=l&&r<=y) return mx[ii][p];
	int mid = (l+r)>>1;
	if(y<=mid) return query(ii,ls[p],l,mid,x,y);
	else if(x>mid) return query(ii,rs[p],mid+1,r,x,y);
	else return max(query(ii,ls[p],l,mid,x,y),query(ii,rs[p],mid+1,r,x,y));
}
bool isok(int cnt0,int cnt1,int max0,int max1,int NH) { 
    int yoo = (cnt1-cnt0+NH);
    if(yoo>=0&&query(yoo&1,rt,0,n+1,max0+1,n+1)>=yoo) return 1;
	yoo = cnt0-cnt1+NH;
	if(yoo>=0&&query(yoo&1,rt,0,n+1,max1+1,n+1)>=yoo) return 1;
	return 0;
} 
int main() { 
    int NH = 0; 
    scanf("%d",&n); 
    int MX = 0; 
    for(int i=1;i<=n;i++) { 
        scanf("%d",&a[i]); 
        MX = max(MX,a[i]); 
        h[i] = (a[i]==MX); 
        if(h[i]) NH++; 
    } 
    maketree(rt,0,n+1); 
    update(0,rt,0,n+1,n+1,0); 
    for(int i=n;i>=1;i--) { 
        int r0 = query(0,rt,0,n+1,a[i]+1,n+1); 
        int r1 = query(1,rt,0,n+1,a[i]+1,n+1); 
        if(h[i]) { 
            update(0,rt,0,n+1,a[i],r0+2); 
            update(1,rt,0,n+1,a[i],r1+2);             
        } else { 
            update(0,rt,0,n+1,a[i],r1+1); 
            update(1,rt,0,n+1,a[i],r0+1);             
        } 
    //	cerr<<r0<<' '<<r1<<endl;
    } 
    int cnt0 = 0 , cnt1 = 0 , max0 = 0 ,max1 = 0; 
    if(!isok(cnt0,cnt1,max0,max1,NH)) { 
        puts("-1"); return 0; 
    } 
    for(int i=1;i<=n;i++) { 
        update(0,rt,0,n+1,a[i],-inf); 
        update(1,rt,0,n+1,a[i],-inf);
        NH -= h[i]; 
        if(isok(cnt0+(a[i]>max0),cnt1,max(max0,a[i]),max1,NH)) { 
            cnt0 = cnt0 + (a[i]>max0);
            max0 = max(max0,a[i]); 
            putchar('0'); 
        } else { 
            cnt1 = cnt1 + (a[i]>max1); 
            max1 = max(max1,a[i]); 
            putchar('1'); 
        }
    } 
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBeginnerContest055
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            int n = int.Parse(szLine);
            long div = (long)Math.Pow(10, 9) + 7;

            long power = 1;
            for( int i=1;i<=n;++i)
            {
                if(power >= div)
                {
                    power = power % div;
                }
                power *= i;
            }

            long result = power % div;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0, x = 0;
  rep(i, n) {
    x += (s[i] == 'I' ? 1 : -1);
    ans = max(ans, x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    A, B, K = map(int, readline().split())
    left = set(list(range(A, min(A+K, B+1))))
    right = set(list(range(B, max(B-K, A-1), -1)))
    ans = list(left | right)
    ans.sort()
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w;
  cin>>h>>w;
  vector<string> c(h);
  
  for (int i=0;i<h;i++) {
    cin >> c[i];
  }
  
  
  for (int i=0;i<h;i++) {
    cout << c[i] << endl;
    cout << c[i] << endl;
  }
  
  
  
}

Measured memory_bytes: 256
N, M, X = map(int, input().split(' '))
price, exp = [], [ [] for i in range(N) ]
rst = -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_comb, exp_comb, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range (N):
        if i >> j & 1:
            price_comb.append(price[j])
            exp_comb.append(exp[j])
    for s in exp_comb:
        for t in range(M):
            exp_sum[t] += s[t]
    cnt_ls = [ x for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_comb)
        else:
            rst = min(rst, sum(price_comb))
print(rst)

Measured memory_bytes: 9224
#include <iostream>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;

    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '?') {
            s[i] = 'D';
        }
    }

    std::cout << s << std::endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int a, b; cin >> a >> b;
	cout << max({ 2 * a - 1,2 * b - 1,a + b }) << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
import sys

rl = sys.stdin.readline


class UnionFind:
    def __init__(self, n: int):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x: int):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x: int, y: int):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[y] < self.parents[x]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x: int):
        return -self.parents[self.find(x)]
    
    def same(self, x: int, y: int):
        return self.find(x) == self.find(y)
    
    def members(self, x: int):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def solve():
    N, M = map(int, rl().split())
    uf = UnionFind(N)
    for _ in range(M):
        x, y, _ = map(lambda z: int(z) - 1, rl().split())
        uf.union(x, y)
    print(uf.group_count())


if __name__ == '__main__':
    solve()


Measured memory_bytes: 63240
#include <stdio.h>

int main(){
   int i,n,l,r,a;
   char s[200001];
    
   scanf("%d",&n);
   scanf("%s",s);
   for (l=r=i=0;i<n;i++)
     if (s[i]=='.') r++;
   a=r;
   for (i=0;i<n;i++) {
     if (s[i]=='.') r--;
     else           l++;
     if (r+l<a) a=r+l;
   }
   printf("%d\n",a);
   return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5, NO_OF_ENDINGS = 2, WITH_MULTIPLIER = 0, WITHOUT_MULTIPLIER = 1;
long long sum_till[MAX_N][NO_OF_ENDINGS];

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

    vector <long long> A(no_of_elements + 1);
    for(int i = 1; i <= no_of_elements; i++)
        cin >> A[i];

    sum_till[1][WITHOUT_MULTIPLIER] = A[1], sum_till[1][WITH_MULTIPLIER] = A[1];
    sum_till[2][WITH_MULTIPLIER] = -A[1] - A[2], sum_till[2][WITHOUT_MULTIPLIER] = A[1] + A[2];
    for(int i = 3; i <= no_of_elements; i++)
    {
        long long max_without_last_2 = max(sum_till[i - 2][WITHOUT_MULTIPLIER], sum_till[i - 2][WITH_MULTIPLIER]);

        sum_till[i][WITHOUT_MULTIPLIER] = A[i] + max(A[i - 1] + max_without_last_2, sum_till[i - 1][WITH_MULTIPLIER]);

        sum_till[i][WITH_MULTIPLIER] = -A[i] + max(-A[i - 1] + max_without_last_2, sum_till[i - 1][WITH_MULTIPLIER] + 2*A[i - 1]);
    }

    long long answer = max(sum_till[no_of_elements][WITH_MULTIPLIER], sum_till[no_of_elements][WITHOUT_MULTIPLIER]);
    cout << answer;

    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;


signed main() {
    quickie
    int n ;
    cin >> n ;
    int a[n] ;
    int s = 0 ;
    mi m ;
    rep(i, 0, n) {
        cin >> a[i] ;
        s += a[i] ;
        m[a[i]]++ ;
    }
    int q ;
    cin >> q ;
    while(q--) {
        int b, c; 
        cin >> b >> c ;
        int xx = m[b] ;
        m[c] += xx ;
        int yy = xx*b ;
        int zz = xx*c ;
        s -= yy ;
        s += zz ;
        cout << s << "\n" ;
        m[b] = 0 ;
    }
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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


Measured memory_bytes: 10304
#include <bits/stdc++.h>
using namespace std;
int cuts(const vector<vector<int> > &grid, const int &mask,
		 const int &h, const int &w, const int &k)
{
	vector<int> cuts;
	for (int i = 0; i < h - 1; ++i)
		if (mask & (1 << i))
			cuts.push_back(i);
	cuts.push_back(10);
	vector<int> pieces(cuts.size());
	int c(0);
	for (int j = 0; j < w; ++j)
	{
		int x(0);
		for (int i = 0; i < h; ++i)
			pieces[i == cuts[x] ? (x++) : x] += grid[i][j];
		for (int n = 0; n < pieces.size(); ++n)
		{
			if (pieces[n] > k)
			{
				c++;
				memset(&pieces[0], 0, 4 * pieces.size());
				x = 0;
				for (int i = 0; i < h; ++i)
				{
					if (pieces[x] == k && grid[i][j])
						return -1;
					pieces[i == cuts[x] ? (x++) : x] += grid[i][j];
				}
			}
		}
	}
	return c;
}
int main()
{
	int h, w, k;
	char c;
	cin >> h >> w >> k;
	vector<vector<int> > grid(h, vector<int>(w));
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
		{
			cin >> c;
			grid[i][j] = c - '0';
		}
	int hs(1 << (h - 1)), ans(h + w - 2);
	for (int mask = 0; mask < hs; ++mask)
	{
		int res = cuts(grid, mask, h, w, k);
		if (res >= 0)
			ans = min(ans, res + __builtin_popcount(mask));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n+k,0),b(n+k,9000000000);
  b[0]=0;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++){
    for(int j=1;j<=k;j++){
      b[i+j]=min(b[i+j],abs(a[i]-a[i+j])+b[i]);
    }
  }
  cout<<b[n-1];
}

Measured memory_bytes: 1792
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> a(3*N);
    vector<ll> L(N+1),R(N+1);
    REP(i,3*N) cin>>a[i];
    priority_queue<ll,vector<ll>,greater<ll>> zenhan;
    priority_queue<ll> kouhan;
    ll tmp=0;
    REP(i,N){
        tmp+=a[i];
        zenhan.push(a[i]);
    }
    L[0]=tmp;
    tmp=0;
    REP(i,N){
        tmp+=a[3*N-i-1];
        kouhan.push(a[3*N-i-1]);
    }
    R[N]=tmp;
    ll tmp_a;
    REP2(i,1,N+1){
        //前半
        tmp_a=zenhan.top();
        if(a[N-1+i]>tmp_a){
            zenhan.pop();
            zenhan.push(a[N-1+i]);
            L[i]=L[i-1]+a[N-1+i]-tmp_a;
        }else{
            L[i]=L[i-1];
        }

        //後半
        tmp_a=kouhan.top();
        if(a[2*N-i]<tmp_a){
            kouhan.pop();
            kouhan.push(a[2*N-i]);
            R[N-i]=R[N-i+1]+a[2*N-i]-tmp_a;
        }else{
            R[N-i]=R[N-i+1];
        }
    }

    ll ans=-INF;
    REP(i,N+1){
        ans=max(ans,L[i]-R[i]);
    }
    cout<<ans<<endl;

}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n;
    cin >> n;
    vector<ll> A(n);
    for (ll &x : A) cin >> x;
    vector<ll> B(n);
    for (ll &x : B) cin >> x;
    vector<ll> C(n);
    for (ll &x : C) cin >> x;

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

    ll cnt = 0;
    for (int i = 0; i < n; i++) { // 真ん中のループ
        ll AtoB = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll BtoC = n - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
        cnt += AtoB * BtoC;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			

void solve()
{  string s;
   cin>>s;
   cout<<(s[2]==s[3] && s[4]==s[5]? "Yes":"No")<<endl;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
edge=[0]*(n+1)
ans=0
edge[0]=1
for i in range(1,n):
    edge[i]=edge[i-1]*2-a[i]
for i in range(n-1,-1,-1):
    bcnt=edge[i+1]+a[i+1]
    if bcnt//2+bcnt%2>edge[i]:
        ans=-1
        break
    if bcnt<edge[i]:
        edge[i]=bcnt
if n==0:
    if a[0]!=1:
        ans=-1
    else:
        edge[0]=0
elif a[0]>0:
    ans=-1
if ans!=-1:
    ans=sum(edge)+sum(a)
print(ans)

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


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

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

int MOD = (int) 1e9 + 7;

auto solve() {
    int N, M;
    cin >> N >> M;

    vector<vi> d(M);
    REP(i, M) {
        int k;
        cin >> k;
        REP(j, k) {
            int s;
            cin >> s;
            d[i].push_back(s-1);
        }
    }

    vi p(M);
    REP(i, M) cin >> p[i];

    int ans = 0;
    int S = 1 << N;
    REP(i, S) {
        bool ok = true;
        REP(j, M) {
            int c = 0;
            for (auto &&e:d[j]) {
                if (((i >> e) & 1) != 0) {
                    c++;
                }
            }
            
            if (c % 2 != p[j]) {
                ok = false;
                break;
            }
        }

        if(ok) {
            ans++;
        }
    }

    return ans;
}


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

    cout << solve() << endl;
//    solve();
//    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}



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


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	i64 c;
	vector<i64> xs;
	vector<i64> vs;

	scanf("%d%lld", &n, &c);
	xs.resize(n);
	vs.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%lld%lld", &xs[i], &vs[i]);

	vector<i64> cw_sum(n), ccw_sum(n);
	vector<i64> cw_sum_max(n), ccw_sum_max(n);

	cw_sum[0] = vs[0] - xs[0];
	cw_sum_max[0] = cw_sum[0];
	for(int i = 1; i < n; ++i) {
		cw_sum[i] = cw_sum[i - 1] + (vs[i] - (xs[i] - xs[i - 1]));
		cw_sum_max[i] = max(cw_sum_max[i - 1], cw_sum[i]);
	}

	ccw_sum[n - 1] = vs[n - 1] - (c - xs[n - 1]);
	ccw_sum_max[n - 1] = ccw_sum[n - 1];
	for(int i = n - 2; i >= 0; --i) {
		ccw_sum[i] = ccw_sum[i + 1] + (vs[i] - (xs[i + 1] - xs[i]));
		ccw_sum_max[i] = max(ccw_sum_max[i + 1], ccw_sum[i]);
	}

	i64 ans = 0;

	for(int i = 0; i < n; ++i) {
		i64 x = cw_sum[i];
		i64 y = (i + 1 < n) ? ccw_sum_max[i + 1] : 0LL;
		i64 t = x + max(y - xs[i], 0LL);
		ans = max(ans, t);
	}

	for(int i = n - 1; i >= 0; --i) {
		i64 x = ccw_sum[i];
		i64 y = (i - 1 >= 0) ? cw_sum_max[i - 1] : 0LL;
		i64 t = x + max(y - (c - xs[i]), 0LL);
		ans = max(ans, t);
	}

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 4992
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>

using namespace std;

int main()
{
  long long a[112345]={};
  long long b[112345]={};
  long long n=0;
  long  i=0;
  long long tmp=0;
  cin>>n;
  for(i=1;i<=n;i++)
    cin>>a[i]>>b[i];
  for(i=n;i>=1;i--)
    {
      a[i]+=tmp;
      tmp+=(b[i]-a[i]%b[i])%b[i];
    }
  cout<<tmp<<endl;
}





Measured memory_bytes: 2048
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N, p, sum = 0, sum2 = 0;
    fscanf(stdin, "%d", &N);
    for (int i = 0; i < N; i++) {
        fscanf(stdin, "%d", &p);

        if (p == i + 1) {
            sum2++;
        } else {
            if (sum2 >= 2) {
                if (sum2 % 2 == 1) {
                    sum += sum2 / 2 + 1;
                } else {
                    sum += sum2 / 2;
                }
            } else if(sum2 == 1) {
                sum++;
            }
            sum2 = 0;
        }
    }
    if (sum2 > 0) {
        if (sum2 % 2 == 1) {
            sum += sum2 / 2 + 1;
        } else {
            sum += sum2 / 2;
        }
    }
    cout << sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string n;
    cin >> n;
    bool ans = n[0] == n[2];

    cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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 RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    string S;
    cin >> N >> S;
    REP(i, S.size()) {
        cout << (char)((S[i] - 'A' + N) % 26 + 'A');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s, t, ans;
    cin>>s>>t;
    for(int i=0; i<n; i++)
	{
    	ans.pb(s[i]);
    	ans.pb(t[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256