akhauriyash/Code-Regression huggingface dataset:
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

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

    string ans = "";
    while (N != 0)
    {
        if (N % 2 != 0)
        {
            N--;
            ans = "1" + ans;
        }
        else
        {
            ans = "0" + ans;
        }
        N /= -2;
    }

    if (ans == "")
        ans = "0";
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def lscan; gets.split.map(&:to_i); end

n, d = lscan

vs = n.times.map{lscan}

ans = 0
vs.combination(2) do |v1, v2|
  r2 = v1.zip(v2).map{|y, z| (y-z)**2}.reduce(:+)
  ans += 1 if Math.sqrt(r2).to_i**2 == r2
end

p ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long n,ans; 
int s;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>0;--i) 
    {
    	if(n%i==0)
		{
            ans=n/i;
            break;
        }
    }
    while(ans>0)
	{ 
        ++s;
        ans/=10;
    }
    cout<<s;
    return 0;
}

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

int main(){
	int a[3];
	for(int i=0; i<3; i++) cin >> a[i];
	int ans = 0;
	
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(i!=j && i!= k && j!=k) ans = max(ans, a[i]*10 + a[j] + a[k]);
			}
		}
	}
	
	cout << ans << endl;
	
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 1050
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
#define x1 alsd
#define x2 SHFkad
#define y1 hasf
#define y2 Ldflkjgdjklshgsl
int x1, x2, y1, y2;
char s[MAXN];
int main() {
	scanf("%s", s+1);
	rep(i, 1, strlen(s+1)) 
		if(s[i] == 'N') y1 = 1;
		else if(s[i] == 'S') y2 = 1;
		else if(s[i] == 'E') x1 = 1;
		else if(s[i] == 'W') x2 = 1;
	puts(((y1^y2) || (x1^x2)) ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int num, i;
  long long int sum=0;
  scanf("%d", &num);
  for(i=1;i<=num;i++) {
    if(i%3!=0&&i%5!=0)
      sum+=i;
  }
  printf("%lld\n", sum);
  return 0;
}

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

// main
int main(){
   // 入力
    stack<string> S;
    string x, y, first, second;
    stringstream ss;

    getline(cin, x);
    ss << x;

    while(ss >> y){
        if (y == "+"){
            second =S.top();
            S.pop();
            first = S.top();
            S.pop();
            S.push( to_string(stoi(first) + stoi(second)) );
        }else if (y == "-"){
            second =S.top();
            S.pop();
            first = S.top();
            S.pop();
            S.push( to_string(stoi(first) - stoi(second)) );
        }else if (y == "*"){
            second =S.top();
            S.pop();
            first = S.top();
            S.pop();
            S.push( to_string(stoi(first) * stoi(second)) );
        }else if (y == "\n"){
            break;
        }else{
            S.push(y);
        }
    }

    cout << S.top() << "\n";

    return 0;
}





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

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

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

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

int main()
{
    char a, b;
    cin >> a >> b;
    int s = a - '0';
    int t = b - '0';
    if (t < s)
    {
        for (int i = 0; i < s; i++)
        {
            cout << t;
        }
        cout << endl;
    }
    else
    {
        for (int i = 0; i < t; i++)
        {
            cout << s;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll numm=0;
  ll sum=0;
  ll min_=LLONG_MAX;
  FORi(N){
    cin>>A[i];
    if(A[i]<0){
      numm++;
      A[i]=-A[i];
    }
    sum+=A[i];
    if(min_>A[i]){
      min_=A[i];
    }
  }
  if(numm%2==1){
    sum-=2*min_;
  }
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 120
#define INF 0x3f3f3f3f
#define MAX 10000
using namespace std;

int main()
{
    cin.sync_with_stdio(false);
    int n;
    cin>>n;
    int i=1000;
    while(i-n<0){i+=1000;}
    if(i-n==0) cout<<0<<endl;
    else cout<<i-n<<endl;

}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 1;										/* デバッグプリント 提出時は0 */
int main()
{
	int		i,n,l, ans = 0;
	
	scanf("%d %d", &n, &l);

	ans = n*l;
	for(i=1;i<n;i++) {
		ans += i;
	}

	if (l>=0) ans -= l;
	else {
		if (l+n-1<0) ans -= l + n -1;
	}
	
	printf("%d\n",ans);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
string s;
int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  cin >> s;
  for (int i = 0; i < 1 << 4; i++) {
    string t;
    if (i & 1) t += 'A';
    t += "KIH";
    if (i & 2) t += 'A';
    t += 'B';
    if (i & 4) t += 'A';
    t += 'R';
    if (i & 8) t += 'A';
    if (s == t) return cout << "YES" << '\n', 0;
  }
  cout << "NO" << '\n';
}

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

bool isACGT(string s) {
    bool acgt = true;
    for (int i=0; i<s.size(); i++) {
        if ((s[i]!='A') && (s[i]!='C') && (s[i]!='G') && (s[i]!='T')) acgt = false;
    }
    return acgt;
}

int main() {
    string S;
    cin >> S;

    int ans = 0;

    for (int i=0; i<S.size(); i++) {
        for (int len=1; len<=S.size()-i; len++) {
            string subs = S.substr(i, len);
            if (isACGT(subs)) ans = max(ans, (int) subs.size());
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    string s;
    cin >> s;
    if(s[0]=='7' or s[1]=='7' or s[2]=='7')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<ull> vul;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Sort(a) sort(a.begin(), a.end())

vector<vl> graph;
vector<bool> used;
ll dp[(ll)1e5][2];

pair<ll, ll> dfs(ll v) {
    used[v] = true;
    dp[v][0] = 1;
    dp[v][1] = 1;
    for (ll to : graph[v]) {
        if (!used[to]) {
            auto q = dfs(to);
            dp[v][0] = (dp[v][0] * (q.first + q.second)) % ((ll)1e9 + 7);
            dp[v][1] = (dp[v][1] * q.first) % ((ll)1e9 + 7);
        }
    }
    return { dp[v][0], dp[v][1] };
}

int main() {
    FAST_IO;
    ll N;
    cin >> N;
    graph.resize(N);
    used.resize(N);
    For(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    auto q = dfs(0);
    cout << (q.first + q.second) % ((ll)1e9 + 7) << '\n';
    return 0;
}

Measured memory_bytes: 15736
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int [] in = new int [9];        
        for(int i=0;i<9;i++){
                             in[i] = sc.nextInt();                           
                            }
        int b = sc.nextInt(); 
        int [] in2 = new int [b];
        for(int i=0;i<b;i++){
                             in2[i] = sc.nextInt();
                            }
		String s = "No";       
        for(int i=0;i<9;i++){                                               
        for(int j=0;j<b;j++){if(in[i]==in2[j]){in[i]=0;}
                            }
                            }
        if(in[0]+in[1]+in[2]==0 || in[3]+in[4]+in[5]==0 || in[6]+in[7]+in[8]==0 || in[0]+in[3]+in[6]==0
           || in[1]+in[4]+in[7]==0 || in[2]+in[5]+in[8]==0 || in[0]+in[4]+in[8]==0 || in[2]+in[4]+in[6]==0){s="Yes";}
		System.out.println(s);
	}
}


Measured memory_bytes: 22996
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
using namespace std;
template<class _T>inline void read(_T &_a)
{
	bool f=0; char _c=getchar(); _a=0;
	while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
	while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
	if(f) _a=-_a;
}

int n,m,a,sum;

int main()
{
	read(n); read(m);
	for(int i=1;i<=m;++i) { read(a); sum+=a; }
	if(sum>n) printf("-1");
	else printf("%d",n-sum);
	return 0;
}

Measured memory_bytes: 3760
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


N = int(input())
X = [int(x) for x in input().split()]
ans = 9999999999
su = 0

X.sort()

xm = max(X)

for i in range(xm+1):
  for j in range(N):
    su += (X[j]-i)**2
  ans = min(ans, su)
  su = 0


print(ans)



Measured memory_bytes: 40684
n = int(input())
a = [int(i) for i in input().split()]
sumA = 0
sumli = sum(a)
ans = 1000000000
for i in range(n-1):
    sumA += a[i]
    sumB = abs(sumli - sumA*2)
    ans = min(ans,sumB)
if n == 2:
    print(abs(a[0]-a[1]))
else:
    print(ans)

Measured memory_bytes: 24928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  ll a[n],b[n],c[n];
  for(ll i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
  ll dp[3][n];
  dp[0][0]=a[0];
  dp[1][0]=b[0];
  dp[2][0]=c[0];
  ll i;
  for(i=1;i<n;i++)
  {
    dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
    dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
    dp[2][i] = c[i] + max(dp[1][i-1],dp[0][i-1]);
  }
  cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<"\n";
}

Measured memory_bytes: 4992
K, A, B = map(int,input().split())
if 1 + K < A or B - A <= 2:
  print(1 + K)
  exit()
K -= (A - 1)
ans = A
if K % 2 == 1:
  ans += 1
ans += (B - A) * (K // 2)
print(ans)

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

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

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

  auto f = [](vector<int> a) {
    const int n = a.size();
    vector<int> b(n, 1);
    multiset<int> bag;
    for (int i = 0; i < n; ++i) {
      while (bag.size() && *bag.begin() < i) bag.erase(bag.begin());
      b[i] += bag.size();
      bag.insert(i + a[i]);
    }
    bag.clear();
    for (int i = n - 1; ~i; --i) {
      while (bag.size() && *--bag.end() > i) bag.erase(--bag.end());
      b[i] += bag.size();
      bag.insert(i - a[i]);
    }
    return b;
  };

  for (int i = 0; i < K; ++i) {
    A = f(A);
    if (all_of(A.begin(), A.end(), [&](int v) { return v == N; })) {
      // cerr << i + 1 << endl;
      break;
    }
  }

  for (int j = 0; j < N; ++j) {
    cout << A[j] << " \n"[j + 1 == N];
  }

  return 0;
}


Measured memory_bytes: 15312
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

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

ordered_set<ll> ods;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll dp[1<<22];

void solve(ll t)
{
    // cout<<"Case #"<<t<<":\n";
    ll n;
    cin>>n;
    ll a[n][n];
    repf(i,0,n) repf(j,0,n) cin>>a[i][j];
    dp[0]=1;
    repf(i,0,n)
    {
        repf(j,0,1<<n)
        {
            if(__builtin_popcount(j)!=i) continue;
            repf(msk,0,n)
            {
                if(a[i][msk] && !((1<<msk)&j))
                {
                    dp[j+(1<<msk)]=(dp[j+(1<<msk)]+dp[j])%mod;
                }
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    ll tt=1;
    while(t--)
    {
        solve(tt);
        tt++;
    }
}     

Measured memory_bytes: 18688
using System;

namespace GCD
{
    class Program
    {
        private static int Gcd(int[] i)
        {
            int a = i[0], b = i[1];
            if (a < b)
            {   
                int t = a;
                a = b;
                b = t;
            }
            while(true)
            {
                int c = a % b;
                if(c == 0) return b;
                a = b;
                b = c;
            }
        }
        static void Main()
        {
            Console.WriteLine(Gcd(Array.ConvertAll(Console.ReadLine().Split(), int.Parse)));
        }
    }
}

Measured memory_bytes: 9252
#include <iostream>
#include <algorithm>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        String S = reader.next();

        int ans = N;
        for (int i=1; i<N; i++) {
            if (S.charAt(i-1) == S.charAt(i)) ans--;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



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

int main(){
  int l[4],r[4];
  double left,right;

  for(int i=0;i<4;i++){
    l[i] = 0;
    r[i] = 0;
  }

  while(cin >> left >> right){
    if(left>=1.1)l[0]++;
    else if(left>=0.6)l[1]++;
    else if(left>=0.2)l[2]++;
    else l[3]++;
    if(right>=1.1)r[0]++;
    else if(right>=0.6)r[1]++;
    else if(right>=0.2)r[2]++;
    else r[3]++;
  }

  for(int i=0;i<4;i++)cout << l[i] << " " << r[i] << endl;
}

Measured memory_bytes: 0
#include<cstdio>

using namespace std;

int main(){
	int n, cnt = 1, x = 0;
	scanf("%d", &n);
	while(1){
		x += cnt;
		if(n <= x) break;
		cnt++;
	}
	int t = x - n;
	for(int i = 1; i <= cnt; i++){
		if(i != t){
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int func(vector<int> v,int k)
{
  int n=v.size();
  int i,j;
  int dp[n];
  for(i=0;i<n;i++)
    dp[i]=INT_MAX;
    dp[0]=0;

  for(i=0;i<n;i++)
  {
    for(j=1;j<=k&&(i+j)<n;j++)
    {
      dp[i+j]=min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
    }
  }
  return dp[n-1];
}
int main()
{
  int n,k;
  cin>>n>>k;
  int i;
  vector<int> v;
  for(i=0;i<n;i++)
  {
    int a;
    cin>>a;
    v.push_back(a);
  }
  cout<<func(v,k)<<"\n";
}


Measured memory_bytes: 1528
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0)puts("No");
	else if (4 * a * b < (c - a - b) * (c - a - b))puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
int n, m;
int A[1010];
int main(){
	scanf("%d %d", &n, &m);
	int t = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &A[i]);
		t += A[i];
	}
	int s = 0;
	for(int i = 0; i < n; i++){
		if(A[i] >= t/(4*m) + (bool)(t%(4*m))) s++;
	}
	printf("%s\n", s >= m ? "Yes" : "No");
	return 0;
}

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

using namespace std;

template <typename T>
T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }

template <typename T>
vector<pair<T, int>> factorize(T n) {
	vector<pair<T, int>> ret;

	for (T p = 2; p * p <= n; ++p) {
		if (n % p != 0) { continue; }

		int num = 0;
		while (n % p == 0) {
			++num;
			n /= p;
		}
		ret.emplace_back(p, num);
	}
	if (n != 1) { ret.emplace_back(n, 1); }

	return ret;
}

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

	int g = A[0];
	for (int i = 0; i < N; ++i) { g = gcd(g, A[i]); }

	if (g != 1) {
		cout << "not coprime\n";
		return 0;
	}

	set<int> st;
	for (auto v : A) {
		auto t = factorize(v);
		for (auto p : t) {
			if (st.count(p.first)) {
				cout << "setwise coprime\n";
				return 0;
			}
			st.insert(p.first);
		}
	}
	cout << "pairwise coprime\n";

	return 0;
}


Measured memory_bytes: 7300
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    int ans = 1;
    deque<char> deq;
    deq.push_front(s[0]);
    int c = 0;
    if(s[0]=='0') c++;
    for (int i = 1; i < s.length(); i++) {
        if(deq.front()!=s[i]){
            if(s[i]=='0'){
                if(c==k){
                    while(deq.back()=='1') deq.pop_back();
                    while(deq.back()=='0') deq.pop_back();
                }
                else c++;
            }
        }
        deq.push_front(s[i]);
        ans = max(ans,(int)deq.size());
    }
    cout << ans << endl;
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const i64 INF = 1001001001001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

i64 dp[61][2][2];

void solve() {
  int n;
  cin >> n;
  vi64 a(n);
  cin >> a;
  i64 x = 0;
  repi(i, 2, n) x ^= a[i];
  i64 y = a[0] + a[1];
  repc(i, 60) rep(j, 2) rep(k, 2) {
    dp[i][j][k] = -1;
  }
  dp[0][0][0] = 0;
  rep(i, 60) {
    int ni = i + 1;
    int ca = a[0] >> i & 1;
    int cx = x >> i & 1;
    int cy = y >> i & 1;
    rep(j, 2) rep(k, 2) {
      if (dp[i][j][k] == -1) continue;
      rep(l, 2) rep(m, 2) {
        int nk = k;
        if (k == 0 && ca < l) nk = 1;
        if (k == 1 && ca > l) nk = 0;
        if ((l ^ m) != cx) continue;
        int s = l + m + j;
        if ((s & 1) != cy) continue;
        int nj = 0;
        if (s >= 2) nj = 1;
        amax(dp[ni][nj][nk], dp[i][j][k] | (l == 1 ? bit64(i) : 0));
      }
    }
  }
  i64 ans = dp[60][0][0];
  if (ans <= 0) {
    cout << -1 << endl;
  } else {
    cout << a[0] - ans << endl;
  }
}


Measured memory_bytes: 3592
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := intSliceScanner(n)
	b := intSliceScanner(n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = a[i] - b[i]
	}
	sort.Ints(c)
	m := 0
	ans := 0
	for i := 0; i < n; i++ {
		if c[i] < 0 {
			m += c[i]
			ans++
		}
	}
	for i := n - 1; i >= 0; i-- {
		if m >= 0 {
			break
		}
		if c[i] > 0 {
			m += c[i]
			ans++
		}
	}
	if m < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 5888
#include <stdio.h>

int main(void)
{
	int height[10], Top[3];
	int i, j, topN;
	for(i=0; i<10; i++)
		scanf("%d", &height[i]);

	for(i=0; i<3; i++)
	{
		Top[i] = height[0];
		for(j=0; j<10; j++)
		{
			if(height[j] > Top[i])
			{
				Top[i] = height[j];
				topN = j;
			}
		}
		height[topN] = 0;
	}

	for(i=0; i<3; i++)
		printf("%d\n", Top[i]);
	return 0;
}

Measured memory_bytes: 600
N = int(input())

E = [None] * (N+1)
for _ in range(N):
    u, k, *vs = list(map(int, input().split()))
    E[u] = vs

d = [0] * (N+1)
f = [0] * (N+1)
t = 0

def dfs(v):
    global t, d, f
    if d[v]:
        return
    t += 1
    d[v] = t
    for u in E[v]:
        dfs(u)
    t += 1
    f[v] = t

for v in range(1, N+1):
    dfs(v)

for v in range(1, N+1):
    print(v, d[v], f[v])



Measured memory_bytes: 5656
#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;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 9e5+10;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// If you copy paste my solution I will murder you in your sleep.
void init()
{

}
ll segtree[4*maxn+1];
void modify(ll node, ll start, ll end, ll idx, ll val)
{
    if(start == end)
        segtree[node] = val;
    else
    {
        ll mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
            modify(2*node, start, mid, idx, val);
        else
            modify(2*node+1, mid+1, end, idx, val);
        segtree[node] = max(segtree[2*node],segtree[2*node+1]);
    }
}
ll query(ll node, ll start, ll end, ll l, ll r)
{
    if(r < start or end < l)
        return -inf;
    if(l <= start and end <= r)
        return segtree[node];
    ll mid = (start + end) / 2;
    ll p1 = query(2*node, start, mid, l, r);
    ll p2 = query(2*node+1, mid+1, end, l, r);
    return max(p1,p2);
}
void solve()
{
    ll n, k;
    cin>>n>>k;
    ll a[n];
    ll res = 0;
    rep0(i,n) {
        cin>>a[i];
        a[i] += 300001;
        ll now = query(1, 1, maxn-1, a[i]-k, a[i]+k);
        res = max(res,now+1);
        modify(1, 1, maxn-1, a[i], now+1);
    }
    cout<<res<<endl;
}

int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    init();
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


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

int main() {
    int k;
    std::cin >> k;

    std::vector<std::deque<std::pair<int, int>>> g(k);
    for (int i = 0; i < k; i++) {
        g[i].push_back({ (i + 1) % k, 1 });
        g[i].push_back({ i * 10 % k, 0 });
    }

    // 1 -> v
    std::vector<int> d(k, 1000000);
    d[1] = 1;
    std::deque<int> q;
    q.push_front(1);
    while (!q.empty()) {
        int curr = q.front();
        q.pop_front();
        for (auto& el : g[curr]) {
            if (d[el.first] > d[curr] + el.second) {
                d[el.first] = d[curr] + el.second;
                if (el.second) q.push_back(el.first);
                else q.push_front(el.first);
            }
        }
    }

    std::cout << d[0] << std::endl;

    return 0;
}

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

int main() {
  int s, w;
  cin >> s >> w;

  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

typedef long long ll;

int N;
ll A[200000 + 100];

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

	map<ll, ll> mns;
	for (int i = 0; i < N; i++) {
		mns[i - A[i]]++;
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += mns[i + A[i]];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 7e3 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m, k, dp[maxn][maxn];

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

	cin >> n >> m >> k;

	if (!n || !m)
	{
		cout << 1 << endl;
		return 0;
	}

	dp[1][k - 1] += 1;
	dp[k][0] -= 1;
	for (int i = k; i <= n + m; i++)
	{
		for (int j = 1; j <= i; j++)
			dp[j][i - j] = (dp[j][i - j] + dp[j - 1][i - j + 1]) % mod;
		
		for (int j = 0; j <= i; j++)
			if (dp[j][i - j])
			{
				dp[j][i - j + k - 1] = (dp[j][i - j + k - 1] + dp[j][i - j]) % mod;
				if (i - j - 1 >= 0)
					dp[j + k - 1 + 1][i - j - 1] = (dp[j + k - 1 + 1][i - j - 1] - dp[j][i - j] + mod) % mod;
			}
	}

	ll ans = 0;
	for (int i = n; i >= 0 + (n > 0); i -= (k - 1))
		for (int j = m; j >= 0 + (m > 0); j -= (k - 1))
			ans = (ans + dp[i][j]) % mod;
	cout << ans << endl;
}



Measured memory_bytes: 167296
/**
 * Title: C - Fennec vs Monster
 * Url: https://atcoder.jp/contests/abc153/tasks/abc153_c
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    for(int i=0; i<n; i++) cin >> h[i];
    sort(h.begin(), h.end(), std::greater<ll>());
    ll ans = 0;
    for(int i=0; i<n; i++) {
        if(i+1>k) ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin(),(c).end())
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int H[25];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  REP(i,N) cin >> H[i];
  int mx = 0;
  int ans = 0;
  REP(i,N) {
    ans += (H[i] >= mx);
    CHMAX(mx,H[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def isPalind(s):
  return s == s[::-1]
  
if __name__ == "__main__":
  S = input()
  N = len(S)
  if isPalind(S) and isPalind(S[:(N - 1) // 2]) and isPalind(S[(N + 1) // 2:]):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
int main() 
{
 int a[10000], min, max, n, i;
 long long sum = 0;
 scanf("%d", &n);
for(i = 0; i < n; i++){ 
scanf("%d", &a[i]);
 sum += a[i]; 
} 
max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
} 
printf("%d %d %lld\n", min, max, sum);
return 0; 
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


long long bcnt[100001], ccnt[100001];

int main(void)
{
	vector <int> A, B, C;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		A.push_back(n);
	}
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		B.push_back(n);
	}
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		C.push_back(n);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	int apos = 0, bpos = 0, cpos = 0;

	for (int i = 0; i < N; i++) {
		bcnt[i] = ccnt[i] = 0;
	}

	while (bpos < N) {
		if ((apos < N) && (A[apos] < B[bpos])) {
			apos++;
		} else {
			bcnt[bpos] = apos;
			bpos++;
		}
	}
	bpos = 0;
	long long ans = 0;
	while (cpos < N) {
		if ((bpos < N) && (B[bpos] < C[cpos])) {
			ccnt[cpos] += bcnt[bpos];
			bpos++;
		} else {
			ans += ccnt[cpos];
			cpos++;
			ccnt[cpos] = ccnt[cpos-1];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3192
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a = int(input())
    b = int(input())

    print(1 ^ 2 ^ 3 ^ a ^ b)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }

    public static void main(String[] args) throws IOException {
        StringBuilder ans = new StringBuilder();
//        int t=ri();
        int t=1;
        while (t-- > 0)
        {
            int a=ri();
            ans.append(a+a*a+a*a*a).append("\n");
        }
        out.print(ans.toString());
        out.flush();

    }
}


Measured memory_bytes: 25424
import sys

def main():
  n,m = map(int,input().split())
  a = list(map(int,input().split()))
  bc = []
  for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
  bc = sorted(bc,key=lambda x:x[1])
  bc.reverse()
  count = 0
  for b,c in bc:
    count += b
    a += [c] * b
    if count >= n:
      break
  a.sort()
  a.reverse()
  return sum(a[:n])

if __name__ == '__main__':
  print(main())

Measured memory_bytes: 24904