akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int n=0;
    cin >> n;
    int x[n],y[n];
    rep(i,n)cin >> x[i] >> y[i];
    int cur[n];
    rep(i,n)cur[i]=i;
    long double dict=0.0,sum=0.0;
    do{
        rep(i,n-1){
            long double a = pow((double)x[cur[i]]-(double)x[cur[i+1]],2);
            long double b = pow((double)y[cur[i]]-(double)y[cur[i+1]],2);
            dict += pow(a+b,0.5);
        }
        sum+=dict;
        dict = 0;
    }while(next_permutation(cur,cur+n));

    int factorial = 1;
    rep2(i,2,n+1)factorial*=i;
    cout << fixed << setprecision(10) << sum / factorial << endl;

    return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
int v[110],a[110],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),v[a[i]]++;
	int x=*max_element(a+1,a+n+1),y=0;
	for(int i=1;i<=n;++i)if(a[i]==x)y++;
	if(y<=1)return puts("Impossible"),0;
	v[x]-=2;
	for(int i=1;i<x;++i)
		if(v[max(i,x-i)]<1)return puts("Impossible"),0;
		else v[max(i,x-i)]--;
	for(int i=1;i<(x+1)/2+1;++i)if(v[i])return puts("Impossible"),0;
	puts("Possible");
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int n;
  scanf("%d",&n);
  int waru = 0,m = n;
  
  
  for(int i = 0;i < 10;i ++){
    waru += n%10;
    int temp = n;
    n = n/10;
  }
  
    if(m%waru==0){
      printf("Yes");
    }
  else{
    printf("No");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

string sorting(string s){
    vector<char> ss(s.size());
    for (ll i=0;i<s.size();i++){
        ss[i]=s[i];
    }
    sort(ss.begin(),ss.end());
    for (ll i=0;i<s.size();i++){
        s[i]=ss[i];
    }
    return s;
}
int main() {
    string s,t,t2;
    cin >> s >> t;
    s=sorting(s);
    t=sorting(t);
    t2=t;
    for(ll i=0;i<t.size();i++){
        t2[i]=t[t.size()-1-i];
    }
    for(ll i=0;i<min(s.size(),t.size());++i){
        if (t2[i]>s[i]){
            cout << "Yes" << endl;
            return 0;
        }
        if (t2[i]<s[i]){
            cout << "No" << endl;
            return 0;
        }
        if (i==min(s.size(),t2.size())-1){
            if (s.size()>=t2.size()){
                cout << "No" << endl;
                return 0;
            }else{
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    return 0;
}


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


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

using namespace std;

int main() {
	int n,k,x;
	scanf("%d %d", &n, &k);
	int pre_data[200005];
	memset(pre_data, 0, sizeof(pre_data));
	vector<int>data;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		pre_data[x]++;
	}
	for(int i=1;i<=200000;i++){
		if(pre_data[i]>0)
			data.push_back(pre_data[i]);
	}
	sort(data.begin(),data.end());
	
	int ans=0, j=0;
	while (data.size()>k){
		ans+=data[j++];
		k++;
		// printf("%d %d\n",data.size());
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> color(9);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    if(a<3200) color.at(a/400)++;
    else color.at(8)++;
  }
  int ans=0;
  for(int i=0; i<8; i++){
    if(color.at(i)>0) ans++;
  }
  
  int ansmin = max(ans, 1);
  int ansmax = ans+color.at(8);
  cout << ansmin << ' ' << ansmax << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[]A = new int[N];
		int[]B = new int[M];
		string[] str2 = Console.ReadLine().Split();
		string[] str3 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		for(var i=0;i<M;i++){
			B[i] = int.Parse(str3[i]);
		}
		Array.Sort(A,(x,y)=>y-x);
		Array.Sort(B,(x,y)=>y-x);
		int C = N*M;
		int a1 = 0;
		int a2 = 0;
		long ans = 1;
		long mod = 1000000007;
		while(C>0){
			int f1 = 0;
			if(a1<N && A[a1]==C){
				f1 = 1;
				a1++;
			}
			int f2 = 0;
			if(a2<M && B[a2]==C){
				f2 = 1;
				a2++;
			}
			if(f1==0 && f2==0){
				ans = ans * (a1*a2-(N*M-C));
			} else if(f1==0){
				ans = ans * a1;
			} else if(f2==0){
				ans = ans * a2;
			}
			ans %= mod;
			C--;
		}
        Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11240
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

string s;
bool ck(char x){
    if(x =='A' || x == 'T' || x =='C' || x=='G')return true;
    else return false;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll ans = 0;
    ll tmp = 0;
    cin>>s;
    rep(i,s.size()){
        tmp = 0;
        if(ck(s[i])){
            tmp = 1;
            for(int j = i+1;j<s.size();j++){
                if(ck(s[j]))tmp++;
                else {
                    chmax(ans,tmp); 
                    tmp = 0;
                    break;
                }
            }
            chmax(ans,tmp);
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
//12:31-12:35
const ll MAX_N=300,INF=1e18;
ll N,M;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
vector<P> G[MAX_N];
P dst[MAX_N][MAX_N];
ll Q,L;
void dijkstra(ll s){
	REP(v,N)dst[s][v]=P(INF,0);
	dst[s][s]=P(0,-L);
	priority_queue<PP,vector<PP>,greater<PP> > pque;
	pque.push(PP(dst[s][s],s));
	while(!pque.empty()){
		PP pp=pque.top();
		pque.pop();
		ll v=pp.second;
		if(dst[s][v]<pp.first)continue;
		for(auto e:G[v]){
			P nd;
			if(e.second<=-dst[s][v].second){
				nd=dst[s][v];
				nd.second+=e.second;
			}else{
				nd=dst[s][v];
				nd.first++;
				nd.second=-(L-e.second);
			}
			if(nd<dst[s][e.first]){
				dst[s][e.first]=nd;
				pque.push(PP(dst[s][e.first],e.first));
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>L;
	REP(i,M){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		if(c<=L){
			G[a].push_back(P(b,c));
			G[b].push_back(P(a,c));
		}
	}
	REP(i,N){
		dijkstra(i);
	}
	cin>>Q;
	REP(i,Q){
		ll s,t;
		cin>>s>>t;
		s--;
		t--;
		cout<<(dst[s][t]==P(INF,0)?-1:dst[s][t].first)<<endl;
	}
}


Measured memory_bytes: 5672
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;

#define row 1001333
#define col 20

char H[row][col];

ll h1(ll key){
	return key%row;
}

ll h2(ll key){
	return 1+(key%(row-1));
}

ll chtonum(char s){
	if(s=='A') return 1;
	if(s=='C') return 2;
	if(s=='G') return 3;
	if(s=='T') return 4;
	return 0;
}

ll get_key(char s[]){
	ll sum=0,p=1;
	int len=strlen(s);
	for(ll i=0;i<len;i++){
		sum+=p*chtonum(s[i]);
		p*=5;
	}
	return sum;
}

void insert(char s[]){
	ll key,h;
	key=get_key(s);
	ll i =0;
	while(1){
		h=(h1(key)+i*h2(key))%row;
		if(strcmp(H[h],s)==0) return ;//这个元素字典里已经有了
		else if (strlen(H[h])==0){
			strcpy(H[h], s);//如果该位置没有别的值，就把这个元素插进去
			return ;
		} 
		i++;//如果这个i对应的h的位置已经有元素了，那么继续寻找下一个i对应的位置
	}
}

bool find(char s[]){
	ll key,h;
	key=get_key(s);
	ll i=0;
	while(1){
		h=(h1(key)+i*h2(key))%row;
		if(strcmp(H[h],s)==0) return true;//如果找到了该元素
		else if (strlen(H[h])==0) return false;
		i++;
	}
	return false;
}

int main (){
	int n;
	char c[20],s[20];
	for(int i = 0;i<row;i++) H[i][0]='\0'; //把数组初始化 方便比较
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		cin>>c>>s;
		if(c[0]=='i') insert(s);
		else {
			if(find(s)) cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 22788
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	if (N > K) ans = K * X + (N - K) * Y;
	else ans = N * X;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int A, B, C, K;
	int i;
	int wa = 0;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &K);
	for (i = 0; i < K; i++) {
		if (i < A)
			wa++;
		else {
			if (i < A+B)
				wa += 0;
			else {
				if (i < A+B+C)
					wa -= 1;
			}
		}
	}
	printf("%d",wa);
	return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int A[3][3];
int b[10];
bool appear[3][3];

void input() {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    cin >> N;
    for(int i = 0; i < N; i++) cin >> b[i];
}

void solve() {
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            appear[i][j] = false;
            for(int k = 0; k < N; k++) {
                if(A[i][j] == b[k]) appear[i][j] = true;
            }
        }
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        bool ok = true;
        for(int j = 0; j < 3; j++) {
            ok &= appear[i][j];
        }
        if(ok) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        bool ok = true;
        for(int j = 0; j < 3; j++) {
            ok &= appear[j][i];
        }
        if(ok) ANS = "Yes";
    }
    bool ok = true;
    for(int i = 0; i < 3; i++) {
        ok &= appear[i][i];
    }
    if(ok) ANS = "Yes";
    ok = true;
    for(int i = 0; i < 3; i++) {
        ok &= appear[i][2-i];
    }
    if(ok) ANS = "Yes";
    cout << ANS << endl;
    return;
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

seq_sum = 0
sign = 1
count_1 = 0
for i in range(n):
    if A[i] * sign * (-1) > seq_sum * sign:
        seq_sum += A[i]
    else:
        count_1 += abs(sign * (-1) - (seq_sum + A[i]))
        seq_sum += A[i] + (sign * (-1) - (seq_sum + A[i]))
    sign = sign * (-1)

seq_sum = 0
sign = -1
count_2 = 0
for i in range(n):
    if A[i] * sign * (-1) > seq_sum * sign:
        seq_sum += A[i]
    else:
        count_2 += abs(sign * (-1) - (seq_sum + A[i]))
        seq_sum += A[i] + (sign * (-1) - (seq_sum + A[i]))
    sign = sign * (-1)

print(min(count_1, count_2))

Measured memory_bytes: 14468
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  string s; cin >> s;
  int ans=0;
  int  n= s.size();
  rep(i,0,s.size()) if(s[i]=='0') ans++;
  cout << min(2*ans,(n-ans)*2) << endl;
 }

Measured memory_bytes: 512
def main():
    while True:
        n,q = map(int,input().split())
        if not n and not q:
            return
        res = [0 for _ in range(1000)]
        for _ in range(n):
            for m in list(map(int,input().split()))[1::]:
                res[m] += 1
        ans = max(res)
        if ans < q:
            print(0)
        else:
            print(res.index(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5632
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int s;
	cin >> s;
	int a=s/100, b=s%100;
	if(1<=a && a<=12 && 1<=b && b<=12) cout << "AMBIGUOUS" << endl;
	else if(1<=a && a<=12) cout << "MMYY" << endl;
	else if(1<=b && b<=12) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int A[200];
  
  int mim=10000000000;
  
    for (int j=0;j<N;j++) {
      cin >> A[j];
      int times=0;
      
      while (A[j] % 2 == 0) {
        A[j] /= 2;
        times++;  
      }
      
      if (times < mim) {
       mim = times; 
      }
    }
  cout << mim << endl;
}

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

int main() {
    char input[11] = "";
    while (cin >> input) {
        for (int i = 0; i < 9; i++) {
            for (int j = 9; j > i; j--) {
                input[j] = (input[j] - '0' + input[j - 1] - '0') % 10 + '0';
            }
        }
        cout << input[9] << endl;
    }
}

Measured memory_bytes: 0
#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>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,m,c; cin >> n >> m >> c;

    std::vector<int> b(m);

    rep(i,m) cin>>b[i];

    int cnt = 0;

    rep(i,n){
        std::vector<int> a(m);
        rep(j,m) cin >> a[j];

        int ans=0;
        rep(j,m) ans+=a[j]*b[j];
        ans+=c;

        if(ans  > 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int A[3];

  for (int i = 0; i < 3; i++) {
    cin >> A[i];
  }

  int count = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = i + 1; j < 3; j++) {
        if (A[i] == A[j]) {
            count++;
        }
    }
  }

  if (count == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

int main(void) {
	int n,i,j,maxdif=0;
	scanf("%d*",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(j=0;j<i;j++){
			if(abs(a[i]-a[j])>maxdif){
				maxdif=abs(a[i]-a[j]);
			}
		}
	}
	printf("%d",maxdif);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0014
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	str	= Console.ReadLine();
				if( str == null ) {
					break;
				}
				
				var	d	= int.Parse( str );
				int	s	= 0;
				for( int x = 0; x < 600; x += d ) {
					s	+= x * x * d; 
				}
				Console.WriteLine( s );
			}
		}
	}
}

Measured memory_bytes: 5544
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL X, Y, Z, K;
	in >> X >> Y >> Z >> K;
	std::vector<LL>A(X), B(Y), C(Z);
	rep(i, X) in >> A[i];
	rep(i, Y) in >> B[i];
	rep(i, Z) in >> C[i];

	std::vector<LL>ab;
	rep(i, X) rep(j, Y) ab.push_back(A[i] + B[j]);
	std::sort(ab.rbegin(), ab.rend());
	while (ab.size() > K) ab.erase(ab.end() - 1);

	std::vector<LL>abc;
	rep(i, ab.size()) rep(j, C.size()) abc.push_back(ab[i] + C[j]);
	std::sort(abc.rbegin(), abc.rend());
	rep(i, K) out << abc[i] << std::endl;
}


Measured memory_bytes: 43240
import java.util.*;
        public class Main {
         
        	public static void main(String[] args) {
        		// TODO 自動生成されたメソッド・スタブ
        		Scanner sc = new Scanner(System.in);
              	String str1 = sc.next();
              	String str2 = sc.next();
              	String str3 = sc.next();
              	String z = str1.substring(0,1) + str2.substring(0,1) + str3.substring(0,1);
              System.out.println(z.toUpperCase());
            }
        }

Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	ll sum1=0,sum2=0;
	REP(i,n) sum1+=a[i];
	REP(i,n) sum2+=b[i];
	if(sum1>sum2) {
		cout<<"No"<<endl;
		return 0;
	}
	ll cnt1=sum2-sum1, cnt2=sum2-sum1;
	vector<ll> c(n);
	REP(i,n) c[i]=a[i]-b[i];
	REP(i,n) {
		if(c[i]<0) {
			ll buf=(abs(c[i])+1)/2;
			cnt1-=buf;
			c[i]+=buf*2;
		}
	}
	if(cnt1<0) {
		cout<<"No"<<endl;
		return 0;
	} else {
		c[0]+=2*cnt1;
	}
	REP(i,n) {
		cnt2-=c[i];
	}
	if(cnt2==0) {
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
#define fi(i,a,b) for(int i = a; i<b; i++)
#define fd(i,a,b) for(int i = a; i>=b; i--)
#define ll long long int
#define pii pair<int, int>
#define vi vector<int>
#define N 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
using namespace std;

//*************************************************************************************

void solve () {

    string s, n; cin>>s;
    fi(i, 0, s.length())
    {
        if(s[i] == 'B' && n.length()>=1)
        {
            n.pop_back();
        }
        else if(s[i] != 'B')
            n.push_back(s[i]);

    }
    cout<<n<<endl;
}

int main(){

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    IOS;

    int t=1;
    while(t--){solve();}
    return 0 ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int n,y=0;
    long long int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        y=i;
        if(i%3==0||i%5==0)
            y=0;
        sum+=y;
        
    }
    cout<<sum;
    
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int N; std::cin >> N;
    long long K; std::cin >> K;
    std::vector<int> A(N), reach(N+1);
    for(int i(0); i < N; ++i){
        std::cin >> A[i];
        --A[i];
    }
    std::vector<int> d(N, -1);
    d[0] = 0; reach[0] = 0;
    int cur(0), loop(INF), st(INF);
    for(int i(0); i < N; ++i){
        int nxt(A[cur]);
        if(d[nxt] != -1){
            st = d[nxt];
            loop = d[cur] + 1 - d[nxt];
            break;
        }
        reach[i+1] = nxt;
        d[nxt] = d[cur] + 1;
        cur = nxt;
    }
    int ans(-1);
    if(K <= st) ans = reach[K];
    else{
        int id;
        if(!loop) id = st;
        id = ((K-st) % loop);
        ans = reach[id + st];
    }
    std::cout << ans + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 5636
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    int n;
    cin>>n;
	cout<<3*n*n<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[200010];
bool cmp(int a, int b){
    return a > b;
}
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i ++){
        scanf("%d", &arr[i]);
    }
    sort(arr, arr + n, cmp);
    long long sum = 0;
    for(int i = k; i < n; i ++){
        sum += (long long)arr[i];
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cmath>

void sortInsertionG(int *a,size_t n,int g){
  /*gはインターバル*/
  int i,j,temp;
  for (i=g;i<n;i++){
    temp=a[i];
    j=i-g;
    while (j>=0&&a[j]>temp){
      a[j+g]=a[j];
      j-=g;
    }
    a[j+g]=temp;
  }
}
void sortShell(int *a,size_t n){
  /* g[m]=g[m+1]*3+1 */
  int i,m;
  m=std::log(2*n+1.0)/std::log(3.0);
  int g[m];
  for (i = 0; i < m; i++)g[i]=(std::pow(3,m-i)-1)/2;
  for (i = 0; i < m; i++) {
    sortInsertionG(a,n,g[i]);
  }
}

int main(){
  int n,k,i,ans=1000000000,temp;
  std::cin>>n>>k;
  int h[n];
  for (i=0;i<n;i++)std::cin>>h[i];
  sortShell(h,n);
  for (i=0;i<n-k+1;i++){
    temp=h[i+k-1]-h[i];
    if (ans>temp)ans=temp;
  }
  std::cout << ans << '\n';
}


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

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

    if (S[K-1] == 'A'){
        S[K-1] = 'a';
    }

    if (S[K-1] == 'B'){
        S[K-1] = 'b';
    }

     if (S[K-1] == 'C'){
        S[K-1] = 'c';
    }

    cout << S << endl;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for(ll i=(a); i<(b); i++)
#define FORD(i, a, b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

#define MOD 1000000007

ll n, m;
vvl graph;

vb visited;

ll dfs(ll node) {
    if(visited[node]) return 0;
    visited[node] = true;
    ll output = 1;
    for(ll neigh : graph[node]) {
        output += dfs(neigh);
    }
    return output;
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    graph = vvl(n);
    FOR(i, 0, m) {
        ll a, b; cin >> a >> b;
        a--; b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    visited = vb(n, false);
    ll output = 0;
    FOR(i, 0, n) {
        if(visited[i]) continue;
        output = max(output, dfs(i));
    }

    cout << output << endl;
}

Measured memory_bytes: 20292
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,A,B = LI()
if (A+B)%2==0:
    ans = (B-A)//2
else:
    count_move = min(A-1,N-B)
    ans = count_move+1
    ans += (B-A-1)//2
print(ans)


Measured memory_bytes: 2940
A = list(map(int, input().split()))
X = A[0]
Y = A[1]  

if Y % 2 == 0:
  YY = Y / 2
  if ((YY - X) >= 0):
    if ((2 * X - YY) >= 0):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll N, W, i, j, k;
    cin >> N >> W;
    vector<ll> v(N), w(N);

    for(i = 0; i < N;i++){
        cin >> v[i] >> w[i];
    }
    vector<pair<ll, ll> > H1, H2;
    ll m = N / 2;
    for(i = 0; i < 1 << m;i++){
        ll Wcnt = 0, Vcnt = 0;
        for(j = 0; j < m; j++) {
            if(i >> j & 1){
                Wcnt += w[j];
                Vcnt += v[j];
            }
        }
        H1.push_back(make_pair(Wcnt, Vcnt));
    }
    ll r = N - m;
    for(i = 0; i < 1 << r;i++){
        ll Wcnt = 0, Vcnt = 0;
        for(j = 0; j < r; j++) {
            if(i >> j & 1) {
                Wcnt += w[j + m];
                Vcnt += v[j + m];
            }
        }
        H2.push_back(make_pair(Wcnt, Vcnt));
    }
    sort(H2.begin(), H2.end());
    //cout << H1[2].first << endl;
    //cout << H2[2].second << endl;
    ll ret = 0;
    ll H1s = H1.size();
    ll H2s = H2.size();
    for(i = 1; i < H2s;i++){
        H2[i].second = max(H2[i - 1].second, H2[i].second);
    }
    for(i = 0; i < H1s; i++) {
        if(W - H1[i].first >= 0) {
            auto it = lower_bound(H2.begin(), H2.end(), make_pair(W - H1[i].first, ll(1e16)));
            if(it != H2.begin()) {
                --it;
                //cout << it->first << endl;
                ret = max(ret, it->second + H1[i].second);
            }
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 43744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
bool solve() {
  int n; cin >> n;
  if(n == 0) return false;
  vector<pair<ld, ld>> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.rbegin(), p.rend());
  int ans = 0;
  vector<P> l, r;
  for(int i=0;i<n;++i) {
    int cnt = 0;
    int now = 0;
    while(cnt < p[i].second) {
      int nxtl = now + p[i].first;
      for(int j=0;j<(int)(l.size());++j) {
        if(l[j].first < now && l[j].first <= nxtl && nxtl <= l[j].second) {
          nxtl = l[j].second;
        }
      }
      l.push_back({now, nxtl});
      now = nxtl;
      int nxtr = now + p[i].first;
      for(int j=0;j<(int)(r.size());++j) {
        if(r[j].first < now && r[j].first <= nxtr && nxtr <= r[j].second) {
          nxtr = r[j].second;
        }
      }
      r.push_back({now, nxtr});
      now = nxtr;
      cnt++;
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}



Measured memory_bytes: 3248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;



int main(void) {
  lli n, a[MAX];
  scanf("%lld", &n);
  rep(i, 0, n) scanf("%lld", &a[i]);

  lli sum[MAX] = {0};
  rep(i, 0, n) sum[a[i]]++;

  lli ans = 0;
  rep(i, 1, MAX) ans += sum[i] * (sum[i]-1) / 2;
  rep(i, 0, n) {
    printf("%lld\n", ans - (sum[a[i]] - 1));
  }
  return 0;
}


Measured memory_bytes: 5632
program main
  implicit none

  integer :: a, b, c

  read *, a, b, c

       if ( a == b .and. a /= c ) then
     print *, "Yes"
  else if ( a == c .and. a /= b ) then
     print *, "Yes"
  else if ( b == c .and. a /= b ) then
     print *, "Yes"
  else
     print *, "No"
  end if

end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string k;
    ll d;
    cin >> k >> d;
    ll n = len(k);
    // dp[figures][0:just, 1:smaller][surplus] = patterns
    vector<vector<vector<mint>>> dp(n + 1, vector<vector<mint>>(2, vector<mint>(d, 0)));
    dp[0][0][0] = 1;
    rep(i, n) {
        ll v = k[i] - '0';
        // just
        rep(j, d) {
            dp[i + 1][0][(j + v) % d] += dp[i][0][j];
        }
        // smaller
        rep(j, d) {
            rep(l, 10) {
                dp[i + 1][1][(j + l) % d] += dp[i][1][j];
                if (l < v) {
                    dp[i + 1][1][(j + l) % d] += dp[i][0][j];
                }
            }
        }
    }
    mint ans = dp[n][0][0] + dp[n][1][0] - 1;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 20156
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=4e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[MAXn][MAXn];

ll d[MAXn];

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP1(i,n)cin>>d[i];
    REP1(i,n)d[i] = d[i-1] + d[i];
    for(int ln = 2;ln <= n;ln ++)
    {
        for(int l = 1;l + ln - 1 <= n;l ++)
        {
            int r = l + ln - 1;
            dp[l][r] = INF;
            for(int k = l;k < r;k ++)
            {
                dp[l][r] = min(dp[l][r], dp[l][k] + dp[k+1][r]);
            }
            dp[l][r] += d[r] - d[l-1];
        }
    }
    cout<<dp[1][n]<<endl;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --n;
    int w = b - a;
    for (int i = 0; i <= n; ++i) {
        int l = i * -d + (n - i) * c;
        int r = i * -c + (n - i) * d;
        if (l <= w && w <= r) {
            cout << "YES\n";
            exit(0);
        }
    }
    cout << "NO\n";
}


Measured memory_bytes: 256
m[14][14];main(x,y,s,M){
	for(;~scanf("%d,%d,%d",&x,&y,&s);){
		m[x+2][y+2]++;m[x+1][y+2]++,m[x+3][y+2]++,m[x+2][y+1]++,m[x+2][y+3]++;
		if(s>1)m[x+1][y+1]++,m[x+3][y+1]++,m[x+1][y+3]++,m[x+3][y+3]++;
		if(s>2)m[x][y+2]++,m[x+4][y+2]++,m[x+2][y]++,m[x+2][y+4]++;
	}
	for(s=M=0,x=2;x<12;x++)for(y=2;y<12;M=M>m[x][y]?M:m[x][y],y++)if(!m[x][y])s++;
	printf("%d\n%d\n",s,M);
	exit(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    double xmin1,xmin2,xmax1,xmax2;
    xmin1=A/0.08;
    xmin2=B/0.1;
    xmax1=(A+1)/0.08;
    xmax2=(B+1)/0.1;
    double xmin,xmax;
    xmin = max(xmin1,xmin2);
    xmax = min(xmax1,xmax2);
    if((xmin-(int)xmin)<0.0000000000000000001){
        xmin = (int)xmin;
    }   else{
        xmin = (int)xmin+1;
    }
    if((xmax-(int)xmax)<0.000000000000000000001){
        xmax=(int)xmax-1;
    }   else{
        xmax=(int)xmax;
    }
    if((xmax-xmin)<0){
        cout<<-1;
    }   else{
        cout<<xmin;
    }
    return 0;
}

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

int main() {
  string V;
  char S;
  V = "aiueo";
  cin >> S;
  if (V.find(S) != string::npos ) {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
 
}

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int binpow(int base, int e, int mod) {
	int ret = 1;
	while(e) {
		if(e & 1)
			ret = (long long) ret * base % mod;
		base = (long long) base * base % mod;
		e >>= 1;
	}
	return ret;
}

int f(int val) {
	int ret = 0;
	while(val > 0) {
		int cnt = __builtin_popcount(val);
		val %= cnt;
		ret++;
	}
	return ret;
}	

int main() {
	fast();
	int n;
	string x;
	cin >> n >> x;
	int cnt = 0;
	for(char ch : x)
		cnt += (ch == '1');
	int sum0 = 0, sum1 = 0;
	if(cnt > 1) {
		for(int i = 0; i < n; i++)
			sum0 = (sum0 + (x[i] == '1') * binpow(2, n - 1 - i, cnt - 1)) % (cnt - 1);
	}
	for(int i = 0; i < n; i++)
		sum1 = (sum1 + (x[i] == '1') * binpow(2, n - 1 - i, cnt + 1)) % (cnt + 1);
	// debug(sum0, sum1);
	for(int i = 0; i < n; i++) {
		if(x[i] == '1') {
			if(cnt == 1) {
				cout << 0 << '\n';
				continue;
			}
			int val = ((sum0 - binpow(2, n - 1 - i, cnt - 1)) % (cnt - 1) + (cnt - 1)) % (cnt - 1);
			// debug(i, val);
			cout << f(val) + 1 << '\n';
		}
		else {
			if(cnt == 0) {
				cout << 1 << '\n';
				continue;
			}
			int val = (sum1 + binpow(2, n - 1 - i, cnt + 1)) % (cnt + 1);
			cout << f(val) + 1 << '\n';
		}
	}
}


Measured memory_bytes: 3768
# ABC128C

N,M=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(M)]
ps=list(map(int,input().split()))

cnt=0
for bit in range(2**N):
    c=1
    for i in range(M):
        ons=0
        for j in range(ks[i][0]):
            k=ks[i][j+1]-1
            if (bit>>k & 1):
                ons+=1
        if ons % 2 != ps[i]:
            c*=0
            break
    if c==1:
        cnt+=1
print(cnt)
                

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int N=1e6+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int n,a[N];
signed main()
{
	n=read();
	double sum=0;
	for(int i=1;i<=n;i++)
	{
		double x=read();
		sum=sum+1.0/x;
//		printf("%.5lf\n",sum);
	}
	sum=1.0/sum;
	printf("%.10lf\n",sum);
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int pn[] = {3, 5, 7, 11};

int cdn(int c)
{
  int cd = 1,
      i = 0;

  while (1 < c && i < 4)
  {
    int d = 0;
    while (c % pn[i] == 0)
    {
      d++;
      c /= pn[i];
    }
    cd *= (d + 1);
    i++;
  }
  if (1 < c)
    cd *= 2;

  return cd;
}

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;

  cin >> n;

  int cnt = 0;
  FOR(i, 105, n + 1)
  {
    if (i % 2 == 1 && cdn(i) == 8)
      cnt++;
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  int N,L,maxl,p=0,lr=0;
  cin >> N >> L;
  int a[N+2];
  a[0]=0;a[N+1]=0;
  for(int i=1;i<=N;i++) cin >> a[i];
  maxl=a[0];
  for(int i=1;i<=N;i++){
    if(max(a[i]+a[i-1],a[i]+a[i+1])>maxl){
      maxl=max(a[i]+a[i-1],a[i]+a[i+1]),p=i;
      if(a[i]+a[i-1]>a[i]+a[i+1]) lr=0;
      else lr=1;
    }
  }
  if(maxl<L) cout << "Impossible" << endl;
  else{
    cout << "Possible" << endl;
    if(lr==0){
      for(int i=1;i<=p-2;i++) cout << i << endl;
      for(int i=N-1;i>=p;i--) cout << i << endl;
      cout << p << endl;
    }
    else{
      for(int i=1;i<=p-1;i++) cout << i << endl;
      for(int i=N-1;i>=p+1;i--) cout << i << endl;
      cout << p << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> s;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        s.push_back({a, b});
    }
    vector<P> c;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        c.push_back({a, b});
    }
    vector<int> ans;
    for (int i = 0; i < N; ++i) {
        int mind = 999999999;
        int tmp = -1;
        for (int j = 0; j < M; ++j) {
            int d = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
            if (d < mind) {
                mind = d;
                tmp = j + 1;
            }
        }
        ans.push_back(tmp);
    }
    for (int i = 0; i < N; ++i) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
_,_,x,y = gets.chomp.split.map(&:to_i)
xary = gets.chomp.split.map(&:to_i)
yary = gets.chomp.split.map(&:to_i)

xary.sort!
yary.sort!
x = [x, xary[-1]].max
y = [y, yary[0]].min

if x < y
  puts "No War"
else
  puts "War"
end

Measured memory_bytes: 1788
import os, sys, re, math

S = input()
T = input()

sCount = [0] * 26
tCount = [0] * 26

for s in S:
    sCount[ord(s) - ord('a')] += 1
for t in T:
    tCount[ord(t) - ord('a')] += 1

sCount.sort()
tCount.sort()

print ('Yes' if sCount == tCount else 'No')


Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int64_t bi_count(int64_t *a, int64_t *b, int64_t x, int N)
{
  int64_t c = 0;
  for (int i = 0; i < N; i++)
  {
    int l = -1;
    int r = N;
    while (r - l > 1)
    {
      int m = (l + r) / 2;
      if (a[i] * b[m] > x)
        r = m;
      else
      {
        l = m;
      }
    }
    c += l + 1;
  }
  return c;
}

void arc37_c()
{
  int64_t N, K;
  cin >> N >> K;
  int64_t a[N];
  int64_t b[N];
  for (int64_t j = 0; j < N; j++)
    cin >> a[j];
  for (int64_t j = 0; j < N; j++)
    cin >> b[j];
  sort(b, b + N);
  int64_t count = 0;
  int64_t x = 0;
  int64_t right = pow(10, 18);
  int64_t left = 0;
  while (right - left > 1)
  {
    x = (left + right) / 2;
    count = bi_count(a, b, x, N);
    if (count >= K)
    {
      right = x;
    }
    else
    {
      left = x;
    }
  }
  cout << right << endl;
}

int64_t bi_high(int x, int *c, int N)
{
  int64_t lb = -1;
  int64_t ub = N;
  while (ub - lb > 1)
  {
    int64_t m = (lb + ub) / 2;
    if (c[m] <= x)
    {
      lb = m;
    }
    else
    {
      ub = m;
    }
  }
  return N - ub;
}
int64_t bi_low(int x, int *a, int N)
{
  int64_t lb = -1;
  int64_t ub = N;
  while (ub - lb > 1)
  {
    int64_t m = (lb + ub) / 2;
    if (a[m] >= x)
    {
      ub = m;
    }
    else
    {
      lb = m;
    }
  }
  return ub;
}
void abc77_c()
{
  int N;
  cin >> N;
  int a[N], b[N], c[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  for (int i = 0; i < N; i++)
    cin >> b[i];
  for (int i = 0; i < N; i++)
    cin >> c[i];
  sort(a, a + N);
  sort(c, c + N);
  int64_t count = 0;
  for (int i = 0; i < N; i++)
  {
    //int q = bi_high(b[i], c, N);
    //int p = bi_low(b[i], a, N);
    //cout << q << " " << p << endl;
    count += bi_high(b[i], c, N) * bi_low(b[i], a, N);
  }
  cout << count;
}
int main(void)
{
  //arc37_c();
  abc77_c();
  return 0;
}


Measured memory_bytes: 1408
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
const int inf=1e9+5;
int n,w;
ll a[105],b[105];
ll dp[105][100005];

ll recurse(int ind,int val)
{
    if(val<=0)
        return 0;
    if(ind>=n)
        return inf;
    if(dp[ind][val]!=-1)
        return dp[ind][val];
    dp[ind][val]=min(recurse(ind+1,val),recurse(ind+1,val-b[ind])+a[ind]);
    return dp[ind][val];
}

int main()
{ quick;

    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
   // cout<<"w:"<<w<<endl;
    fab(0,n,i)
    cin>>a[i]>>b[i];
   

    for(int i=1e5+2;i>=0;i--)
    {
        if(recurse(0,i)<=w)
        {
            cout<<i<<endl;
            return 0;
        }
    } 
    

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 85692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=1e6+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,u[N],cnt[N];

ll po(ll base,ll ti){
	if(!ti)return 1;
	ll tmp=po(base,ti/2);
	return (ti&1?tmp*tmp%MOD*base%MOD:tmp*tmp%MOD);
}

map<ll,ll> build(ll k){
	map<ll,ll> tmp;
	for(ll i=2;i*i<=k;i++){
		if(k%i==0){
			while(k%i==0)k/=i,tmp[i]++;
		}
	}
	if(k>1)tmp[k]++;
	for(auto i:tmp)cnt[i.X]=max(cnt[i.X],i.Y);
	return tmp;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP(i,n)cin>>u[i],build(u[i]);
	ll lcm=1,ans=0;
	REP(i,N)lcm=(lcm*po(i,cnt[i]))%MOD;
	REP(i,n){
		map<ll,ll> tm=build(u[i]);
		ll tmp=1;
		for(auto i:tm)tmp=tmp*po(po(i.X,MOD-2),i.Y)%MOD;
		ans=(ans+lcm*tmp%MOD)%MOD;
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 8192