akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

typedef long long ll;

int N;
vector<int> A, B, D;

void input_init(void) {
	cin >> N;
	A.resize(N);
	B.resize(N);
	D.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	for (int i = 0; i < N; ++i)
		cin >> B[i];
	for (int i = 0; i < N; ++i)
		D[i] = A[i] - B[i];
}

int solve(void) {
	ll sum = accumulate(D.begin(), D.end(), (ll)0);
	if (sum < (ll)0)
		return -1;

	sort(D.begin(), D.end());
	int cnt = 0;
	ll minus_v = (ll)0;
	for (int i = 0; i < N; ++i) {
		if (D[i] >= 0)
			break;
		minus_v += (ll)D[i];
		++cnt;
	}
	if (cnt != 0) {
		for (int i = N - 1; i >= 0; --i) {
			++cnt;
			minus_v += (ll)D[i];
			if (minus_v >= 0)
				break;
		}
	}
	return cnt;
}

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

	input_init();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


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

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

	int N, X; cin >> N >> X;
	int l[110];
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	int sum = 0;
	int c = 0;
	while(sum <= X){
		sum += l[c];
		c++;
	}
	cout << c;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string o, e;
  cin >> o >> e;

  for(int i=0;i<SZ(e);++i)
	cout << o[i] << e[i];
  if(SZ(o) != SZ(e))
	cout << o.back();
  cout << endl;

  return 0;
}


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

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

int main() {
  int N, X;
  cin >> N >> X;
  int x[100000];
  for (int i = 0; i < N; i++) cin >> x[i];
  int acc = 0;
  for (int i = 0; i < N; i++) {
    int distance = abs(X - x[i]);
    acc = gcd(acc, distance);
  }
  cout << acc << endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static int N;
	static int[] w, v;
	static long[][] memo;

	static long dp(int idx, int remW) {
		if(remW < 0)
			return -(int)1e9;
		if (idx == N)
			return 0;
		if (memo[idx][remW] != -1)
			return memo[idx][remW];

		long take = v[idx] + dp(idx + 1, remW - w[idx]);
		long leave = dp(idx + 1, remW);
		return memo[idx][remW] = Math.max(take, leave);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int W = sc.nextInt();
		w = new int[N];
		v = new int[N];
		for (int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		memo = new long[N][W+1];
		for (long[] l : memo)
			Arrays.fill(l, -1);
		System.out.println(dp(0, W));

	}

}


Measured memory_bytes: 131572
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,a,b,j;
    string s,t;
    cin>>a>>b;
   if(a%b==0)
   cout<<"0";
   else cout<<"1";
    return 0;
}





Measured memory_bytes: 3656
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll N, M, tmp;
  vector<ll> A;
  cin >> N >> M;
  for(ll i = 0; i < M; i++){
    cin >> tmp;
    A.push_back(tmp);
  }

  ll ans = N;
  for(ll i = 0; i < M; i++){
    ans -= A[i];
  }

  cerr << "Answer:" << endl;
  cout << max(ans, -1LL) << endl;

  return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MAXN = 1e5+200;
