akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

const i64 mod = 1e9 + 7;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main(){
    i64 h, w, k;
    cin >> h >> w >> k;
    vector<string> mas(h);
    for(int i = 0; i < h; ++i) cin >> mas[i];
    vector<vector<i64>> ans(h, vector<i64>(w, 0));
    i64 cnt = 1;
    for(int i = 0; i < h; ++i){
        i64 l = 0;
        for(int j = 0; j < w; ++j){
            if(mas[i][j] == '#'){
                i64 r = j;
                for(int x = r + 1; x < w; ++x){
                    if(mas[i][x] == '.') r = x; 
                    else break;
                }
                for(int x = l; x <= r; ++x){
                    ans[i][x] = cnt;
                }
                ++cnt;
                l = r + 1;
                j = r;
            }
        }
        if(ans[i][0] != 0 && ans[i][w - 1] == 0){
            while(l < w){
                ans[i][l] = cnt;
                ++l;
            }
            ++cnt;
        }
    }
    bool flag = false;
    for(int i = 0; i < h; ++i){
        if(ans[i][0] == 0){
            if(flag){
                for(int j = 0; j < w; ++j){
                    ans[i][j] = ans[i - 1][j];
                }
            }
        }else{
            if(!flag){
                for(int x = i - 1; x >= 0; --x){
                    for(int y = 0; y < w; ++y){
                        ans[x][y] = ans[x + 1][y];
                    }
                }
                flag = true;
            }
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1664
#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...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  string s;
  for (int i = 0; i < h; i++) {
    string t; cin >> t; s += t;
  }
  V<> n(26); for (int i = 0; i < 26; i++) n[i] = count(s.begin(), s.end(), 'a' + i);
  int a = 0, b = 0;
  for (int i = 0; i < 26; i++) {
    if (n[i] & 1) a++;
    else if (n[i] >> 1 & 1) b++;
  }
  bool ok = true;
  if (h & 1 and w & 1) {
    if (a != 1) ok = false;
    int c = h / 2 + w / 2;
    if (b > c or c & 1 and b == 0) ok = false;
  } else if (!(h & 1) and !(w & 1)) {
    if (a != 0 or b != 0) ok = false;
  } else {
    int c = h & 1 ? w / 2 : h / 2;
    if (a != 0) ok = false;
    if (b > c or c & 1 and b == 0) ok = false;
  }
  cout << (ok ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 256
def resolve():
    import math
    X = int(input())
    while True:
        count = 0
        for i in range(2, int(math.sqrt(X))):
            if X%i == 0:
                count += 1
                break
        if count == 0:
            print(X)
            exit()
        else:
            X += 1
resolve()

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException, NumberFormatException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] xy = null;
		xy = br.readLine().split(" ");
		long hNum = Long.parseLong(xy[0]);
		long wNum = Long.parseLong(xy[1]);

		if (hNum == 1 || wNum == 1) {
			System.out.println(1);
		} else if ((hNum * wNum) % 2 == 0) {//偶数なら
			System.out.println(hNum * wNum / 2);
		} else {
			System.out.println(hNum * wNum / 2 + 1);
		}

	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1e19;
#define all(v) v.begin(), v.end()

int main(){
  ll N,K,m=INF;
  cin >> N >> K;
  vector<P> A(N);
  vector<ll> X(N),Y(N);
  rep(i,N){
    cin >> X.at(i) >> Y.at(i);
    A.at(i)=P(X.at(i),Y.at(i));
  }
  sort(all(X));
  sort(all(Y));
  rep(a,N){
    for(ll b=a+1;b<N;b++){
      rep(c,N){
        for(ll d=c+1;d<N;d++){
          ll k=0;
          rep(i,N){
            if(A.at(i).first>=X.at(a)&&A.at(i).first<=X.at(b)&&A.at(i).second>=Y.at(c)&&A.at(i).second<=Y.at(d)){
              k++;
            }
          }
          if(k>=K){
            m=min(m,(X.at(b)-X.at(a))*(Y.at(d)-Y.at(c)));
          }
        }
      }
    }
  }
  cout << m << endl;
      
}
    

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

constexpr int LIMIT = 1000000;
int dp1[LIMIT], dp2[LIMIT];

void solve() {
  std::fill(dp1, dp1 + LIMIT, 100);
  std::fill(dp2, dp2 + LIMIT, 100);
  dp1[0] = dp2[0] = 0;
  for (int n = 1; n < 200; ++n) {
    int const tet = n * (n + 1) * (n + 2) / 6;
    for (int i = 0; i + tet < LIMIT; ++i) {
      dp1[i + tet] = std::min(dp1[i + tet], dp1[i] + 1);
      if (tet % 2) {
        dp2[i + tet] = std::min(dp2[i + tet], dp2[i] + 1);
      }
    }
  }
}

int main() {
  solve();
  int N;
  while (std::cin >> N && N) {
    std::cout << dp1[N] << " " << dp2[N] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 10824
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

def sort_str(t):
    l = sorted(t)
    text = ''
    for i in range(len(t)):
        text += l[i]
    return text

def sum_stair(n):
    num = 0
    for i in range(1, n + 1):
        num += i
    return num

def main():
    N = int(input())
    s = [sort_str(input()) for _ in range(N)]

    t = {}
    for i in s:
        t[i] = 0
    for i in s:
        t[i] += 1
    ans = 0
    for i in t.values():
        ans += sum_stair(i - 1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 109060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long n = scan.nextLong();
        long a = scan.nextLong();
        long b = scan.nextLong();
        long c = n % (a + b);
        long out = 0;
        if(c <= a){
            out = c + (n / (a + b)) * a;
        }else{
            out = a + (n / (a + b)) * a; 
        }
        System.out.println(out);
    }
}

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

int n;
int a[105];

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

	int ans = 1e9;

	cin >> n;

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

	for(int i = -100; i <= 100; i++) {
		int test = 0;
		for(int j = 0; j < n; j++) {
			test += (a[j] - i)*(a[j] - i);
		}
		ans = min(test, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int ar[3];
    for(int i=0;i<3;++i) cin>>ar[i];
   	sort(ar,ar+3,greater<int>());
   	cout<<ar[0]-ar[2];
  	return 0;
}


Measured memory_bytes: 3516
n=int(input())
a=list(map(int,input().split()))
a.sort()
data=set()
for x in a:
    data|={x,}
while True:
    now=min(data)
    data-={now,}
    if now==1:
        ans=now
        break
    if len(data)==0:
        ans=now
        break
    for i in range(len(data)):
        check=data.pop()
        check%=now
        if check!=0:
            data|={check,now,}
            break
    data|={now,}
print(ans)

Measured memory_bytes: 14988
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, A[100001];

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

    for (int i=0; i<N-1; ++i) {
        if (A[i] < 0) {
            A[i] *= -1;
            A[i+1] *= -1;
        }
    }

    long long sum = 0;
    for (int i=0; i<N; ++i) {
        sum += A[i];
    }

    long long res = sum;
    for (int i=N-2; i>=0; --i) {
        sum = sum - A[i] - A[i+1];
        A[i] *= -1;
        A[i+1] *= -1;
        sum = sum + A[i] + A[i+1];
        res = max(res, sum);
    }

    cout << res << endl;

    return 0;
}

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

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

using int64 = long long;
using P = pair<int64,int64>;

const int MOD = 1000000007;
int main() {
    int64 n;
    cin >> n;
    vector<int64> a(n);
    for (int64 i=0; i<n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());
    vector<P> len(1, P(a[0], 0));
    for (const auto& ai : a) {
        if (len.back().first == ai) len.back().second++;
        else len.emplace_back(ai, 1);
    }

    if (n % 2 == 1 && len.back().first == 0 &&  len.back().second == 1) len.pop_back();
    bool f = all_of(len.begin(), len.end(), [](P p){return p.second == 2;});

    int ans = 0;
    if (f) {
        ans = 1;
        for (int i=0; i<n/2; i++) {
            ans *= 2;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 2168
from itertools import product

n, s = int(input()), input()

for bfo2, bfo1 in product(['S', 'W'], repeat=2):
    ans = [bfo2, bfo1]
    for i in s:
        if ((bfo1 == 'S' and i == 'o')
                or (bfo1 == 'W' and i == 'x')):
            ans.append(bfo2)
        elif ((bfo1 == 'S' and i == 'x')
                or (bfo1 == 'W' and i == 'o')):
            ans.append(*({'S', 'W'} - {bfo2}))
        bfo1, bfo2 = ans[-1], bfo1
    if ans[:2] == ans[-2:]:
        print(*ans[1:-1], sep='')
        break
else:
    print(-1)


Measured memory_bytes: 91240
m = set()
for _ in range(int(input())):
    a, b = map(int, input().split())
    i = 0
    while True:
        if a + b + i in m:
            m.remove(a + b + i)
            i += 1
        else:
            m.add(a + b + i)
            break
m = list(m)
m.sort()
for i in m:print("{} 0".format(i))


Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  ll cnt = 0;
  ll ans = 0;
  REP(i, S.size()) {
    if(S[i] == 'B') cnt++;
    if(S[i] == 'W') ans += cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3740
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    int a[2003];
    P p[2003];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[i] = P(a[i], i);
    }
    sort(p, p + n);
    int ans = 1000000000;
    int d[2003] {0};
    int c[2003];
    int start;
    for(int i = 0; i < n; i++){
        priority_queue<int, vector<int>, greater<int>> que;
        for(int j = 0; j < n; j++) c[j] = a[j];
        start = 0;
        for(int j = 0; j < n; j++){
            if(d[j]){
                sort(c + start, c + j);
                for(int s = start; s < j - (k - 1); s++) que.push(c[s]);
                start = j + 1;
            }
        }
        sort(c + start, c + n);
        for(int s = start; s < n - (k - 1); s++) que.push(c[s]);
        if((int)que.size() < q) break;
        int les = que.top();
        for(int j = 0; j < q - 1; j++) que.pop();
        int lar = que.top();
        ans = min(ans, lar - les);
        d[p[i].second] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int x,y; cin>>x>>y;
    cout<<__gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*2
#define mod 1000000007
#define ll long long
int a[nn];int n;
set<int> s;map<int,int> m;
int b[nn];
int main()
{
	cin>>n;for(int i=1;i<=n;i++) scanf("%d",&a[i]),s.insert(a[i]);
	
	int tot=0;
	for(set<int>::iterator it=s.begin();it!=s.end();it++) m[*it]=++tot;
	for(int i=1;i<=n;i++) a[i]=m[a[i]],b[a[i]]=i;int cnt=0;
	for(int i=1;i<=n;i++)
		if(b[i]%2!=i%2) cnt++;
	cout<<cnt/2;
	return 0;
} 

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long max = 0;
        for(int i = 0;i<=Math.sqrt(a);i++){
            if(max<i*i && i*i<=a){
                max = i*i;
                // System.out.println(i*i);
            }
        }
        System.out.println(max);
        // System.out.println(Math.sqrt(271828169));
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <cmath>



typedef long long ll;


using namespace std;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n;
ll m;

int main(){
    cin>>n>>m;
    ll a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int cnt=0;
    int i=0;
    while (i<n){
        if (m==0){
            break;
        } else if(m<0){
            break;
        } else {
        m-=a[i++];
        cnt++;
        }
    }
    if (m>0 || m<0){
        printf("%d\n",cnt-1);
    }else{
        printf("%d\n",cnt);
    }
}

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

using namespace std;

typedef long long ll;

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; }

int main(){
    int n;  cin >> n;
    int ans=0;

    for(int i=1;i<=n/2;i++){
        //printf("%d,%d\n",i,n-1);
        if(i != n-i){ //printf("Yes\n");
            ans++;
        }
    }


    cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll n; cin >> n;
    ll p[100];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    ll ans = 0;
    for (int i = 1; i < n-1; i++) {
        ll minx = min(p[i-1],min(p[i],p[i+1]));
        ll maxx = max(p[i-1],max(p[i],p[i+1]));
        if(p[i] != minx && p[i] != maxx){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e3+5;
int ans[4];

int main()
{
	int n,m;
	cin>>n>>m;
	int los=0;
	for(int i=0;i<4;i++) ans[i]=-1;
	for(int i=0;i<m;i++)
	{
		int lo,num;
		cin>>lo>>num;
		if(lo>n) los=1;
		if(ans[lo]==-1||ans[lo]==num) ans[lo]=num;
		else los=1;
	}
	if(los) cout<<-1<<endl;
	else 
	{
		if(ans[1]==0)
		{
			if(n==1&&ans[2]<=0&&ans[3]<=0) cout<<0<<endl;
			else cout<<-1<<endl;
			
		}
		else if(ans[1]==-1) 
		{
			if(n==1) cout<<0<<endl;
			else 
			{
				cout<<1;
				for(int i=2;i<=n;i++)
				{
					if(ans[i]==-1) cout<<0;
					else cout<<ans[i];
				}
				cout<<endl;
			}
		}
		else 
		{
			for(int i=1;i<=n;i++)
			{
				if(ans[i]==-1) cout<<0;
				else cout<<ans[i];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
K = int(input())


def lun(n):
    found = []

    def _lun(top, m):
        if m == 0:
            found.append(int("".join(map(str, top))))
            return
        for t in (top[-1] - 1, top[-1], top[-1] + 1):
            if 0 <= t <= 9:
                _lun(top + [t], m - 1)

    for i in range(1, 10):
        _lun([i], n - 1)

    return found


d = 1
luns = []
while True:
    luns.extend(lun(d))
    if len(luns) >= K:
        break
    d += 1

print(luns[K - 1])

Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long int MOD=1e9+7;

long long int modinv(long long int a, long long int m) {
    long long int b = m, u = 1, v = 0;
    while (b) {
        long long int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

long long int conv(long long int i, long long int j) {
    long long int tmp=min(i-j, j);
    long long int cnt=1;
    long long int rs=1;
    while(cnt<=tmp) {
        rs *= (i+1-cnt);
        rs %= MOD;
        
        rs *= modinv(cnt, MOD);
        rs %= MOD;
    
        cnt++;
    }

    return rs;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long int> A(N);
    vector<long long int> C(N+K, 0);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    
    sort(A.begin(), A.end());
    
    C[K-1]=1;
    for(int n=1; n<N; n++) {
        C[K-1+n] = C[K-1+n-1]*(K-1+n);
        C[K-1+n] %= MOD;
        C[K-1+n] *= modinv(n, MOD);
        C[K-1+n] %= MOD;
    }
    
    long long int ans=0;
    for(int n=0; n<N; n++) {
        // cout << n << ":" << endl;
        if(n-(K-2)>0) {
            // cout << n << "C" << K-1 << endl;
            ans += C[n]*A[n];
            ans %= MOD;
        }
        
        if(N-1-n-(K-2)>0) {
            // cout << N-1-n << "C" << K-1 << endl;
            ans -= C[N-1-n]*A[n];
            ans %= MOD;
        }
    }

    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 2176
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e2+5;

int32_t main(){
   
   speed_cubing
   
   int a;
   cin>>a;

   cout<<a+a*a+a*a*a;
    
   return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,l,r;
    string s;
    while(cin>>s)
    {
        l=r=0;
        n=s.size();
        for(int i=0;i<n;i++)
            if(s[i]=='1')
                l++;
            else
                r++;
        cout<<min(l,r)*2<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n, m;
int blue[510][510];
int red[510][510];
int main(){
	// freopen("in.in","r",stdin);
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			char x; cin >> x;
			if(x == '#') blue[i][j] = red[i][j] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < m; j++){
			if(j == 1) blue[i][j] = 1;
			else if(i % 2 == 1) blue[i][j] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 2; j <= m; j++){
			if(j == m) red[i][j] = 1;
			else if(i % 2 == 0) red[i][j] = 1;
		}
	}

	// output
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(blue[i][j]) cout << '#';
			else cout << '.';
		}
		cout << "\n";
	}
	cout << "\n";
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(red[i][j]) cout << '#';
			else cout << '.';
		}
		cout << "\n";
	}

}

Measured memory_bytes: 2816
#data=list(input().split())
a,b=map(int,input().split())
if b+a-1<0:
    print(int((2*b+a-1)*a/2)-(b+a-1))
elif b>0:
    print(int((2*b+a-1)*a/2)-b)
else:
   print(int((2*b+a-1)*a/2)) 



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

namespace AtCoder_Cs
{
	public class ABC081
	{
		public static void Main()
		{
			var lin = Console.ReadLine();
			var cnt = 0;
			for (int i = 0; i <= 2; i++)
			{
				if (lin.Substring(i,1) == "1")
				{
					cnt++;
				}
			}
			Console.WriteLine($"{cnt}");

		}
	}
}


Measured memory_bytes: 13268
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  static long long S[3001], F[3000];
  copy_n(istream_iterator<int>(cin), N, F);
  partial_sum(F, F + N, S + 1);
  for (auto i = 2; i <= N; ++i)
    for (auto j = 0; j <= N - i; ++j)
      F[j] = S[j + i] - S[j] - min(F[j], F[j + 1]);
  cout << F[0] * 2 - S[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9; 

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

    int n;
    string s;
    cin >> n >> s;
    map <char, int> num;
    vector<int> alphabet(26);
    for(char c = 'A'; c <= 'Z'; ++c){
        alphabet[c - 'A'] = c;
        num[c] = c - 'A';
    }
    for(int i = 0; i < (int)s.length(); ++i){
        s[i] = alphabet[(num[s[i]] + n) % 26];
    }
    cout << s << "\n";
}

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

int main(){

  int N;
  std::string S;
  std::cin >> N >> S;

  int maxCnt = 0;
  for (int i=1;i<N;i++) {
    //部分取得
    std::string X = S.substr(0,i);
    std::string Y = S.substr(i,N-i);
    //std::cout << Y << '\n';
    int cnt = 0;
    for (char c='a';c<='z';c++) {
      if ( X.find(c)!=std::string::npos &&
            Y.find(c)!=std::string::npos  ) cnt++;
    }
    maxCnt = std::max(maxCnt,cnt);
  }

  std::cout << maxCnt  << '\n';

  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
 
if h%3 == 0 or w%3 == 0:
    ans = 0
    
else:
    ans = float('inf')
    
    # 縦(横)で2つに分割して、そのうちの1つを横(縦)で分割する
    for x, y in [[h, w], [w, h]]:
        mid = x//2
        r = x%2
        temp = float('inf')
        for i in range(1, y):
            a, b, c = x*i, (mid+r)*(y-i), (mid)*(y-i)
            area = abs(max(a, b, c) - min(a, b, c))
            if area < temp:
                temp = area
            else:
                break
        ans = min(ans, temp)
        
    # 縦(横)で3つに分割する
    for x, y in [[h, w], [w, h]]:
        ans = min(ans, x*(y//3+1) - x*(y//3))
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int n, m, l, i, j, k;
  unsigned long long a[100][100] = {}, b[100][100] = {}, c[100][100] = {};
  scanf ("%d %d %d", &n, &m, &l);
  for(i = 0; i < n ;i++){
    for(j = 0; j < m ;j++){
      scanf("%d", &a[i][j]);
    }
  }
  for(i = 0; i < m ;i++){
    for(j = 0; j < l ;j++){
      scanf("%d", &b[i][j]);
    }
  }
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < l ; j++ ){
      for(k = 0 ; k < m ; k++){
	c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  for(i = 0; i < n ; i++ ){
    for(j = 0; j < l ; j++ ){
      printf("%lu", c[i][j]);
      if ( j != l-1 ) printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner

object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  val line = scanner.nextLine

  val lst: Array[Int] = line.split(" ").map{_.toInt}
  //一応配列の要素数を取得
  val listNum: Int = lst.length

  // わかりやすさのためにいったんすべて変数に代入する
  val wakeUpH: Int = lst(0)
  val wakeUpM: Int = lst(1)
  val sleepH: Int = lst(2)
  val sleepM: Int = lst(3)
  val studyM: Int = lst(4)

  val diffH: Int = sleepH - wakeUpH
  val diffM: Int = sleepM - wakeUpM
  //勉強できる時間
  val canStudyTime: Int = diffH*60 + diffM - studyM
  
  println(canStudyTime)
}

Measured memory_bytes: 55268
#include<cstdio>
#include<cmath>
using namespace std;
int d[100010],s[100010],n,a=1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&d[i]);
	d[0]=2e8;s[0]=2e8;
	for(int i=2;i<=n;i++){
		if((abs(d[i]-d[i-1])+s[i-1])>(abs(d[i]-d[i-2])+s[i-2]))s[i]=abs(d[i]-d[i-2])+s[i-2];
		else s[i]=abs(d[i]-d[i-1])+s[i-1];
	}
	printf("%d",s[n]);
	return 0;
}

Measured memory_bytes: 896
a, b, c = map(int, input().split())
if ((a % 2) + (b % 2) + (c % 2)) > 0:
    ans = 0
elif (a == b) & (b == c):
    ans = -1
else:
    ans = 0
    while ((a % 2) + (b % 2) + (c % 2)) == 0:
        a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2
        ans += 1
print(ans)

Measured memory_bytes: 3064
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
sec = 0

for i in range(len(t)-1):
    if t[i+1] - t[i] > T:
        sec += T
    else:
        sec += t[i+1] - t[i]
sec += T
print(sec)


Measured memory_bytes: 25200
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ans[100005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size(), cnt = 0;
	rep(i,n){
		if(s[i] == 'R') ++cnt;
		else{
			ans[i] += cnt / 2;
			ans[i-1] += cnt - cnt / 2;
			cnt = 0;
		}
	}
	cnt = 0;
	for(int i = n-1; i >= 0; --i){
		if(s[i] == 'L') ++cnt;
		else{
			ans[i] += cnt / 2;
			ans[i+1] += cnt - cnt / 2;
			cnt = 0;
		}
	}
	rep(i,n-1) cout << ans[i] << " " ;
	cout << ans[n-1] << endl;
	return 0;
}


Measured memory_bytes: 4156
n=int(input())
l1=[]
for i in range(1,14):
    l1.append('S %d'%i)
for i in range(1,14):   
    l1.append('H %d'%i)
for i in range(1,14):
    l1.append('C %d'%i)
for i in range(1,14):
    l1.append('D %d'%i)

for i in range(1,n+1):
    s=str(input())
    if s in l1:
        l1.remove(s)

for i in l1:
    print(i)



Measured memory_bytes: 5592
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>1)
        a=(a*(a-1))/2;
  else
    a=0;
  if(b>0)
    b=(b*(b-1))/2;
  else
    b=0;
    cout<<a+b<<endl;









}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt0=[0]*60
cnt1=[0]*60
mod=10**9+7
tp=[0]*60
for i in range(60):
  tp[i]=(1<<i)%mod
for i in range(60):
    x=1<<i
    one=sum(1 for j in a if j&x)
    ans+=tp[i]*one*(n-one)
print(ans%mod)



Measured memory_bytes: 42156
#include <stdio.h>
int A[500000],L[500000/2+2],R[500000/2+2],count=0;;

#define SENTINEL 2000000000
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
  int main(){
  int n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&A[i]);

  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    printf("%d",A[i]);

  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


void merge(int *A, int left,int mid,int right){
  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for( i = 0 ;i<n1;i++) L[i] = A[left + i];
  for (i = 0 ;i<n2;i++) R[i] = A[mid + i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for (k = left;k<right;k++){
    if (L[i] <= R[j]){
      count++;
      A[k] = L[i];
	i = i + 1;
    }
    else {
      count++;
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4508
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>

#define PI 3.14159265359


using namespace std;
int main()
{
    int a,b;
    string op;
    int ans;
    while(1){
        cin >> a >> op >> b;
        if(op == "?") break;

        if(op == "+") ans = a + b;
        else if(op == "-") ans = a - b;
        else if(op == "*") ans = a * b;
        else if(op == "/") ans = a / b;
        cout << ans << endl;    
    }
 



    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	set<char> st;
	REP(i, k)
	{
		char a; cin >> a;
		st.insert(a);
	}
	for (int i = n;; i++)
	{
		string s = to_string(i);
		bool f = true;
		REP(j, s.size())
		{
			if (st.count(s[j]))
			{
				f = false;
			}
		}
		if (f)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var n int
        fmt.Scanf("%d", &n)

        var canDiv bool
        for i := 2; i <= 9; i++ {
                if n%i == 0 && n/i <= 9 {
                        canDiv = true
                }
        }
        if n == 1 {
                canDiv = true
        }

        if canDiv {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	int n,x[100],y[100],h[100],cx,cy,X=-1,Y=-1,H=0;

	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];

	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			for(int k=0;k<n;k++){
				int ch=abs(i-x[k])+abs(j-y[k])+h[k];
				for(int l=0;l<n;l++){
					if(max(ch-abs(i-x[l])-abs(j-y[l]),0)!=h[l])break;
					else if(l==n-1){
						cout<<i<<" "<<j<<" "<<ch<<endl;
						return 0;
					}
				}
			}
		}
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
int n;
string s, t;
int h, w;
    int sr, sc;
    cin >> h>> w>> n;
    cin >> sr >> sc;
    cin >> s;
    cin >> t;
    int u = 0, d = 0, r =0 , l=0;
    for (int i = 0; i < n; i++) {
        u += s[i]=='U';
        l += s[i]=='L';
        r += s[i]=='R';
        d += s[i]=='D';
 
        if (sr - u < 1 || d + sr > h || sc - l < 1 || r + sc > w) {
            cout << "NO";
            return 0;
        }
        // cout << i << " = " << "u = " << u << " d = " << d << " r = " << r << " l = " << l << endl;
 
        if (sr - u < h) u -= t[i]=='D';
        if (d + sr > 1) d -= t[i]=='U';
        if (r + sc > 1) r -= t[i]=='L';
        if (sc - l < w) l -= t[i]=='R';
        // cout << i << " = " << "u = " << u << " d = " << d << " r = " << r << " l = " << l << endl;
    }
    cout << "YES";
 
    return 0;
}

Measured memory_bytes: 776
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let r1 = line.trim();
    let r1_rev: String = r1.chars().rev().collect();
    let line = gets();
    let r2 = line.trim();
    let r2_rev: String = r2.chars().rev().collect();
    if r1 == r2_rev && r2 == r1_rev {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
N, K = map(int, input().split())

e_table = [0]
pre = 0
for i in range(1,1001):
    e_table.append((pre + i)/i)
    pre = pre + i

lis = [0] * K
SUM = 0
maximam = 0

for i, p in enumerate(input().split()):
    p = int(p)
    lis.append(e_table[p])
    SUM = SUM - lis[i] + lis[-1]
    maximam = max(maximam, SUM)
print(maximam)

Measured memory_bytes: 78088
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 1e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int Dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int Dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int a[4];
	for(int i = 0; i < 2; i++){
		cin >> a[i];
	}
	a[2] = a[0] - 1;
	a[3] = a[1] - 1;
	sort(a, a + 4);
	reverse(a, a + 4);
	cout << a[0] + a[1];
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let mut vec: Vec<i32> = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    let all_sum: i32 = vec.iter().fold(0, |sum, a| sum + a);
    let middle = all_sum / 2;
    let mut sum: i32 = 0;
    for v in vec.iter() {
        sum += *v;
        if sum >= middle {
            if (sum - middle) < (middle + *v - sum) {
                println!("{}", (all_sum - 2 * sum).abs());
            } else {
                println!("{}", (all_sum - 2 * (sum - *v)).abs());
            }
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b,c,ans=0,j;
    cin>>a>>b>>c;
    j=c/b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    f(i,1,j+1){
        if(ans<floor(a*(b*i-1)/b)-a*floor((b*i-1)/b)){
            ans=floor(a*(b*i-1)/b)-a*floor((b*i-1)/b);
        }
        if(ans==a-1-a/b){
            cout<<a-1-a/b<<endl;
            return 0;
        }
    }
    if(ans<floor(a*c/b)-a*floor(c/b)){
        ans=floor(a*c/b)-a*floor(c/b);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
solve :: Int -> Int -> Int -> String
solve a b c
  | d < e && 0 < (c-a-b) = "Yes"
  | otherwise = "No"
  where
    d = 4 * a * b
    e =  (^2) $ (c-a-b)


main = do
  [a,b,c] <- map read . words <$> getLine
  putStrLn $ solve a b c


Measured memory_bytes: 508
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();

        int[] arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        System.out.println(arr[K-1]);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	int L, q;
	cin >> L >> q;
	x.emplace_back(x.back() + L + 1);
	vector<vector<int> > p;
	p.resize(n);
	for(int i = 0; i < n; ++i) {
		p[i].resize(20);
	}
	for(int i = 0; i < n; ++i) {
		auto it = upper_bound(x.begin(), x.end(), x[i] + L);
		p[i][0] = (--it - x.begin()); 
	}
	for(int j = 1; j < 20; ++j) {
		for(int i = 0; i < n; ++i) {
			p[i][j] = p[p[i][j - 1]][j - 1];
		}
	}
	while(q--) {
		int a, b;
		cin >> a >> b;
		if(a > b) {
			swap(a, b);
		}
		--a;
		--b;
		int ans = 0;
		for(int j = 19; ~j; --j) {
			if(x[p[a][j]] < x[b]) {
				ans += 1 << j;
				a = p[a][j];
			}
		}
		cout << ans + 1 << '\n';
	}
	return 0;
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

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

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> a, b, c;
	rep(i, n) {
		int a_in;
		cin >> a_in;
		a.push_back(a_in);
	}
	rep(i, n) {
		int b_in;
		cin >> b_in;
		b.push_back(b_in);
	}
	rep(i, n) {
		int c_in;
		cin >> c_in;
		c.push_back(c_in);
	}
	
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	
	ll sum = 0;
	rep(i, n) {
		ll t_m = (ll) (lower_bound(a.begin(), a.end(), b[i]) - a.begin());
		ll m_b = (ll) (n-(upper_bound(c.begin(), c.end(), b[i]) - c.begin()));
//		cout << t_m << " " << m_b << endl;
		sum += t_m * m_b;
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    int ans = 0;

    rep(i, M){
        cin >> L[i] >> R[i];
    }

    /*  間に合わない O(NM)
    rep (i, N){
        bool flag = true;
        rep (j, M){
            if (L[j] <= i && M[j] >= i){
                continue;
            } else{
                flag = false;
                break;
            }
        }
        if (flag)   ans++;
    }
    */

    int max_l = *max_element(L.begin(),L.end());
    int min_r = *min_element(R.begin(),R.end());

    REP(i, N){
        if (max_l <= i && min_r >= i){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int[] A = cin.arrayInt();
        Array.Sort(A);
        Console.WriteLine(Math.Abs(A[1] - A[0]) + Math.Abs(A[2] - A[1]));
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

int main(){
    int A,B,C,X,c=0;
    cin >> A >> B >> C >> X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X){
                    c++;
                }
            }
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
  int a,b,d,r;
  scanf("%d %d",&a,&b);
  double f1,f2,f;
  f1=a;
  f2=b;
  d=a/b;
  r=a%b;
  f=f1/f2;
  printf("%d %d %.5f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 640
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
arr = [True for i in range(N)]
ans = 0
for i in range(M):
    A, B = list(map(int, input().split()))
    A -= 1
    B -= 1
    if H[A] <= H[B]:
        arr[A] = False
    if H[B] <= H[A]:
        arr[B] = False
for ele in arr:
    if ele == True:
        ans += 1

print(ans)

Measured memory_bytes: 20108
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

string s, t;
llint dp[200005][2], dp2[200005][2];
llint beki[200005];

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

  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  int n = s.size();

  beki[0] = 1;
  for(int i = 1; i < 200005; i++) beki[i] = beki[i-1] * 10, beki[i] %= mod;

  dp[n][0] = 1;
  for(int i = n; i > 0; i--){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 10; k++){
        if(t[i-1] != '?' && t[i-1]-'0' != k) continue;
        if(j == 0 && s[i-1]-'0' < k) continue;
        int nj = j;
        if(k < s[i-1]-'0') nj = 1;
        dp[i-1][nj] += dp[i][j], dp[i-1][nj] %= mod;
      }
    }
  }

  for(int i = n; i > 0; i--){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 10; k++){
        if(t[i-1] != '?' && t[i-1]-'0' != k) continue;
        if(j == 0 && s[i-1]-'0' < k) continue;
        int nj = j;
        if(k < s[i-1]-'0') nj = 1;
        dp2[i-1][nj] += dp2[i][j] + dp[i][j]*k%mod*beki[i-1]%mod, dp2[i-1][nj] %= mod;
      }
    }
  }

  llint ans = 0;
  for(int i = 0; i < 2; i++) ans += dp2[0][i], ans %= mod;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 11376
#include "iostream"
#include "map"

using namespace std;

int main(){
int n,mod;
cin>>n>>mod;
long long int v[100001]={};
map<int,long long int>m;
m[0]++;
for(int i=1;i<=n;i++){
cin>>v[i];
v[i]+=v[i-1];
v[i]%=mod;
m[v[i]]++;
}
long long int ans=0;
for(auto i:m)ans+=i.second*(i.second-1)/2;
cout<<ans<<endl;
}

Measured memory_bytes: 4992
import sys

input = sys.stdin.readline

N, C = map(int, input().split())

T = 10 ** 5 + 1
A = [[0] * T for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    A[c - 1][s] += 1
    A[c - 1][t] -= 1

for i in range(C):
    for j in range(1, T):
        A[i][j] += A[i][j - 1]
        if A[i][j] == 1 and A[i][j - 1] == 0:
            A[i][j - 1] = 1

ans = 0
for j in range(1, T):
    cnt = 0
    for i in range(C):
        cnt += A[i][j]
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 65884