akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main() {
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int r,g,b,n,sum = 0;
	scanf("%d %d %d %d",&r,&g,&b,&n);
	for(int i = 0;i <= n / r;i++){
		for(int j = 0;j <= n / g;j++){
			if((n - i * r - g * j) % b == 0 && n - i * r - g * j >= 0) sum++;
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (K, S) = readLine()!!.split(" ").map(String::toInt)

    var cnt = 0
    for (X in 0..K) {
        for (Y in 0..K) {
            val Z = S - X - Y
            if (Z in 0..K) {
                cnt++
            }
        }
    }
    println(cnt)
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  ll l, r;
  cin >> l >> r;
  if (r - l + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  ll mi = INF;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      chmin(mi, i * j % 2019);
    }
  }
  cout << mi << endl;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

long long mod_pow(long long x, long long n, int M=1000000007) {
    long long ret = 1;
    while(n) {
        if(n & 1) (ret *= x) %= M;
        (x *= x) %= M;
        n >>= 1;
    }
    return ret;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    mint ans = mod_pow(2, n) - 1;
    mint x = 1, y = 1;
    rep(i, a) {
        x *= n - i;
        y *= i + 1;
    }
    ans -= x / y;
    x = y = 1;
    rep(i, b) {
        x *= n - i;
        y *= i + 1;
    }
    ans -= x / y;
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

vi sub(vi &a, vi &b)
{
    vi ret(a.size(), 0);
    rep(i, ret.size()) {
        ret[i] = b[i] - a[i];
    }
    return ret;
}

void dump(vi p)
{
    cout << "p = {";
    rep(i, p.size()) {
        cout << p[i] << ", ";
    }
    cout << "}" << endl;
}

int solve(vvi &yui, vvi &kyoko, int p)
{
    set<vi> st;
    for (int i = 0; i + p < yui.size(); i++) {
        st.insert(sub(yui[i], yui[i+p]));
    }

    for (int i = 0; i + p < kyoko.size(); i++) {
        if (st.find(sub(kyoko[i], kyoko[i+p])) != st.end()) {
            //dump(sub(kyoko[i], kyoko[i+p]));
            return p;
        }
    }

    return 0;
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string momo;
    cin >> momo;
    string shami;
    cin >> shami;

    vvi yui(momo.size()+1, vi(26, 0)), kyoko(shami.size()+1, vi(26, 0));
    rep(i, momo.size()) {
        rep(j, yui[i].size()) {
            yui[i+1][j] = yui[i][j];
        }
        yui[i+1][momo[i] - 'a']++;
    }
    rep(i, shami.size()) {
        rep(j, kyoko[i].size()) {
            kyoko[i+1][j] = kyoko[i][j];
        }
        kyoko[i+1][shami[i] - 'a']++;
    }
    
    int n = min(momo.size(), shami.size());

    int ans = 0;
    Rep(i, n+1) {
        ans = max(ans, solve(yui, kyoko, i));
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5908
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int z = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = x; i <= y; i++) {
            if (z % i == 0) cnt++;
        }
        System.out.println(cnt);
    }
}



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

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

  if(s.at(5) == '1'){
    cout << "TBD" <<endl;
  }
  
  else if(s.at(6) == '1' || s.at(6) == '2' || s.at(6) == '3' || s.at(6) == '4'){
    cout << "Heisei" <<endl;
  }
  else{
    cout << "TBD" << endl;
  } 
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[11],da[43][11],dn[43],h,v,n,f,an,z;

int list(int n,int k,int g) {
	int i; 
	if (k==10 && n==h) { for (i=0;i<h;i++) da[v][a[i]]++; dn[v]=h; v++; }
	if (n==h || k>=10) return 1;
	for (i=g;i<10;i++) { a[n]=i; list(n+1,k+i,i);}
	return 0;
}

int dfs(int g,int u,int t) {
	int i,j,k;
	if (an<g) an=g;
	if (g+t/dn[u]<=an) return 0;
	for (i=u;i<41;i++) {
		f=0;
		for (j=1;j<10;j++) {a[j]-=da[i][j]; if (a[j]<0) { f=1; for (k=j;k>0;k--) a[k]+=da[i][k]; break;}}
		if (f==0) {dfs(g+1,i,t-dn[i]); for(j=1;j<10;j++) a[j]+=da[i][j];}
		}
  return 0;
}

int main() {
	int i,j;
	v=0;
	for (i=0;i<40;i++) for (j=0;j<11;j++) da[i][j]=0;
	for (i=2;i<11;i++) { h=i; list(0,0,1); }
	while(cin >> n && n>0) {
		for (i=0;i<11;i++) a[i]=0;
		for (i=0;i<n;i++) { cin >> j; a[j]++; }
		v=0; an=0;
		while(v<5) {
			while(true) {
				f=0;
				for (i=1;i<10;i++) if (a[i]<da[v][i]) { f=1; break;}
				if (f==1) break;
				for (i=1;i<10;i++) a[i]-=da[v][i]; an++; n-=2;
			}
			v++;
		}
		dfs(an,5,n);
		cout << an << endl;	
	    }
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> H(N);
    REP(i,N) cin>>H[i];
    REP(i,N){
        if(i==0||H[i-1]<H[i]) H[i]--;
        else if(H[i-1]>H[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define INTEREST  5 /* % */
#define DEBT 100000

int main()
{
  int n, i, r;
  int x = DEBT;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    x += x * INTEREST / 100;
    r = x % 1000;
    x = x - r + (r > 0 ? 1000 : 0);
  }
  printf("%d\n", x);
  return 0;
}

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

class B
{
    static void Main()
    {
#if DEBUG
        string exampleInput =
        @"1000000000000000000
";
        Console.SetIn(new System.IO.StringReader(exampleInput));
#endif

        ulong X = ulong.Parse(Console.ReadLine());
        ulong v = 100;
        for (int i = 1;; i++)
        {
            v += v / 100UL;
            if(v >= X)
            {
                Console.WriteLine(i);
                break;
            }
        }

        Console.Out.Flush();
    }
}

Measured memory_bytes: 27612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 1000;
    rep (i, (int)s.size() - 2) chmin(ans, abs(atoi(s.substr(i, 3).c_str()) - 753));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n= int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

first = sum(a)

if a[0] < b[0]:
  b[0] -= a[0]
  a[0] = 0
else:
  a[0] -= b[0]
  b[0] = 0
  
if a[n] < b[n-1]:
  b[n-1] -= a[n]
  a[n] = 0
else:
  a[n] -= b[n-1]
  b[n-1] = 0
  
for i in range(n):
  if a[i] >= b[i]:
    a[i] -= b[i]
    b[i] = 0
  else:
    b[i] -= a[i]
    a[i] = 0
    
  if a[i+1] >= b[i]:
    a[i+1] -= b[i]
    b[i] = 0
  else:
    b[i] -= a[i+1]
    a[i+1] = 0

print(first - sum(a))


Measured memory_bytes: 19284
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

const int64 mod = 998244353;

int64 mpow(int64 mm, int64 xx)
{
	if(xx == 0)
	{
		return 1;
	}
	int64 tmp = mpow(mm, xx / 2);
	tmp *= tmp;
	tmp %= mod;
	if(xx % 2 == 1)
	{
		tmp *= mm;
		tmp %= mod;
	}
	return tmp;
}

int main()
{
	map<char, char> memo;
	memo['T'] = 'A';
	memo['A'] = 'T';
	memo['G'] = 'C';
	memo['C'] = 'G';
	char tmp;
	cin >> tmp;
	cout << memo[tmp] << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int n, x, t;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n>>x>>t;
    int times = ceil((double)n/(double)x);
    cout<<times*t<<"\n";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int N;
    cin >> N;
  	vector<int> A(N);
  	for (int i = 0; i < N; i ++) cin >> A.at(i);
  
  	sort(A.begin(), A.end());
  	cout << A.at(N-1) - A.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF =ll(1e18)+5;
ll H,W;
vector<std::string> s;

bool onBoard(int y,int x){
    if(y>=0 && y<H && x>=0 && x<W){
        return true;
    }
    return false;
}

void solve(){
    priority_queue<pair<ll,P>,vector<pair<ll,P>>,greater<pair<ll,P>>> q;
    ll d[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            d[i][j] =INF;
        }
    }
    int dy[] = {0,1};
    int dx[] = {1,0};
    q.push(make_pair(0,P(0,0)));
    d[0][0] =0;
    while(!q.empty()){
        P p = q.top().second;
        ll di = q.top().first;
        
        // cerr <<"y="<<p.first <<"x=" << p.second<<"di="<< di << endl;
        q.pop();
        if(di>d[p.first][p.second]){
            continue;
        }
       
        for(int i=0;i<2;i++){
            ll ny = p.first + dy[i];
            ll nx = p.second + dx[i];
            if(!onBoard(ny,nx)){
                continue;
            }
            if(s[p.first][p.second] == '.' && s[ny][nx] != s[p.first][p.second]){
                if(d[ny][nx] > d[p.first][p.second]+1){
                    d[ny][nx] = d[p.first][p.second]+1;
                    q.push(make_pair(d[ny][nx],P(ny,nx)));
                }
                continue;
            }else{
                if(d[ny][nx] > d[p.first][p.second]){
                    d[ny][nx] = d[p.first][p.second];
                    q.push(make_pair(d[ny][nx],P(ny,nx)));
                }

            }
           
        }
    }
    ll ans = d[H-1][W-1];
    if(s[0][0] == '#'){
        ans ++;
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    scanf("%lld",&H);
    scanf("%lld",&W);
    s.resize(W);
    for(int i = 0 ; i < W ; i++){
        std::cin >> s[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d %d", $n, $k);
while ($n--) {
	fscanf(STDIN, "%d %d", $a, $b);
	if (!isset($x[$a])) $x[$a] = 0;
	$x[$a] += $b;
}
ksort($x);
foreach ($x as $i => $c) {
	$k -= $c;
	if ($k <= 0) exit("$i");
}

Measured memory_bytes: 8952
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

int main(){
	int T;
	cin >> T;
	for(int t = 0; t < T; t++){
		int n;
		int res = 0;
		int x, y, x2, y2, w, h;
		cin >> x >> y >> w >> h;
		x2 = x + w;
		y2 = y + h;
		cin >> n;
		for(int i = 0; i < n; i++){
			int cx, cy;
			cin >> cx >> cy;
			if(x <= cx && cx <= x2 && y <= cy && cy <= y2) res++;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    for (int i = 1; i < n; i++) {
        for (int j = i; j < n; j += i) {
            cnt[j]++;
        }
    }
    cout << accumulate(all(cnt), 0) << endl;
    return 0;
}

Measured memory_bytes: 7132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

	ll ans = 0, limit = min(N, K);
	for(int i = 0; i <= limit; i++) {
		for(int j = 0; i + j <= limit; j++) {
			vector<int> v;
			for(int a = 0; a < i; a++) v.push_back(V[a]);
			for(int a = 0; a < j; a++) v.push_back(V[N - 1 - a]);

			ll sum = accumulate(v.begin(), v.end(), 0LL);

			sort(v.begin(), v.end());
			for(int a = 0; a < min(K - i - j, (int)(v.size())); a++)
				if(v[a] >= 0)
					break;
				else
					sum -= v[a];
			ans = max(ans, sum);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000000000ll
#define maxn 100010
#define inf (1ll<<60)
ll s,a[maxn],b[100];
void insert(ll x){
    FORD(i,60,0)
        if(!(s&(1ll<<i))&&(x&(1ll<<i))){
            if(!b[i]){b[i]=x;return;}
            x^=b[i];
        }
    FORD(i,60,0)
        if((s&(1ll<<i))&&(x&(1ll<<i))){
            if(!b[i]){b[i]=x;return;}
            x^=b[i];
        }
}
int main(){
    int n;
    in(n);
    FOR(i,1,n){
        in(a[i]);
        s^=a[i];
    }
    FOR(i,1,n)insert(a[i]); 
    ll ans=0;
    FORD(i,60,0)
        if(!(s&(1ll<<i))&&!(ans&(1ll<<i)))
            ans^=b[i];
    FORD(i,60,0)
        if((s&(1ll<<i))&&(ans&(1ll<<i)))
            ans^=b[i];
    printf("%lld\n",ans+(s^ans)); 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  //n++;

  string ans;
  while(n > 0){
    ans += (char)('a' + --n % 26);
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
        int n,d,x,a[100],i,j=0,s=0;
        scanf("%d %d %d",&n,&d,&x);
        for(i=0;i<n;i++) scanf("%d",&a[i]);
        for(i=0;i<n;i++){
                for (j=1; j<=d; j=j+a[i]) s++;
        }
        printf("%d\n",s+x);
        return 0;
}

Measured memory_bytes: 256
from math import floor
from collections import defaultdict


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    # divisors.sort()
    return divisors


def main():
    N = int(input())
    divlist = defaultdict(int)

    ans = 0
    for i in range(1, N+1):
        ans += i/2 * floor(N/i) * floor(1+N/i)

    print(int(ans))


def test():
    ans = 0
    for i in range(1, 10000000):
        d = Calc_Divisors(i)
        print(len(d))
        ans += len(d) * i
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68248
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class E
{
	public static void Main()
	{
		string S = GetString();
		int N = S.Length;
		int[] num = new int[26];
		for(int i = 0; i < N; i++)
			num[(int)(S[i] - 'a')]++;

		if(num.Count(x => x % 2 == 1) > 1)
		{
			Console.WriteLine(-1);
			return;
		}

		int[] p = Enumerable.Repeat(-1, N).ToArray();
		var queues = Enumerable.Range(0, 26).Select(_ => new Queue<int>()).ToArray();
		int[] used = new int[26];
		int left = 1;
		for(int i = 0; i < N; i++)
		{
			int c = (int)(S[i] - 'a');
			if(num[c] % 2 == 0)
			{
				if(used[c] * 2 >= num[c])
					continue;
			}
			else
			{
				if(used[c] * 2 + 1 > num[c])
				{
					continue;
				}
				else if(used[c] * 2 + 1 == num[c])
				{
					p[i] = (N + 1) / 2;
					used[c]++;
					continue;
				}
			}

			p[i] = left;
			queues[c].Enqueue(N - left + 1);
			left++;
			if((N % 2 == 1) && (2 * left - 1 == N))
				left++;

			used[c]++;
		}

		for(int i = N - 1; i >= 0; i--)
		{
			if(p[i] != -1)
				continue;
			
			int c = (int)(S[i] - 'a');
			p[i] = queues[c].Dequeue();
		}

		long ans = 0;
		var bit = new BinaryIndexedTree<int>(N, 0, (x, y) => x + y);
		for(int i = 0; i < N; i++)
		{
			ans += i - bit.Query(p[i]);
			bit.Update(p[i], 1);
		}
		Console.WriteLine(ans);
	}
}


public class BinaryIndexedTree<T>
{
	private int N;
	private T Identity;
	private Func<T, T, T> Func;
	private T[] bit;

	public BinaryIndexedTree(int n, T identity, Func<T, T, T> func)
	{
		N = n;
		Identity = identity;
		Func = func;
			
		bit = new T[N + 1];  // 1-index
		for(int i = 0; i <= N; i++)
			bit[i] = Identity;
	}

	public void Update(int i, T x)
	{
		while(i <= N)
		{
			bit[i] = Func(bit[i], x);
			i += i & -i;
		}
	}

	public T Query(int i)
	{
		T s = Identity;
		while(i > 0)
		{
			s = Func(s, bit[i]);
			i -= i & -i;
		}
		return s;
	}

	/* bit must be monotonically increasing */
	public int LowerBound(T key, Comparison<T> comp, Func<T, T, T> inv)
	{
		if(comp(key, Identity) <= 0)
			return 0;

		int pow = 1;
		while(pow <= N)
			pow <<= 1;
		pow >>= 1;

		int x = 0;
		for(int k = pow; k > 0; k >>= 1)
		{
			if((x + k <= N) && (comp(bit[x + k], key) < 0))
			{
				key = inv(key, bit[x + k]);
				x += k;
			}
		}

		return x + 1;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 19552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A;
  cin>>A;
  if(A%1111==0||(A-A%10)%1110==0||(A%1000)%111==0){

      cout<<"Yes"<<endl;

  }else{

      cout<<"No"<<endl;
  }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N;
  cin >> N;
  long int count=0;
  
  /*while(N>=10){
  	count = n/10;
    N/= 10;
  }*/
  if(N%2 == 0){
  	while(N>=10){
  		count += N/10;
    	N/= 10;
      	while(N>=5){
  			count += N/5;
    		N/= 5;
      	
  		}
  	} 
    cout << count << endl;
  }else{ cout << 0 << endl;}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
gcdとって簡略化するかな
0の考慮ぬけてんのか
ペアになるとりかたで１まとまりと考えるか
1 0
1 0
1 0
0 1
0 1
なら、この5個で１かたまり、
1 0=2^3
0 1=2^2
=12通りから全部とらないが重複してるから-1=11通り
*/

int main(){
  ll N,MOD=1e9+7, zero=0, ans=1;
  cin>>N;
  map<pair<ll,ll>,ll> M;
  vector<ll> Z(N+1,2);
  Z[0]=1;
  for(ll i=1; i<=N; i++) (Z[i]*=Z[i-1])%=MOD;
//まずmapつくる
  for(ll i=0; i<N; i++){
    ll a,b; cin>>a>>b;
    if(a==0 && b==0){
      zero++;
      continue;
    }
    if(a!=0 && b!=0){
      ll c=__gcd(a,b);
      a/=c;
      b/=c;
      M[make_pair(a,b)]++;
    }
    else if(a==0) M[make_pair(0,1)]++;
    else if(b==0) M[make_pair(1,0)]++;
  }
//数え上げ
  for(auto v: M){//0 0は除外
    ll val1=v.second;
    if(val1==-1) continue;
    ll a=v.first.first;
    ll b=v.first.second;
    ll val2=0;
    if(a!=0 && b!=0){
      val2+=M[make_pair(b,-a)];
      val2+=M[make_pair(-b,a)];
    }
    else if(a==0) val2+=M[make_pair(1,0)];
    else if(b==0) val2+=M[make_pair(0,1)];
    (ans*=(Z[val1]+Z[val2]-1LL)%MOD)%=MOD;//どちらもとらないが重複で-1 or Z[0]=1が余分
    if(a!=0 && b!=0){
      M[make_pair(b,-a)]=-1;
      M[make_pair(-b,a)]=-1;
    }
    else{
      M[make_pair(1,0)]=-1;
      M[make_pair(0,1)]=-1;
    }
  }
  ans--;
  ans+=zero;
  if(ans<0) ans+=MOD;
  cout<<ans<<endl;  
}

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cntR=0, cntB=0;
    for(int i=0; i<N; i++) {
        if(S[i]=='R') cntR++;
        else cntB++;
    }
    if(cntR>cntB) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        int n, x, count = 0;
        boolean flag = false;
        Scanner sc = new Scanner(System.in);
        while (true) {
            n = sc.nextInt();
            x = sc.nextInt();
            if (n == 0 && x == 0)
                break;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    for (int k = 1; k <= n; k++) {
                        if (i + j + k == x)
                            flag = true;
                        if (i == j || j == k || k == i)
                            flag = false;
                        if (flag) {
                            count++;
                        }
                        flag = false;
                    }
                }
            }
            System.out.println(count / 6);
            count = 0;
        }
    }
}

Measured memory_bytes: 26744
n = int(input())
list = list(range(1,n+1))

list_Fizz = [i for i in list if i % 3 == 0]
list_Buzz = [i for i in list if i % 5 == 0]
list_FizzBuzz = [i for i in list if i % 15 == 0]

print(sum(list) - sum(list_Fizz) - sum(list_Buzz) + sum(list_FizzBuzz))


Measured memory_bytes: 53000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,K;
  cin>>N>>K;
  VI A(N);
  rep(i,N) cin>>A[i];
  int X=0;
  while(K){
    if(K&1) X=A[X]-1;
    VI tmp(N);
    rep(i,N) tmp[i]=A[A[i]-1];
    A.swap(tmp);
    K>>=1;
  }
  cout<<X+1<<endl;
}

Measured memory_bytes: 5156
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[1010];
int main()
{
  ll n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  sortup(a,n);
  printf("%lld\n",a[n-1]-a[0]);
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < k; ++i) {
        res += a[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cmath>

using namespace std;

int n,m,i,j,k,t,c,ax[51],ay[51],bx[51],by[51];

int main() {
	scanf("%d%d",&n,&m);
    for (i = 1;i <= n;i++) {
    	scanf("%d%d",&ax[i],&ay[i]);
    }
    for (i = 1;i <= m;i++) {
    	scanf("%d%d",&bx[i],&by[i]);
    }
    for (i = 1;i <= n;i++) {
    	t = 2147483647;
    	for (j = 1;j <= m;j++) {
    		if (t > abs(ax[i] - bx[j]) + abs(ay[i] - by[j])) {
    			t = abs(ax[i] - bx[j]) + abs(ay[i] - by[j]);
    			c = j;
    		}
    	}
    	printf("%d\n",c);
    }
}

Measured memory_bytes: 128
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

def main():
    n, k=map(int, input().split())
    a = list(map(int, input().split()))
    ans = bubble_sort(a) * k % mod
    div2 = inverse(2)
    # a.sort()
    lft = 0
    rgt = 0
    while lft < n:
        while rgt < n and a[lft] == a[rgt]:
            rgt += 1
        ans = (ans + (rgt - lft) * (n - rgt) % mod * k % mod * (k-1) * div2 % mod) % mod
        lft =rgt

    print(ans)
main()


Measured memory_bytes: 39920
n, m = map(int, input().split())
l = [list(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
l = l[::-1]

color = [[] for _ in range(n)]
for i in range(n):
    color[i] = [[i], 1]
#print(color)

check = []
for i in range(n):
    check.append(i)

v = 0
ans = []

for i in range(m):
    c1 = color[check[l[i][0]]]
    c2 = color[check[l[i][1]]]
    value = 0
    if c1 == c2: 
        pass
    else:
        value = c1[1] * c2[1]
        if c1[1] >= c2[1]:
            c1[1] += c2[1]
            c1[0] += c2[0]
            tmp = c2[0]
            for j in range(len(tmp)):
                check[tmp[j]] = check[l[i][0]]
            c2[0] = []
            c2[1] = 0
        else:
            c2[1] += c1[1]
            c2[0] += c1[0]
            tmp = c1[0]
            for j in range(len(tmp)):
                check[tmp[j]] = check[l[i][1]]
            c1[0] = []
            c1[1] = 0

    #print(i, l[i])
    #print(check)
    #print(color)
    v += value
    ans.append(n*(n-1)//2 - v)
    #print("--------")

ans = ans[::-1]
ans.append(n*(n-1)//2)
#print(ans)

for i in range(1, len(ans)):
    print(ans[i])


Measured memory_bytes: 111576
import sys
import math
sys.setrecursionlimit(10**6)
from collections import defaultdict

n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    if i>=k:
        ans+=1/n
    else:
        ans+=1/(n*2**int(1-1/(10**9)+math.log((k/i),2)))
#print(i,2**int(math.log((k/i),2)),ans)
print(ans)

Measured memory_bytes: 3564
n, m = map(int ,input().split())
 
adj = [[] for _ in range(n)]
 
for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    adj[a].append(b)
    adj[b].append(a)
 
from collections import deque
q = deque()
 
dist = [-1] * n
ans = [0] * n
 
q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1:continue
        dist[to] = dist[now] + 1
        q.append(to)
        ans[to] = now
 
print("Yes")
for i in range(1, n):
    print(ans[i] + 1)

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

int n;
vector<int> a;

int solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  cout << solve() << endl;
  return 0;
}

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

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

using namespace std;

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

    vector<int> A(N+1);
    vector<int> B(N+1);
    vector<int> C(N);
    int sum = 0;
    
    for(int i=1; i<=N; i++) cin >> A.at(i); 
    for(int i=1; i<=N; i++) cin >> B.at(i);
    for(int i=1; i<=N-1; i++) cin >> C.at(i);
    
    for(int i=1; i<=N; i++){
        sum += B.at(A.at(i));
    }
    for(int i=1; i<N; i++){
        if(A.at(i+1) - A.at(i) == 1){
            sum += C.at(A.at(i));
        }
    }
    
    cout << sum << endl;
        
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
flagBIG = 0
BIG = 0
SMALL = 0
i=1
while i<N:
    if A[i] == A[i-1] and flagBIG == 1:
        SMALL = A[i]
        break
    if A[i] == A[i-1] and flagBIG == 0:
        BIG = A[i]
        flagBIG = 1
        i = i+1
    i=i+1
if BIG!= 0 and SMALL!=0:
    print(BIG*SMALL)
else:
    print(0)

Measured memory_bytes: 14224
# coding=utf-8

if __name__ == '__main__':
    N, M = map(int, input().split())
    cut_list = []
    demand_list = [list(map(int, input().split())) for i in range(M)]
    demand_list.sort()

    # demand_list2 = [demand_list[0]]
    previous_demand = demand_list[0]
    demand_list = demand_list[1:]
    counter = 1

    if M == 1:
        print(counter)
    else:
        for demand in demand_list:
            if previous_demand[0] == demand[0]:
                pass
            elif previous_demand[1] <= demand[0]:
                previous_demand = demand
                counter += 1
            else:
                previous_demand = [demand[0], min(previous_demand[1], demand[1])]

        print(counter)


Measured memory_bytes: 28304
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  ll n, k;
  cin >> n >> k;
  ll a[n] = {};
  ll fir = 0, sec = 0;
  REP(i, n) {
    cin >> a[i];
    REP(j, i) {
      if(a[j] > a[i]) fir++;
    }
  }
  REP(i, n)REP(j, n) {
    if (a[j] > a[i]) sec++;
  }
  fir %= 1000000007;
  fir *= k;
  fir %= 1000000007;
  sec %= 1000000007;
  sec *= k;
  if(k%2==0)
      sec /= 2;
  sec %= 1000000007;
  sec *= k - 1;
  if((k-1)%2==0)
      sec /= 2;
  sec %= 1000000007;
  ll ans = fir + sec;
  ans %= 1000000007;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long countOfSubarrays(vector<int>&arr)
{	
	int n = arr.size();
	vector<vector<int>>bitPos(20,vector<int>(n));
	for(int bit=0;bit<20;bit++)
	{
		for(int i=0;i<arr.size();i++)
		{
			bitPos[bit][i] = ((arr[i]>>bit)&1);
		}
}

vector<vector<int>>dp(n,vector<int>(20));
vector<int>maxRange(n,n);
for(int bit=0;bit<20;bit++)
{
	int lastIdx = n;
	for(int i = n-1;i>=0;i--)
	{
			if(bitPos[bit][i])
			{
				dp[i][bit] = lastIdx;
				lastIdx = i;
}
else{
	if(i==n-1) dp[i][bit] = n;
	else{
		dp[i][bit] = dp[i+1][bit];
}
}
maxRange[i] = min(maxRange[i] , dp[i][bit]);
}
}

long long reqCnt = 0;
for(int i=0;i<n;i++)
{
	reqCnt+=maxRange[i] - i;
}
return reqCnt;
}

void solve()
{
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0;i<n;i++)
	cin>>arr[i];
	long long ans = countOfSubarrays(arr);
	cout<<ans<<endl;
	
}
int main()
{
	solve();
}


Measured memory_bytes: 43896
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	boolean isSquare(int n) {
		for (int i = (int)Math.sqrt(n); i*i <= n; i++) {
			if (i*i == n) return true;
		}
		return false;
	}
	
	void run() {
		int n;
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			int ans = 0;
			
			for (int i = 1; i*i <= n; i++) {
				if (n-i*i == 0) ans++;
				for (int j = i; j*j <= n-i*i; j++) {
					if (n-i*i-j*j == 0) ans++;
					for (int k = j; k*k <= n-i*i-j*j; k++) {
						if (n-i*i-j*j-k*k == 0) ans++;
						else if (k*k <= n-i*i-j*j-k*k && isSquare(n-i*i-j*j-k*k)) ans++;
					}
				}
			}
			
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 20124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int dp[1000]={};
	string t,b;
	cin>>t>>b;

	rep(i,t.size()){
		rrep(j,b.size()){
			if(t[i]==b[j]){
				dp[j]+=dp[j-1];
				dp[j]%=np;
			}
		}
		if(t[i]==b[0])dp[0]++;
	}
	cout<<dp[b.size()-1]<<endl;

	return 0;
}



Measured memory_bytes: 3220
// StrucuredProgramming.cc
// goto 文は、C/C++言語などで使うことのできる文で、実行されると無条件に
// 指定されたラベルに処理が飛びます。
// 例えば goto CHECK_NUM; という文が実行されると、プログラムの中で
// CHECK_NUM: と書かれた行に処理が移ります。
// この機能を使って、繰り返し処理なども実現することができます。
// 一方、goto 文は自由度が高すぎ、プログラムの可読性に影響するため、
// 可能な限り使わないことが推奨されています。
//
// 次のC++言語のプログラムと同じ動作をするプログラムを作成してください。
// ただし、goto 文は使わないで実装してみましょう。
//
// void call(int n){
//   int i = 1;
//  CHECK_NUM:
//   int x = i;
//   if ( x % 3 == 0 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//  INCLUDE3:
//   if ( x % 10 == 3 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//   x /= 10;
//   if ( x ) goto INCLUDE3;
//  END_CHECK_NUM:
//   if ( ++i <= n ) goto CHECK_NUM;
// 
//   cout << endl;
// }
// 【入力】
// １つの整数 nが１行に与えられます。
// 【出力】
// 上記プログラムに入力の整数 nを与えた結果を出力してください。
// 【制約】
// 3≤n≤10000
// 【例】
// 入力：
// 30
// 出力：
//  3 6 9 12 13 15 18 21 23 24 27 30
#include<iostream>
using namespace std;

void call( int n) {
  int cnt = 0;
  for ( int i = 1; i <= n; i++) {
    int x = i;
    if ( x % 3 == 0) {
      cout << " " << i;
    } else {
      for ( ; x;  x /= 10) {
	if ( x % 10 == 3) {
	  cout << " " << i;
	  break;
	}
      }
    }
  }
  cout << endl;
}

int main( void) {
  int n;

  cin >> n;

  call( n);

  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int min(int a, int b)
{
    return (a < b ? a : b);
}

int read_file(char *fname, char **buf) // ??????????????? fname, ?????????????????? buf (????????¢??°?????§?????¢????¢????)
{
    int n;
    char *p;
    FILE *fin;

    fin = fopen(fname, "r"); // ?????????????????????????????¢????????§????????????
    if (fin == NULL) { // ??????????????§??????????????°??¨????????????
        printf("cannot open %s\n", fname);
        exit(1);
    }

    fseek(fin, 0, SEEK_END);
    n = ftell(fin); // ??????????????????????????????
    fseek(fin, 0, SEEK_SET);
    p = (char *)malloc(n * sizeof(char)); // ???????????????????´????????????¢???????¢????
    if (p == NULL) {
        printf("not enough memory\n");
        exit(1);
    }

    fread(p, sizeof(char), n, fin); // ?????¢??? p ??? n ??????????????????
    fclose(fin); // ????????????????????????
    *buf = p; // ????????????????´????????????????????????¢??°?????????????????´?????????

    return (n); // ?????????????????????
}

int lehvenstein_distance(int n, int m, char *s, char *t)
{
    int **dp;
    int i, j;
    int ans;

    dp = (int **)malloc(sizeof(int *) * (n + 1));

    for (i = 0; i <= n; i++){
        dp[i] = (int *)malloc(sizeof(int) * (m + 1));
        for (j = 0; j <= m; j++) dp[i][j] = 1001001001;
    }

    for (i = 0; i <= n; i++) dp[i][0] = i;
    for (j = 0; j <= m; j++) dp[0][j] = j;

    for (i = 1; i <= n; i++){
        for (j = 1; j <= m; j++){
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s[i - 1] != t[j - 1]));
        }
    }

    ans = dp[n][m];

    for (i = 0; i <= n; i++) free(dp[i]);
    free(dp);

    return (ans);
}

int main(int argc, char *argv[])
{
    int n, m;
    int c;
    //char *X, *Y;
    char X[1024], Y[1024];

    //if (argc < 3) { // ??????????????????????????°????¶???????????????°??????
    //    printf("%s file1 file2\n", argv[0]); // argv[0] ???????????°??????????????\??£?????????
    //    return (-1);
    //}

    //n = read_file(argv[1], &X); // 1???????????????????????? X ???????????????
    //m = read_file(argv[2], &Y); // 2???????????????????????? Y ???????????????

    //printf("%s %s\n", X, Y);

    scanf("%s", X);
    scanf("%s", Y);

    n = strlen(X) + 1; m = strlen(Y) + 1;

    //X[n - 1] = Y[m - 1] = 0;

    c = lehvenstein_distance(n - 1, m - 1, X, Y); // X ??¨ Y ?????¨????????¢????¨????

    printf("%d\n", c); // ???????????????

    //free(X);
    //free(Y);

    return (0);
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007
void init();
void solve();

signed main()
{
	init();
	solve();
}

struct BIT {
	vector<vector<int>> node;
	int n;
	BIT(int n_) : node(n_+1, vector<int>(n_+1, 0)), n(n_) {}
	void add(int r, int c, int v) {
		for (int i = r+1; i <= n; i += i & -i) {
			for (int j = c+1; j <= n; j += j & -j) {
				node[i][j] += v;
			}
		}
	}
	int get(int r, int c) {
		int res = 0;
		for (int i = r+1; i; i -= i & -i) {
			for (int j = c+1; j; j -= j & -j) {
				res += node[i][j];
			}
		}
		return res;
	}
	int get_sum(int r1, int c1, int r2, int c2) {
		return get(r2, c2) - get(r1, c2) - get(r2, c1) + get(r1, c1);
	}
};

void init()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	BIT bit(N);
	rep(i, M) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		bit.add(l, r, 1);
	}
	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		l-= 2;
		r--;
		cout << bit.get_sum(l, l, r, r) << endl;
	}
}

void solve()
{
}

Measured memory_bytes: 1920
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int H, W;
int a[1010][1010];

signed main() {
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> a[i][j];
    }
  }

  int cont = 0;
  vector<P> v1, v2;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (a[i][j] % 2 == 1) {

        if (j != W) {
          cont++;
          v1.push_back(P(i, j));
          v2.push_back(P(i, j + 1));
          a[i][j + 1]++;
        }
      }
    }
  }

  for (int i = 1; i < H; i++) {
    if (a[i][W] % 2 == 1) {
      cont++;
      v1.push_back(P(i, W));
      v2.push_back(P(i + 1, W));
      a[i + 1][W]++;
    }
  }

  cout << cont << endl;

  for (int i = 0; i < cont; i++) {
    cout << v1[i].first << " " << v1[i].second << " ";
    cout << v2[i].first << " " << v2[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 10340
#3_1_1
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
c.sort()
ans = 0
for i in range(n):
    ue = bisect.bisect_left(a,b[i])
    sita = n - bisect.bisect_right(c,b[i])
    ans += ue * sita
print(ans)

Measured memory_bytes: 23232