int main(){
    ll n;
    cin>>n;
    ll i = 0;
    if(n <=2){
      cout<<4<<endl;
      return 0;
    }
    while(n > 1){
      if(n % 2 == 0){
        n /= 2;
      }else{
        n = n * 3 + 1;
      }
      i++;
    }
    cout<<i+2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 2000;
const int N2 = N * 2 + 1;
const int MOD = 998244353;

void update(int& x, int a)
{
  x += a;
  if (x >= MOD) {
    x -= MOD;
  }
}

char s[N + 1];
int dp[2][N2];

int main()
{
  scanf("%s", s);
  int n = strlen(s);
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  int reds = 0, blues = 0;
  for (int i = 0; i < 2 * n; ++ i) {
    memset(dp[i + 1 & 1], 0, sizeof(dp[i + 1 & 1]));
    int b = i < n ? s[i] - '0' : 0;
    int r = i < n ? 2 - b : 0;
    for (int j = 0; j <= i; ++ j) {
      if (dp[i & 1][j]) {
        if (j + 1 <= reds + std::min(r, 1)) {
          update(dp[i + 1 & 1][j + 1], dp[i & 1][j]);
        }
        if (i - j + 1 <= blues + std::min(b, 1)) {
          update(dp[i + 1 & 1][j], dp[i & 1][j]);
        }
      }
    }
    reds += r;
    blues += b;
  }
  int result = 0;
  for (int j = 0; j <= 2 * n; ++ j) {
    update(result, dp[2 * n & 1][j]);
  }
  printf("%d\n", result);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 1
if(A.count(0) != 0):
    print("0")
    exit()
else:
    for i in range(N):
        ans = ans * A[i]
        if(ans > 10**18):
            print("-1")
            exit()
print(str(ans))

Measured memory_bytes: 21576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int a=n/100;
  int s=n%100;
  int g=5;
  int cut=0;
  while(1){
    if(s==0){
      break;
    }
    if(s<g){
      g--;
      continue;
    }
    s-=g;
    cut++;
  }
  if(cut>a) cout<<0<<endl;
  else cout<<1<<endl;
}
  

Measured memory_bytes: 384
# -*- coding:utf-8 -*-

def solve():
    W, H, x, y = list(map(int, input().split()))

    # 面積の大きくない方の最大値って面積の半分のことじゃね？
    area_ans = W*H/2

    # x,yが長方形の重心にあるなら無限の直線で分割できる(1)
    # そうでないなら、たった一本が存在する？

    if x==W/2 and y==H/2:
        is_sep = 1
    else:
        is_sep = 0
    
    print(area_ans, is_sep)


if __name__ == "__main__":
    solve()


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

int main()
{
	int n, m, x, k, hi=0, lo=0;
	cin>>n>>m>>x;

	while(m--){
		cin>>k;
		if(k>x)hi++;
		else lo++;
	}

	cout << min(hi,lo) << endl;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

    for(int i=0;i<s.size();i+=w){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 1e6+6,mod=1e8,mod2=998244353;
void files(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void solve() {
    int a,b;
    cin>>a>>b;
    a+=b;
    cout<<a%24<<endl;
}
int main() {
    run();
    //files();
   // int t = 1;
solve();

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fatafat                                                                \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define int long long
#define MOD ((long long)(1e9) + 7)
#define excl(i, a, b) for (int i = a; i < b; i++)
#define incl(i, a, b) for (int i = a; i <= b; i++)
#define mp(a, b) make_pair(a, b)
#define ff first
#define ss second
#define PII pair<int, int>

using namespace std;

int binexp(int a, int b) {
  if (b) {
    if (b % 2)
      return a * binexp(a * a, b / 2);
    return binexp(a * a, b / 2);
  }
  return 1;
}

int modexp(int a, int b, int m) {
  if (b) {
    if (b % 2)
      return (a * modexp((a * a) % m, b / 2, m)) % m;
    return modexp((a * a) % m, b / 2, m);
  }
  return 1;
}

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

int euclidgcd, euclidx, euclidy;

void exteuclid(int a, int b) {
  if (b == 0) {
    euclidgcd = a;
    euclidx = 1;
    euclidy = 0;
  } else {
    exteuclid(b, a % b);
    int temp = euclidx;
    euclidx = euclidy;
    euclidy = temp - euclidy * (a / b);
  }
}

int modinv(int a, int m) {
  exteuclid(a, m);
  return (euclidx % m + m) % m;
}

int pmodinv(int a, int m) { return modexp(a, m - 2, m); }

bool checkprime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0)
      return false;
  return true;
}

vector<bool> seive(int n) {
  vector<bool> ret(n + 1, true);
  ret[0] = ret[1] = false;
  for (int i = 2; i * i <= n; i++)
    if (ret[i])
      for (int j = i * i; j <= n; j += i)
        ret[j] = false;
  return ret;
}

vector<bool> seivelims(int l, int r) {
  vector<bool> ret(r - l + 1, true);
  for (int i = 2; i * i <= r; i++) {
    for (int j = max(i * i, ((l + i - 1) / i) * i); j <= r; j += i) {
      ret[j - l] = false;
    }
  }
  return ret;
}

vector<int> rootnfact(int n) {
  vector<int> ret;
  for (long i = 2; i * i <= n; i++)
    while (n % i == 0) {
      ret.push_back(i);
      n /= i;
    }
  if (n != 1)
    ret.push_back(n);
  return ret;
}

vector<int> prelognfact(int n) {
  vector<int> minprime(n + 1, 0);
  minprime[0] = minprime[1] = 0;
  for (int i = 2; i * i <= n; i++) {
    if (minprime[i] == 0) {
      for (int j = i * i; j <= n; j += i) {
        if (minprime[j] == 0)
          minprime[j] = i;
      }
    }
  }
  for (int i = 2; i <= n; i++)
    if (minprime[i] == 0)
      minprime[i] = i;
  return minprime;
}

vector<int> lognfact(int n, vector<int> minprime) {
  vector<int> ret;
  while (n != 1) {
    ret.push_back(minprime[n]);
    n /= minprime[n];
  }
  return ret;
}

int temp, temp1, temp2;

signed main() 
{ 
    fatafat; 
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int max=-1,cnt=0;
    bool found=false;
    for(int i=0;i<n;i++)
    {
        found=false;
        for(int j=0;j<i;j++)
        {
            if(arr[j]>arr[i])
            {
                found=true;
                break;
            }
        }
        if(!found)
            cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

double dp[3000][3000];
int main() {
  int n;
  cin >> n;
  vector<double> p(n);
  rep(i,n)cin >> p[i];

  dp[0][0] = 1;
  rep(i,n){
    rep(j,n){
      dp[i+1][j+1] += dp[i][j]*p[i];
      dp[i+1][j] += dp[i][j]*(1.0-p[i]);
    }
  }
  int m= n/2+1;
  double ans = 0;
  srep(j,m,n+1){
    ans+=dp[n][j];
    
  }
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vvi v;
vi d;
map<pii,int> m;

void dfs(int now,int par) {
  for(int x:v[now]) {
    if(x==par) continue;
    d[x]=d[now]+m.find(make_pair(now,x))->second;
    dfs(x,now);
  }
}

int main() {
  int N;
  cin >> N;
  vi w(N-1);
  v=vvi(N);
  rep(i,N-1) {
    int u,u2;
    cin >> u >> u2 >> w[i];
    v[u-1].push_back(u2-1);
    v[u2-1].push_back(u-1);
    m.insert(make_pair(make_pair(u-1,u2-1),w[i]));
    m.insert(make_pair(make_pair(u2-1,u-1),w[i]));
  }
  
  d=vi(N);
  dfs(0,-1);
  rep(i,N) {
    if(d[i]%2) cout << 1 << endl;
    else cout << 0 << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

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

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

void solve() {
  int N, A, B; cin >> N >> A >> B;
  string s; cin >> s;
  int a = 0, b = 0;
  rep(i, s.size()) {
    if (s[i] == 'a') {
      if (a + b < A + B) { yes(); a++; }
      else no();
    } else if (s[i] == 'b') {
      if (a + b < A + B && b + 1 <= B) { yes(); b++; }
      else no();
    } else {
      no();
    }
  }
}


Measured memory_bytes: 848
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: usize = scan(tokens);
    let n: usize = scan(tokens);
    let a: Vec<usize> = vec(n, |_| scan(tokens));
    let mut max = k - a[n - 1] + a[0];
    for i in 1..n {
        max = std::cmp::max(max, a[i] - a[i - 1]);
    }
    println!("{}", k - max);
}


Measured memory_bytes: 8444
//default library
#include <stdio.h>
#include <string.h>
//extra library


//default define
#define ll long long int
#define fl(i,a,n) for(int i = a; i < (n); i++)
#define fls(i,a,s) for(int i = a; s[i] != '\0'; i++)
#define endl puts("");
#define kill return 0;

//extra define


//declare function


//main code
int main() {
	char str[1001];
	scanf("%s", str);
	int len = strlen(str)-1;
	printf("%s", str);
	if(str[len] == 's'){
		puts("es");
	}else if(str[len] != 's'){
		puts("s");
	}
    return 0;
}

//functions




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

int main() {
    string  a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N = int(input())
L = inpl()
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        k = bisect_left(L,L[i]+L[j],j,N) - (j+1)
        ans += k
print(ans)

Measured memory_bytes: 44812
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,X,Y;
int ans[2000];

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

    for(int i=1;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
            int k=min(abs(i-j),abs(i-X)+1+abs(j-Y));
            ans[k]++;
        }
    }

    repn(i,N-1) cout<<ans[i]<<endl;
}

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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;
            string a = "Christmas", b = "Eve";
            D = int.Parse(Console.ReadLine());
            if (D <= 25)
            {
                Console.Write(a);
                if (D <= 24)
                {
                    Console.Write( " "+b);
                    if (D <= 23)
                    {
                        Console.Write(" "+b);
                        if (D <= 22)
                        {
                            Console.Write(" " + b);
                        }
                    }
                }
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
long long mod = 1e9+7;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}

long long factorial(long long n){
	long long fact = 1;
  	for(long long i=1;i<=n;++i){
      fact = (fact*i)%mod;
    }
  	return fact;
}


long long C(long long n, long long r) {
    if(r==0)return 1;
  	if(r==1)return n;
  	return (factorial(n)%mod * power(factorial(n-r),mod-2)%mod * power(factorial(r),mod-2)%mod)%mod;
}

int main(){
	long long n,ans=0,mul=3,current,diff,i=1;
  	
  	cin>>n;
  	diff = n - mul;
   
    while(diff>=0){
      current = (C(diff+i-1,i-1))%mod;
      ans=(ans+(current)%mod)%mod;
      mul += 3;
      diff = n - mul;
      ++i;
    }
  
  	cout<<ans;
    return 0;
}


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

int main()
{
    char c;
    cin >> c;

    string vowel = "aeiou";
    string output = "consonant";
    for (int i = 0; i < vowel.size(); i++)
    {
        if (vowel.at(i) == c)
        {
            output = "vowel";
            break;
        }
    }
    cout << output << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 int x,y;
 cin>>x>>y;
 cout<<x*y;
}

Measured memory_bytes: 3596
n = gets.to_i
str = gets.chomp

dp = Array.new(n, 0)

acc_w = 0
acc_e = 0

1.upto(n - 1) do |i|
  acc_w += 1 if str[i - 1] == "W"
  dp[i] += acc_w
  acc_e += 1 if str[n - i] == "E"
  dp[n - i - 1] += acc_e
end

puts dp.min

Measured memory_bytes: 4868
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18, cs;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code
    

        cin>>n;
        if(n==0) cout<<1<<endl;
        else cout<<0<<endl;
        
    
    
    //code
    return 0;
}




Measured memory_bytes: 50520
#include <stdio.h>
#include <math.h>
#define NUM 1000000007

int pow_mod(int m, int n){
    if(n==0) return 1;
    
    int s = pow_mod(m, n/2);
    
    long long t = (long long)s*s%NUM;
    
    if(n%2==1) t = t*m%NUM;
    
    return t;
}

int main(void){
    int m, n;

    scanf("%d %d", &m, &n);
    printf("%d\n", pow_mod(m, n));
    
    return 0;
    
}




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

double add(int a){
    double sum=0;
    rep(i,a){
        sum += i+1;
    }
    
    return sum/a;
}
int main(){
    int n,k;cin >> n >> k;
    deque<double>q;
    double MAX=0,sum=0;
    rep(i,n){
        int a;cin>>a;
        if(q.size()<k){
            q.push_back(add(a));
            sum+=q[i];
        }else{ 
            if(MAX<sum){
                MAX = sum;
            }
            sum-=q[0];
            q.pop_front();   
            q.push_back(add(a));    

            sum+=q[k-1];
            if(MAX<sum){
                MAX = sum;
            }
        }
    }
    if(n==k)rep(i,n)MAX+=q[i];
    cout <<fixed<<setprecision(7)<< MAX << endl;
    return 0;
}


Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//↑templete
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
int main(){
	//%MOD下での階乗
	ll ex[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		ex[i]=ex[i-1]*i%MOD;
	}
	//%MOD下での階乗の逆数
	ll inv[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		inv[i]=mod_pow(i,MOD-2,MOD);
	}
	for(int i=1;i<SIZE;i++){
		inv[i]=inv[i-1]*inv[i]%MOD;
	}
	int X, Y;
	cin>>X>>Y;
	for(int a=0;a<=X;a++){
		if((X-a)%2)
			continue;
		int b=(X-a)/2;
		if(2*a+b!=Y)
			continue;

		//(1, 2)をa回、(2, 1)をb回
		ll ans=ex[a+b]%MOD*inv[a]%MOD*inv[b];
		cout<<ans%MOD<<endl;
		return 0;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 16000
import sys
s = input()
t = input()
if len(t) > len(s):
    print('UNRESTORABLE')
    sys.exit()
elif len(t) == len(s):
    print(t)
    sys.exit()
diff = len(s)-len(t)
for i in range(diff,-1,-1):
    target = s[i:len(t)+i]
    for ta,te in zip(target,t):
        if ta != '?' and ta != te:
            break
    else:
        tmp = list(s)
        tmp[i:len(t)+i] = t
        print(''.join(tmp).replace('?','a'))
        sys.exit()
print('UNRESTORABLE')

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

main(){
    string game;
    while( cin >> game && game != "0") {
	int A = 0, B = 0;
	for ( int i = 1; i < game.size(); i++ ) {
	    if ( game[i] == 'A' ) A++;
	    else B++;
	}
	(A > B) ? A++ : B++;
	cout << A << " " << B << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN=1e5+5;
const ll inf=(1ll<<63-1);
ll a[MAXN];
ll dp[MAXN];
int main()
{
 
    ll n,e,t;
    cin>>n>>e>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,(ll)0x3f3f3f3f,sizeof(dp));
    dp[0]=0;
    ll mn=inf;
    for(int i=1,now=0;i<=n;i++){
        while(t<=2*(a[i]-a[now+1]))
        {
            mn=min(mn,dp[now]-2*a[now+1]);
            now++;
        }
        dp[i]=dp[now]+t;
        dp[i]=min(dp[i],mn+2*a[i]);
 
    }
    cout<<e+dp[n]<<endl;
    return 0;
 
}


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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r) {
  if (l>=r) {
    return ;
  }
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}
void solve() {
  pos=0;
  rec(0,pre.size());
  for (int i=0; i<n; i++) {
    if (i) {
      cout<<" "<<flush;
    }
    cout<<post[i]<<flush;
  }
  cout<<endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin>>n;
  int s;
  for (int i=0; i<n; i++) {
    cin>>s;
    pre.push_back(s);
  }
  for (int i=0; i<n; i++) {
    cin>>s;
    in.push_back(s);
  }
  solve();
  return 0;
}



Measured memory_bytes: 3180
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
var sc = bufio.NewScanner(os.Stdin)

const MAX = 1000000000000000000

var N int

func main() {
	N = nextInt()
	pfs := PrimeFactors(N)
	m := make(map[int]int, len(pfs))
	for i := 0; i < len(pfs); i++ {
		s := pfs[i]
		//mapにkeyが存在するか判定
		if _, ok := m[s]; ok {
			m[s]++
		} else {
			m[s] = 1
		}
	}

	ans := 0
	//fmt.Println(m)
	for _, v := range m {
		u := 1
		for {
			v -= u
			if v < 0 {
				break
			}
			ans++
			u++

			//fmt.Println(u, q, v, ans)
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1764
import java.util.*;
 class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] c = s.toCharArray();
        int[] a = new int[c.length];
        for (int i = 0; i < c.length; i++){
            a[i] = (c[i] + n) % 91;
            if (a[i] <65){
                a[i] += 65;
            }
        }
        for (int i = 0; i < c.length; i++){
            c[i] = (char)a[i];
        }
        String ss = new String(c);
        System.out.println(ss);
    }
}


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

int main() {
    int A, B;
    string S, T, U;
    
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    
    if (U==S){
        A--;
    }
    else{
        B--;
    }
    
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		int i = 1;

		do{
			int x = i;
			if(x % 3 == 0){
				System.out.print(" " + i);
			}else{
				do{
					if(x % 10 == 3){
						System.out.print(" " + i);
						break;
					}else{
						x /= 10;
					}
				}while(x != 0);
			}
		}while( ++i <= n);
		System.out.print("\n");

	}

}

Measured memory_bytes: 24264
#include <iostream>
#include "vector"
using namespace std;

typedef long long ll;
const ll M = (ll)1e9 + 7;
const int N = (int)2e5 + 10;
vector<int> graph[N];
int used[N];
int dfs(int v, int c) {
    c++;
    used[v] = true;
    for(auto &to: graph[v]) {
        if(!used[to]) {
            c += dfs(to, 0);
            used[to] = true;
        }
    }
    return c;
}
int main(){
    int n; cin >> n;
    int m; cin >> m;
    while(m--) {
        int u, v; cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int answer = 0;
    for(int i = 1; i <= n; i++)
    {
        if(!used[i])
            answer = max(answer, dfs(i, 0));
    } cout << answer;
}

Measured memory_bytes: 24720
#include<stdio.h>

#define YOUSO 2000

int main(){
  int i,j,n,q,x,m;
  int a[YOUSO+1] ={0};

  scanf("%d",&n);
  
  for(i=0;i<n; i++){
    scanf("%d",&x);
    
    for(j = YOUSO-x ;0<j ;j--){if(a[j]){
	a[j+x] = 1;
      }
    }
    a[x] = 1;
  }
  
  scanf("%d",&q);
  
  for(i= 0;i<q;i++){ scanf("%d",&x);
    
    if(a[x]){
      printf("yes\n");
    }
    
    else {printf("no\n");
    }
  }
  
  return 0;
}



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

const int MOD = 1e9 + 7;
const int N = 2e6 + 5;

int f[N], inv[N], finv[N];
// inv[]: inverse element

int powMod(int u, int v) {
    int res = 1;
    while (v) {
        if (v & 1) res = (ll)res * u % MOD;
        v >>= 1;
        u = (ll) u * u % MOD;
    }
    return res;
}

void initInv() {
    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = (ll)f[i - 1] * i % MOD;
    }
    inv[0] = inv[1] = 1;
    for (int i = 2; i < N; i++) {
        inv[i] = (ll)(MOD - MOD / i) * inv[MOD % i] % MOD;
    }
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
        finv[i] = ((ll)finv[i - 1] * inv[i]) % MOD;
    }
}

int C(int x, int y) {
    if (y < 0) return 0;
    return ((ll)f[x] * finv[y] % MOD) * finv[x - y] % MOD;
}

int Lucas(int u, int v) {
    if (v == 0) return 1;
    return (ll)C(u % MOD, v % MOD) * Lucas(u / MOD, v / MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    initInv();
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long sum = 0;
    for (int i = r1; i <= r2; i++) {
        sum = (sum + (C(c2 + i + 1, i + 1) - C(c1 + i, i + 1) + MOD)) % MOD;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 23680
n, p = map(int, input().split())
A = list(map(int, input().split()))

even = 0
odd = 0
for a in A:
    if a%2 ==0:
        even += 1
    else:
        odd += 1

ans = 0
import math
if p == 0:
    for i in range(odd+1):
        if i%2 == 1:
            continue
        ans += (2**even)* math.factorial(odd) // math.factorial(odd - i) //math.factorial(i)

else:
    for i in range(odd+1):
        if i%2 == 0:
            continue
        ans += (2**even)* math.factorial(odd) // math.factorial(odd - i) //math.factorial(i)

print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

bool ok(string s){
  //cout<<s<<endl;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-1-i]) return 0;
  }
  return 1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  string s;
  cin>>s;
  if(ok(s)&&ok(s.substr(0,(s.size()-1)/2))&&ok(s.substr((s.size()+1)/2))) {
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;

}

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

int main() {
	int a, b, d;
	cin >> a >> b;
	d = a / b;
	cout << d << " " << a - b*d << " "
			<< fixed << setprecision(5) << (double)a/b << endl;
	return 0;
}

Measured memory_bytes: 3264
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t;
    t = 1;
    while (t--)
    {
        long long int k, j = 0, i;
        cin >> k;
        for (i = 1; i <= 1000000; i++)
        {
            j = (j * 10 + 7) % k;
            if (j == 0)
            {
                cout << i << " " << endl;
                return 0;
            }
        }
        cout << "-1" << endl;
    }
    return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main(){
	ll x; cin >> x;
	ll ans = 0LL;
	ll y = x/500;
	ans += y*1000;
	ll z = x%500;
	ll w = z/5;
	ans += 5*w;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
#define forn(k,n) for(int i=k;i<n;i++)
#define forn1(k,n) for(int j=k;j<n;j++)
template<class T> T power(T N,T P)
{ return (P==0)?  1: N*power(N,P-1); }
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("error.txt", "w", stderr);
	bs;
	ll a,b,c,diff;
	cin>>a>>b>>c;
	diff=min(a,c);
	if(a>0){ a-=min(a,c); c-=diff;}
	if(b>0&&c>0) b-=min(b,c);
	cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);	
      String s=sc.next();
		char c[]=s.toCharArray();
          if(c[0]=='9'||c[1]=='9'){
          
          System.out.println("Yes");
          }else{System.out.println("No");
          }}}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define Graph vector<vector<int>>
#define rng(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rnr(i, a, b) for(ll i = ll(a); i >= ll(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll modpow(ll a, ll n) {
    //ret a^n;
    ll ret = 1;
    rep(i, n) {
        ret = (ret * a) % MOD;
    }
    return ret;
}

int main() {
    ll n; cin >> n;
    cout << (modpow(10, n) - 2 * modpow(9, n) + modpow(8, n) + 3 * MOD) % MOD << endl;
}


Measured memory_bytes: 3604
from bisect import *
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for b in B:
    ans+=(n-bisect(C,b))*bisect_left(A,b)
print(ans)

Measured memory_bytes: 29384
#include<iostream>
using namespace std;
#define MAX 1000000
typedef struct{ 
  int p, l, r;
}Node;
Node t[1000000];
int count,h,d[1000000];
void b(int); 

int main(){
  int n,id,k,c,l,r;
  cin>>n;
  for(int i=0;i<n;i++) {
    t[i].p=-1;
    t[i].l=-1;
    t[i].r=-1;
  }  
  for(int i=0;i<n;i++){
    cin>>id>>k;
    for(int j=0;j<k;j++){
      cin>>c;
      t[c].p=id;
      if(j==0)t[id].l=c;
      else t[r].r=c;
      r=c;
    }
  }

  for(int i=0;i<n;i++){
    b(i);
    d[i]=count;
  }
  for(int i=0;i<n;i++){
    if(t[i].p==-1)
    cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", root, ";  
    else if(t[i].l==-1)
    cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", leaf, ";         
    else
      cout<<"node "<<i<<": parent = "<<t[i].p<<", depth = "<<d[i]<<", internal node, ";
    int j=i;
    cout<<'[';
    if(t[j].l!=-1){
      cout<<t[j].l;
      if(t[t[j].l].r==-1) cout<<']'<<endl;
      else cout<< ", ";
       
      j=t[j].l;
      while(t[j].r!=-1){
	cout<<t[j].r;
      if(t[t[j].r].r==-1)cout<<']'<<endl;
      else cout<<", ";
      j=t[j].r;
      }
    }
    else cout<<']'<<endl; 
  }
  return 0;
}

void b(int x){
  count=0;
  while(t[x].p>=0){
    x=t[x].p; 
    count++;
  }
}

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

using namespace std;

void calcLucasSequence(vector<long>& lucasSequence, const int& numOfTerm);

int main() {
    int numOfTerm = 0;
    cin >> numOfTerm;
    
    vector<long> lucasSequence;
    calcLucasSequence(lucasSequence, numOfTerm);
    
    cout << lucasSequence.at(numOfTerm) << endl;  
}

void calcLucasSequence(vector<long>& lucasSequence, const int& numOfTerm) {
    const long INITIAL_TERM = 2;
    const long SECOND_TERM = 1;
    
    lucasSequence.push_back(INITIAL_TERM);
    lucasSequence.push_back(SECOND_TERM);
    for (int term_i = 2; term_i <= numOfTerm; ++term_i) {
        lucasSequence.push_back(lucasSequence.at(term_i - 1) + lucasSequence.at(term_i - 2));
    }
} 

Measured memory_bytes: 3648
N = int(input())
l_b = list(map(int,input().split()))
l_a = [0]*(N)
for i in range(1,N-1):
    l_a[i] =min(l_b[i-1],l_b[i])
l_a[-1] = l_b[-1]
l_a[0] = l_b[0]
print(sum(l_a))


Measured memory_bytes: 38256
gets;P=*0..1e5;Q=[0]*2e5;F=->x{x==(p=P[x])?x:(s=F[p];Q[x]+=Q[p];P[x]=s)};puts$<.all?{|s|l,r,d=s.split.map &:to_i;(x=F[l])==(y=F[r])?Q[l]+d==Q[r]:(P[y]=x;Q[y]=Q[l]+d-Q[r])}?:Yes: :No

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

const int64_t INF = 1e+15;

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<int> used;

int main() {
    int64_t D,G;
    cin >> D >> G;
    vector<int64_t> p(D),c(D);
    for ( int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
    
    int64_t sum,num;
    int64_t num_min = INF;
    used.resize(D);
    for ( int bit = 0; bit < (1<<D); ++bit){
        sum = 0; num = 0;
        used.assign(D,0);
        for ( int j = 0; j < D; ++j){
            if ( bit & (1<<j)){
                sum = sum + c[j];
                sum = sum + (1+j)*100 * p[j];
                num += p[j];
                used[j] = 1;
            }
        }
        if( sum >= G ){
            chmin(num_min,num);
        } else {
            for ( int64_t j = D-1; j >= 0; --j){
                int64_t del = G - sum;
                if ( used[j] == 0 and del >= 0 ){
                    int64_t cost = 100 * (j+1);
                    int64_t all = cost * p[j];
                    if ( del > all + c[j] ){
                        sum = sum + all + c[j];
                        num = num + p[j];
                    } else if ( del <= cost * (p[j]-1) ){
                        int64_t amari = del % cost, sho = del / cost;
                        if ( amari != 0 ) ++ sho;
                        sum = sum + cost * sho;
                        num += sho;
                    } else {
                        sum = sum + all + c[j];
                        num = num + p[j];
                    }
                    
                }
            }
            chmin(num_min,num);
        }
    }
    
    cout << num_min << endl;
    
    return 0;
}


Measured memory_bytes: 3584
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(A,B):#106-A
    anser=A*B-(A+B-1)
    return anser

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
int A[MAXN] , B[MAXN] , pr[MAXN] , s[MAXN] , aa , bb;

void solve() {
	cin >> n;
	rep( i , 1 , n ) scanf("%lld%lld",A + i,B + i) , pr[i] = A[i] , pr[i + n] = B[i] , aa += A[i] , bb += B[i];
	int res = min( aa , bb );
	sort( pr + 1 , pr + 1 + 2 * n );
	rep( i , 1 , n << 1 ) s[i] = s[i - 1] + pr[i];
	rep( i , 1 , n ) {
		if( A[i] < B[i] ) swap( A[i] , B[i] );
		if( A[i] <= pr[n] ) res = min( res , s[n] );
		else if( B[i] <= pr[n - 1] ) res = min( res , s[n - 1] + A[i] );
		else res = min( res , s[n - 2] + A[i] + B[i] );
	}
	cout << res << endl;
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}



Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,k;    cin>>n>>k;
    string s;   cin>>s;
    vector<int>dic;
    if(s.front() == '0') dic.push_back(0);
    int tmp = 0;
    rep(i, n){
        if(s[i] != s[tmp]){
            dic.push_back(i-tmp);
            tmp = i;
        }
    }
    dic.push_back(n-tmp);
    if(s.back() == '0') dic.push_back(0);
    int len = 2*k+1;
    //[l, r)
    int l = 0, r = len;
    int sum = 0;
    rep(i, len){
        if(i>=dic.size())   break;
        sum += dic[i];
    }
    int ans = sum;
    for(; r < dic.size();){
        sum = sum + dic[r] - dic[l];
        r++;
        l++;
        sum = sum + dic[r] - dic[l];
        r++;
        l++;
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4080
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
    int n, h[100100];
    scanf("%d", &n);
    rep(i, n)
        scanf("%d", &h[i]);

    int dp[100100] = {0};
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++)
        dp[i] += min(abs(h[i] - h[i - 2]) + dp[i - 2], abs(h[i] - h[i - 1]) + dp[i - 1]);
    
    printf("%d\n", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<limits.h>
int main(void)
{
	int n,c[10001],g,t,l,r,a,min,i,j;
	while(1)
	{
		scanf("%d", &n);
		if(n==0)
		break;
		for(i=1; i<=n; i++)
		scanf("%d", &c[i]);
		min=INT_MAX;
		for(i=1; i<=n; i++)
		{
			for(j=1; j<4; j++)
			{
				g=n;
				t=1;
				l=i-1;
				r=i+1;
				while(c[l]==j&&l>0)
				{
					t++;
					l--;
				}
				while(c[r]==j&&r<=n)
				{
					t++;
					r++;
				}
				if(t>3)
				{
					while(1)
					{
						g-=t;
						t=0;
						if(l>0)
						a=c[l];
						else if(r<=n)
						a=c[r];
						else
						break;
						while(c[l]==a&&l>0)
						{
							t++;
							l--;
						}
						while(c[r]==a&&r<=n)
						{
							t++;
							r++;
						}
						if(t<4)
						break;
					}
				}
				if(min>g)
				min=g;
			}
		}
		printf("%d\n", min);
	}
	
	return 0;
}


Measured memory_bytes: 2028