akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using L = long long;

struct Tree {
	int size = 1;
	vector<L> values, lazy;

	Tree(int n) {
		while(size < n)
			size *= 2;
		values.resize(size * 2);
		lazy = values;
	}

	L getMax() {
		return values[1];
	}

	void add(int l, int r, L val, int subSize, int v = 1) {
		if(l == 0 && r == subSize - 1) {
			values[v] += val;
			lazy[v] += val;
			return;
		}

		int s2 = subSize / 2;
		if(r < s2)
			add(l, r, val, s2, 2 * v);
		else if(l >= s2)
			add(l - s2, r - s2, val, s2, 2 * v + 1);
		else  {
			add(l, s2 - 1, val, s2, 2 * v);
			add(0, r - s2, val, s2, 2 * v + 1);
		}

		values[v] = max(values[2 * v], values[2 * v + 1]) + lazy[v];
	}
};

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

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

	vector<vector<pair<int, L>>> req(n + 1);

	for(int i = 0; i < m; ++i) {
		int l, r, score;
		cin >> l >> r >> score;
		req[r].emplace_back(l, score);
	}

	Tree dp(n + 1);

	for(int i = 1; i <= n; ++i) {
		dp.add(i, i, dp.getMax(), dp.size);

		for(auto p : req[i])
			dp.add(p.first, i, p.second, dp.size);
	}
	cout << dp.getMax() << '\n';
}



Measured memory_bytes: 19456
N,M = map(int,input().split())
X = list(map(int,input().split()))

X.sort()

Y = []
for i in range(M-1):
    Y.append(X[i+1]-X[i])

Y.sort()

for i in range(N-1):
    if len(Y) != 0:
        Y.pop()


print(sum(Y))

Measured memory_bytes: 13968
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int a,b;

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

  if(a>0 && b>0)
    cout<<"Positive\n";
  else if(a<=0 && b>=0)
    cout<<"Zero\n";
  else {
    if((b-a+1)%2==0)
      cout<<"Positive\n";
    else
      cout<<"Negative\n";
  }
  
  return 0;
}


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

const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;

int n, k, h[maxn], d[maxn] = {0};

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h[i];
    d[0] = 0;
    d[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; ++i) {
        int t = inf;
        for (int j = 1; j <= min(i, k); ++j) {
            t = min(t, d[i - j] + abs(h[i - j] - h[i]));
        }
        d[i] = t;
    }
    printf("%d\n", d[n - 1]);
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 22:36:36 2020

@author: liang
"""

N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = input()
hand = {"r":P, "s":R, "p":S}
ans = 0
for i in range(K):
    s = str()
    tmp = i
    while tmp < N:
        s += T[tmp]
        tmp += K
    #print(s)
    count = 1
    prev = str()
    for j in range(len(s)):
        if s[j] == prev:
            count += 1
        else:
            count = 1
        if count%2 == 0:
            continue
        prev = s[j]
        """
        if s[j] == "r":
            ans += P
        elif s[j] == "s":
            ans += R
        else:
            ans += S
        """
        ans += hand[s[j]]
print(ans)
        

Measured memory_bytes: 9408
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s,t; cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = n;
	rep(i,n-m+1){
		int cnt = 0;
		rep(j,m){
			if(t[j] != s[i+j]) cnt++;
		}
		chmin(ans, cnt);
	}
	cout << ans << "\n";
}

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

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	final long MOD = 1_000_000_007L;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] l = new int[d];
		for (int i = 0; i < d; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int s = sc.nextInt();
		long[] dp = new long[90010];
		dp[s] = 1;

		for (int i = 0; i < d; i++) {
			for (int j = 0; j <= s; j++) {
				if (j - l[i] > 0)
					dp[j - l[i]] += MOD - dp[j];
				dp[j] %= MOD;
			}
		}
		long cut = 0;
		for (int i = 1; i <= s; i++) {
			long tmp = dp[i];
			for (int j = 0; j < d; j++) {
				tmp = (tmp * i) % MOD;
			}
			cut = (cut + tmp) % MOD;
		}
		System.out.println(cut);
	}
}

Measured memory_bytes: 27960
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
    string s;
    cin>>s;
    int l=s.size();
    rep(i,l){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D') continue;
        }
        else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D') continue;
        }
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			int m1 = arr[0];
			int d1 = arr[1];

			arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			int m2 = arr[0];
			int d2 = arr[1];

			if (m1 != m2)
			{
				Console.WriteLine(1);
			}
			else
			{
				Console.WriteLine(0);
			}

		}
	}


}


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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N,0);
  vector<ll> S(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  S[0]=A[0];
  for(int i=1;i<N;i++){
    S[i]=A[i]+S[i-1];
  }
  for(int i=N-2;i>=0;i--){
    if(S[i]*2<A[i+1]){
      cout << N-i-1 << endl;
      return 0;
    }
  }
  cout << N << endl;
}

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

#define BR "\n"
#define SP " "

int main() {
  double r;
  cin >> r;

  double pi = 3.141592653589793238;
  cout << fixed << setprecision(9) << r * r * pi << SP << 2 * r * pi << BR;
  return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
ll X[100005];

//-----UnionFind--------
vector<int> par, rk, cn;

void initUnion(int n)
{
	for (int i = 0;i < n;i++) {
		par.push_back(i);
		rk.push_back(1);
		cn.push_back(0);
	}
}

int root(int x) {
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry) return;

	if (rk[ry] < rk[rx]) swap(rx, ry);
	X[ry] += X[rx];
	rk[ry] += rk[rx];
	cn[ry] += cn[rx];
	par[rx] = ry;
}

bool same(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}
//-----UnionFind--------

class edge {
public:
	int u;
	int v;
	ll w;
};

bool comp(edge v, edge u)
{
	return v.w < u.w;
}

int main()
{
	cin >> n >> m;
	vector<edge> e(m);
	int u, v, w;

	for (int i = 0;i < n;i++) cin >> X[i];
	for (int i = 0;i < m;i++) {
		cin >> u >> v >> w;
		u--;
		v--;
		e[i].u = u;
		e[i].v = v;
		e[i].w = w;
	}

	sort(e.begin(), e.end(), comp);

	int ans = m;
	initUnion(n);

	for (int i = 0;i < m;i++) {
		w = e[i].w;
		v = e[i].v;
		u = e[i].u;

		if (!same(u, v)) {
			int Ru = root(u);
			int Rv = root(v);
			unite(u, v);
		}

		int Ru = root(u);
		cn[Ru]++;

		if (X[Ru] >= w) {
			ans -= cn[Ru];
			cn[Ru] = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4076
#include<iostream>
using namespace std;
int main()
{
  int a,b,n1,n2,n4,n5,num,std,j=0;
  cin>>a>>b;

  for(int i=a;i<=b;i++)
  {
    num=i;
    n1=num%10;
    n5=num/10000;

    n2=(num%100)/10;
    n4=(num/1000)%10;

    if(n1==n5 && n2==n4) j++;
  }
  cout<<j<<endl;
}

Measured memory_bytes: 256
import math
from itertools import accumulate


def is_2017_like(num):
    if num == 1:
        return 0
    for k in range(2, int(math.sqrt(num)) + 1):
        if num % k == 0 or ((num + 1) // 2) % k == 0:
            return 0
    return 1


q = int(input())
lr = [list(map(int, input().split()))for i in range(q)]
ans = []
for i in range(1, 10 ** 5, 2):
    ans.append(is_2017_like(i))
ans = list(accumulate(ans))
for i in range(q):
    if lr[i][1] == 1:
        print(0)
    elif lr[i][1] != 1 and lr[i][0] == 1:
        print(ans[(lr[i][1] + 1) // 2 - 1] - 0)
    else:
        print(ans[(lr[i][1] + 1) // 2 - 1] - ans[(lr[i][0] + 1) // 2 - 2])


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

int N,M,K;
int E[100],A[100];
int v[4];

double dp[51][50000];
void solve(){


    dp[0][0]=1.0;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i;j--){
            for(int k=0;k<=i*100;k++){
                for(int l=0;l<M;l++){
                    int toval=k;
                    int topos=min(N,j+v[l]);
                    if(E[topos]==1)topos=min(N,topos+A[topos]);
                    else if(E[topos]==2)toval+=A[topos];
                    else if(E[topos]==3)toval=max(0,toval-A[topos]);
                    dp[topos][toval]+=dp[j][k]/M;
                }
                dp[j][k]=0;
            }

        }
    }

    double sum=0;
    for(int i=0;i<50000;i++)sum+=dp[N][i]*i;
    cout<<(int)sum<<endl;
}

bool input(){
    memset(dp,0,sizeof(dp));
    memset(E,0,sizeof(E));
    memset(A,0,sizeof(A));

    cin>>M>>N>>K;
    if(M==0&&N==0&&K==0)return false;
    for(int i=0;i<M;i++)cin>>v[i];
    for(int i=0;i<K;i++){
        int n,e,a;
        cin>>n>>e>>a;
        E[n]=e;
        A[n]=a;
    }
    return true;
}

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

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

namespace abl_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();

      var uf = new UnionFind(N);

      for (int i = 0; i < M; i++)
      {
        var A = CIn.ReadInt() - 1;
        var B = CIn.ReadInt() - 1;

        uf.Unite(A, B);
      }

      var hs = new HashSet<int>();

      for (int i = 0; i < N; i++)
      {
        hs.Add(uf.GetRoot(i));
      }

      Console.WriteLine(hs.Count - 1);
    }
  }

  class UnionFind
  {
    private readonly int[] parent;
    private readonly int[] size;

    public UnionFind(int n)
    {
      parent = Enumerable.Range(0, n).ToArray();
      size = Enumerable.Repeat(1, n).ToArray();
    }

    public int GetRoot(int a)
    {
      if (parent[a] == a) return a;
      return parent[a] = GetRoot(parent[a]);
    }

    public void Unite(int a, int b)
    {
      var aRoot = GetRoot(a);
      var bRoot = GetRoot(b);

      if (aRoot == bRoot) return;

      if (size[a] >= size[b])
      {
        size[aRoot] += size[bRoot];
        parent[bRoot] = aRoot;
      }
      else
      {
        size[bRoot] += size[aRoot];
        parent[aRoot] = bRoot;
      }
    }

    public bool IsSame(int a, int b)
    {
      return GetRoot(a) == GetRoot(b);
    }

    public int GetSize(int a)
    {
      return size[GetRoot(a)];
    }
  }


  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 42376
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int binarySearch(int n, vector<int> v);

int main() {
	int n, q;

	cin >> n;
	vector<int> va(n);
	for (int i = 0; i < n; i++) {
		cin >> va.at(i);
	}

	cin >> q;
	vector<int> vb(q);
	for (int i = 0; i < q; i++) {
		cin >> vb.at(i);
	}

	int c = 0;
	for (int i = 0; i < q; i++) {
		if (binarySearch(vb.at(i), va) == 1) c++;
	}

	cout << c << endl;
}

int binarySearch(int key, vector<int> v) {
	//sort(v.begin(), v.end());

	int left, right;
	left = 0;
	right = v.size();

	while (left < right) {
		int mid = (left + right) / 2;

		if (key == v.at(mid)) {
			return 1;
		}
		else if (key < v.at(mid)) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}

	return -1;

}


Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;

using namespace std;

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double kakudo_a = double(m) * 6.0;
    double kakudo_b = double(h) * 30.0 + double(m) * 0.5;
    double kakudo = 0.0;
    if (kakudo_a > kakudo_b){
        kakudo = kakudo_a - kakudo_b;
    }
    else{
        kakudo = kakudo_b - kakudo_a;
    }
    if (kakudo > 180.0){
        kakudo = 360.0 - kakudo;
    }
    //cout << kakudo << endl;
    double ans = pow(double(a), 2.0) + pow(double(b), 2.0) - 2 * a * b * cos(M_PI * kakudo /180.0);
    ans = pow(ans, 0.5);
    printf("%.12f\n",ans);
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

const int N = 1e4;
int a[N+5];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	REP(x, 1, 100) REP(y, 1, 100) REP(z, 1, 100)
	{
		int n = x*x + y*y + z*z + x*y + y*z + z*x;
		if (n <= 10'000)
			a[n]++;
	}

	int n; cin >> n;
	REP(i, 1, n)
		cout << a[i] << '\n';

	return 0;
}

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


int n;
std::vector< std::string > ss;

inline int getDots(std::string s) {
    return s.rfind('.', s.length() - 1);
}

std::pair<long long, int> calc(int depth, int i) {
    int num = getDots(ss[i]) + 1;
    if(depth > num) {
        return {-1, i};
    }

    char c = ss[i][num];
    if(c >= '0' && c <= '9') {
        return {(long long)(c - '0'), i+1};
    }

    long long ans = (c == '+' ? 0 : 1);
    int j = i + 1;
    while(j < n) {
        auto res = calc(depth + 1, j);
        if(res.first == -1) {
            break;
        }
        if(c == '+') {
            ans += res.first;
        } else {
            ans *= res.first;
        }
        j = res.second;
    }
    return {ans, j};
}

int main() {
    ss.resize(100);
    while(std::cin >> n, n != 0) {
        for(int i=0; i<n; ++i) {
            std::cin >> ss[i];
        }
        std::cout << calc(0, 0).first << std::endl;
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
const int Maxn=1<<18,mod=998244353;
int a[Maxn],p[Maxn],A[Maxn],B[Maxn];
int ksm(int x,int k){
    int ret=1,tmp=x;
    while(k){
        if(k&1)ret=1ll*ret*tmp%mod;
        tmp=1ll*tmp*tmp%mod;k>>=1;
    }
    return ret;
}
int inv(int x){return ksm(x,mod-2);}
void FWT(int*a,int n,int type){
    for(int l=2;l<=n;l<<=1)
        for(int*p=a,m=l>>1;p!=a+n;p+=l)
            for(int i=0;i<m;i++){
                int x=p[i],y=p[i+m];
                p[i]=(x+y)%mod;
                p[i+m]=(x-y)%mod;
                if(type==-1){
                    p[i]=1ll*p[i]*((mod+1)/2)%mod;
                    p[i+m]=1ll*p[i+m]*((mod+1)/2)%mod;
                }
            }
}
int main(){
    int n,sum=0;scanf("%d",&n);
    for(int i=0;i<1<<n;i++)scanf("%d",&p[i]);
    for(int i=0;i<1<<n;i++)sum=(sum+p[i])%mod;
    for(int i=0;i<1<<n;i++)p[i]=1ll*p[i]*inv(sum)%mod;
    for(int i=0;i<1<<n;i++)A[i]=p[i]-(i==0),B[i]=-1+(i==0)*(1<<n);
    FWT(A,1<<n,1);FWT(B,1<<n,1);
    for(int i=0;i<1<<n;i++)A[i]=1ll*B[i]*inv(A[i])%mod;
    FWT(A,1<<n,-1);
    for(int i=0;i<1<<n;i++)
        cout<<((A[i]-A[0])%mod+mod)%mod<<" \n"[i==(1<<n)-1];
    return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(nullptr);
   ios_base::sync_with_stdio(false);

   int n,a,b,ans=0;
   cin>>n;
   vector<int> x,y;
   x.resize(n+1,0);
   y.resize(n+1,0);

   rep(i,1,n+1){
      cin>>x[i];
      y[x[i]]++;
   }

   rep(i,1,n+1){
      ans += (y[i] * (y[i]-1))/2;
   }

   rep(i,1,n+1){
      a = y[x[i]] * (y[x[i]] - 1)/2;
      b = (y[x[i]] - 1) * (y[x[i]] -2)/2;
      cout<<ans-a+b<<'\n';
   }
   return 0;
}

Measured memory_bytes: 5760
#include <iostream>

int main() {
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      char c;
      std::cin >> c;
      if (i==j) std::cout << c;
    }
  }
  std::cout << std::endl;
  return 0;
}


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

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

int main() {
    int H, W;   cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++)
        cin >> s[i];

    vector<vector<int> > dist(H, vector<int>(W, -1));
    queue<pair<int, int> > que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') {
                que.push(pair<int, int>(i, j));
                dist[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while (!que.empty()) {
        pair<int, int> v = que.front();
        for (int i = 0; i < 4; i++) {
            int nx = v.first + dx[i];
            int ny = v.second + dy[i];

            if (nx < 0 || H <= nx || ny < 0 || W <= ny || s[nx][ny] == '#' || dist[nx][ny] != -1)
                continue;
            
            ans = dist[nx][ny] = dist[v.first][v.second] + 1;
            
            que.push(pair<int, int>(nx, ny));
        }
        que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13568
-- 解答を参考に書いた
local read = io.read
local lshift, rshift, band = bit.lshift, bit.rshift, bit.band
local H, W, K = read("*n", "*n", "*n")
read("*l")

local byte_sharp = string.byte("#")

local c = {}
for i = 1, H do
	local str = read("*l")
	c[i] = {}
	for j = 1, W do
		if byte_sharp == str:byte(j) then
			c[i][j] = true
		else
			c[i][j] = false
		end
	end
end


local out = 0
-- bitの利用
-- bitの数[0, (1<<H)-1]のような閉区間
for maskR = 0, lshift(1, H) - 1 do
	for maskC = 0, lshift(1, W) - 1 do
		local black = 0
		-- luaのlistは1からだからそれに合わせて[1, H]
		for i = 1, H do
			for j = 1, W do
				-- 0は塗りつぶしされてない
				if band(rshift(maskR, i - 1), 1) == 0
				and band(rshift(maskC, j - 1), 1) == 0
				and c[i][j] then
					black = black + 1
				end
			end
		end
		if black == K then
			out = out + 1
		end
	end
end

print(out)


Measured memory_bytes: 2752
N=int(input())
for i in range(1,N+1):
    x,y,z=input().split()
    x=int(x)
    y=int(y)
    z=int(z)
    if x>y:
        x,y=y,x
    if y>z:
        y,z=z,y
    if x>y:
        x,y=y,x
    if x*x+y*y==z*z:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+1],b[200005];
    memset(b,0,sizeof(b));
    a[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    ll ans=0;
    ll sum=0;
    for(int i=1;i<200005;i++)
    {
        ll num=b[i];
        ll temp=(num*(num-1))/2;
        if(temp<0)
        {
            temp=0;
        }
        sum+=temp;
    }
    for(int i=1;i<=n;i++)
    {
        ll num=b[a[i]];
        ll temp=(num*(num-1))/2;
        if(temp<0)
        {
            temp=0;
        }
        ans=sum-temp;
        num-=1;
        if(num<0)
        {
            num=0;
        }
        temp=(num*(num-1))/2;
        if(temp<0)
        {
            temp=0;
        }
        ans+=temp;
        cout<<ans<<"\n";
        ans=0;
    }
	return 0;
}







Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <math.h>
#define ll long long
using namespace std;

int main () {
  ll n;
  cin >> n;
  ll a[15];
  ll x[15][15], y[15][15];
  for (int i = 0; i < 15; i++) {
    a[i] = 0;
    for (int j = 0; j < 15; j++) {
      x[i][j] = 0;
      y[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  ll two[15];
  ll MAX = 0;
  for (ll i = 0; i < 15; i++) two[i] = 0;
  for (ll num = 0; num < pow(2, n); num++) {
    for (ll i = 0; i < 15; i++) two[i] = 0;
    ll sub = num;
    ll itr = 0;
    ll cnt = 0;
    while (sub != 0) {
      if (sub % 2 == 1) {
        two[itr] = 1;
        cnt++;
      }
      itr++;
      sub = (sub >> 1);
    }
    for (ll i = itr; i < 15; i++) two[i] = 0;
    // two[j] = 1 → 正直者
    bool ok = true;
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < a[i]; j++) {
        if (two[i] == 0) {
        }
        else {
          if (two[x[i][j]] == y[i][j]) {
            // ok
          }
          else {
            ok = false;
            break;
          }
        }
      }
    }
    if (ok == true && MAX < cnt) {
      MAX = cnt;
    }
  }
  cout << MAX << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int A = Integer.parseInt(st.nextToken());    
        int B = Integer.parseInt(st.nextToken());    
        int C = Integer.parseInt(st.nextToken());
        int five=0,sev=0;
        if(A==5)
            five++;
        else
            sev++;
        if(B==5)
            five++;
        else
            sev++;
        if(C==5)
            five++;
        else
            sev++;

        if(sev==1 && five==2)
            System.out.println("YES");
        else
            System.out.println("NO");

    }
}

//10 3 10 3

Measured memory_bytes: 19540
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;
int main() {
  string S,T;
  cin >> S >> T;
  int s = S.size();
  int t = T.size();
  if (t-s > 0) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i=s-t; i>=0; i--) {
    bool bubun = true;
    FOR(j,i,i+t) {
      if (S[j] == '?') continue;
      if (S[j] == T[j-i]) continue;
      bubun = false;
    }
    if (bubun) {
      FOR(j,0,s-t) {
        if(S[j] == '?') S[j] = 'a';
      }
      FOR(j,i,i+t) {
        S[j] = T[j-i];
      }
      FOR(j,i+t,s) {
        if(S[j] == '?') S[j] = 'a';
      }
      cout << S << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  
  return 0;
}

Measured memory_bytes: 3580
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++)
		cout<<s[i]<<t[i];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long r = Integer.parseInt(st.nextToken());
        long D = Integer.parseInt(st.nextToken());
        long x = Integer.parseInt(st.nextToken());
        for(int i=2001;i<=2010;i++){
            x = r*x-D;
            System.out.println(x);
        }

    }
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

ll n , k;
ll a[MAXX];

int main()
{
    _FastIO;

    cin >> n;
    ll x = 1000;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    a[n] = -1;
    for(ll i = 0; i < n - 1; i++){
        for(ll j = i + 1; j <= n; j++){
            if(a[j] < a[j - 1]){
                ll c = x / a[i];
                x += ((a[j - 1] - a[i]) * c);
                i = j - 1;
                break;
            }
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3648
N, K, *A = [int(_) for _ in open(0).read().split()]


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_right(self, p, v):  # apply operator from the right side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(dat[p], v)
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_left(self, p, v):  # apply operator from the left side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(v, dat[p])
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        vl = vr = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                vl = f(vl, dat[l])
                l += 1
            if r & 1:
                r -= 1
                vr = f(dat[r], vr)
            l >>= 1
            r >>= 1
        return f(vl, vr)


st = SegmentTree([0] * 300001, max, 0)
for a in A:
    l = max(0, a - K)
    r = min(a + K, 300000)
    st.update(a, st.query(l, r + 1) + 1)
print(st.query(0, 300001))


Measured memory_bytes: 136612
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    if(n<1200) out("ABC");
    else out("ARC");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int a, b, c; cin >> a >> b >> c;
  
  if(c-a-b <= 0) cout << "No" << endl;
  else if(4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<ll>> x(N, vector<ll>(N)), y(N, vector<ll>(N));
    rep(i, 0, N){
        cin >> A[i];
        rep(j, 0, A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    ll ans = 0;
    for(int bit = 0; bit < (1<<N); bit++){
        bool f = true;
        vector<ll> truth(N, -1);
        for(int i = 0; i < N; i++){
            if(bit & (1<<i)) truth[i] = 1;
            else truth[i] = 0;
        }
        ll cnt = 0;
        for(int i = 0; i < N; i++){
            if(bit & (1<<i)){
                cnt++;
                rep(j, 0, A[i]){
                    if(truth[x[i][j]] != y[i][j]){
                        f = false;
                    }
                }
            }
        }
        if(f) ans = max(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
a_list = list(map(int, input().split()))
a_accumulate = list(itertools.accumulate(a_list))
a_sum = sum(a_list)
result = 0
i = 0
for a in a_list:
  result += a * (a_sum - a_accumulate[i])
  i += 1
print(result%(pow(10,9)+7))

Measured memory_bytes: 33440
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def process(commands):
    d = set()
    for c in commands:
        cpair = c.split()
        if cpair[0] == "insert":
            d.add(cpair[1])
        elif cpair[0] == "find":
            r = "yes" if cpair[1] in d else "no"
            print(r)


def main():
    n = int(input())
    commands = [input() for i in range(n)]
    process(commands)


if __name__ == "__main__":
    main()

Measured memory_bytes: 106740
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  string s; cin >> s;
  for (int i =0; i < s.size(); i ++) cout << 'x';
  cout << endl;
}


Measured memory_bytes: 256
while True:
	ans = 0
	try:
		n = input()
		
	except (EOFError):
		break
	
	for a in range(10):
		atmp = n - a
		if(-1 < atmp and atmp<28):
			for b in range(10):
				btmp = atmp - b
				if(-1 < btmp and btmp<19):
					for c in range(10):
						d = btmp  - c
						if(-1 < d and d<10):
							ans += 1
							#print (a, b, c, d)
	print ans
						

Measured memory_bytes: 4220
import collections
h , w = map(int,input().split())
p = []
for i in range(h):
    p.extend(list(input()))
c = collections.Counter(p)

if h % 2 == 0 and w % 2 == 0:
    for k , v in c.items():
        if v % 4 != 0:
            print("No")
            exit()
    print("Yes")
    
elif h % 2 != 0 and w % 2 != 0:
    m = 0
    n = 0
    for k , v in c.items():
        if v % 4 == 1:
            n += 1
            if n > 1:
                print("No")
                exit()
        elif v % 4 == 2:
            m += 1
            if m > w//2 + h//2:
                print("No")
                exit()
        elif v % 4 == 3:
            n += 1
            m += 1
            if n > 1:
                print("No")
                exit()
            if m > w//2 + h//2:
                print("No")
                exit()
        
    print("Yes")
elif h % 2 != 0:
    m = 0
    for k , v in c.items():
        if v % 4 == 1 or v % 4 == 3:
            print("No")
            exit()
        elif v % 4 == 2:
            m += 1
            if m > w//2:
                print("No")
                exit()
    print("Yes")
elif w % 2 != 0:
    m = 0
    for k , v in c.items():
        if v % 4 == 1 or v % 4 == 3:
            print("No")
            exit()
        elif v % 4 == 2:
            m += 1
            if m > h//2:
                print("No")
                exit()
    print("Yes")        

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int A,B;
  cin >> A >> B;

  cout << A * B << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

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

int w[305], dp[305][305];
signed main(void)
{
	while(true) {
		int n;
		cin >> n;
		if(!n) break;
		REP(i, n) cin >> w[i];
		REP(i, 305) REP(j, 305) dp[i][j] = 0;

		FOR(W, 2, n+1) {
			REP(i, n) {
				int j = i+W-1;
				if(j >= n) continue;

				if(dp[i+1][j-1] == W-2 && abs(w[i] - w[j]) <= 1) dp[i][j] = W;
				FOR(k, i, j) {
					dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
				}
			}
		}
		cout << dp[0][n-1] << endl;
	}

	return 0;
}



Measured memory_bytes: 3488
n = int(input())
T = [int(t) for t in input().split()]
m = int(input()) # num of drinks
drinks = []

for i in range(m):
    p, x = map(int, input().split())
    drinks.append([p,x])

for drink in drinks:
    diff = T[drink[0]-1] - drink[1] # 通常の時間 - 加速された時間
    print(sum(T)-diff)


Measured memory_bytes: 3060
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)


N, X = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(X - e) for e in x]

res = x[0]
for e in x[1:]:
    res = gcd(res, e)
print(res)

Measured memory_bytes: 64536
#include <iostream>
using namespace std;
int p(int a){return a/2;}
int l(int a){return a*2;}
int r(int a){return a*2+1;}
int main(){

  int n,h[260];
  cin>>n;
  for(int i=1;i<=n;i++) cin>>h[i];
  for(int i=1;i<=n;i++){
    cout<<"node "<<i<<": ";
    cout<<"key = "<<h[i]<<", ";
    if(p(i)>=1) cout<<"parent key = "<<h[p(i)]<<", ";
    if(l(i)<=n) cout<<"left key = "<<h[l(i)]<<", ";
    if(r(i)<=n) cout<<"right key = "<<h[r(i)]<<", ";
    cout<<endl;
  }

  return 0;

}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
int main() {
	int n;
	scanf("%d", &n);
	vector<int> ds(n);
	bool bad = false;
	for (int i = 0; i < n; ++i) {
		int d;
		scanf("%d", &d);
		++ds[d];
		if (d == 0 && i) bad = true;
		else if (d && !i) bad = true;
	}
	if (bad) {
		printf("0\n");
		return 0;
	}
	Mint ans = 1;
	for (int i = 1; i < n; ++i) {
		ans *= modex(Mint(ds[i - 1]), ds[i]);
	}
	printf("%d\n", ans.val);
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <string.h>
#include <climits>
#include <map>
#include <stack>
#include <set>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define fi first
#define se second

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

const int maxN = 30000;

string thr = "2 5 63";

bool v[maxN + 2];

void solve(int n){
    v[2] = v[3] = v[4] = v[9] = 1;
    n -= 4;
    int cr = 6;
    while(n >= 2 && cr + 6 <= maxN){
        v[cr + 2] = v[cr + 4] = 1;
        cr += 6;
        n -= 2;
    }
    cr = 12;
    while(n >= 2 && cr + 12 <= maxN){
        v[cr + 3] = v[cr + 9] = 1;
        cr += 12;
        n -= 2;
    }
    
    cr = 6;
    while(n){
        v[cr] = 1;
        n--;
        cr += 6;
    }
    
    string rs = "";
    for(int i = 2; i <= maxN; i++){
        if(v[i]){
            rs += to_string(i) + " ";
        }
    }
    cout << rs.substr(0, rs.size() - 1);
}

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

    int n;
    cin >> n;
    
    if(n == 3){
        cout << thr;
    }
    else{
        solve(n);
    }
    cout << '\n';
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
	int N, V[50], C[50], ans;
	ans = 0;
	cin >> N;

	for (int i = 0; i < N; i++)
		cin >> V[i];
	for (int i = 0; i < N; i++)
	    cin >> C[i];
	for (int i = 0; i < N; i++)
		if (V[i] >= C[i])
			ans += V[i] - C[i];


	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

char s[5];

int main(){
  scanf("%s",s);
  if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]))puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main() {
  int l,r=0,m;
  cin>>l;
  int arr[l];
  for(int i=0;i<l;i++){
    cin>>arr[i];
    if(i%2==0 && arr[i]%2!=0) r++;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int dp[12][10];

void solve(int ca){
    int K; cin>>K;
    if(K<10){
        cout<<K<<endl;
        return;
    }
    memset(dp,0, sizeof(dp));
    for(int i=0;i<10;++i) dp[0][i]=1;
    int total=9;
    int ans_d=0;

    vector<int> ans;
    for (int i = 1; total<=K; ++i) {
        for (int j = 0; j < 10; ++j) {
            if(j>0) dp[i][j]+=dp[i-1][j-1];
            dp[i][j]+=dp[i-1][j];
            if(j<9) dp[i][j]+=dp[i-1][j+1];
            if(j>0) total+=dp[i][j];
            //cout<<j<<endl;
            if(total>=K){
                ans_d=i;
                ans.push_back(j);
                goto finish;
            }
        }
    }
    finish:
    /*
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 10; ++j) {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
     */
    int cnt=total-dp[ans_d][ans[0]];
    //cout<<cnt<<endl;
    //cout<<ans[0]<<endl;
    int d=ans_d;
    ans_d--;
    for(;ans_d>=0;--ans_d){
        int base=ans[ans.size()-1];
        //cout<<base<<endl;
        for (int i = max(base-1,0); i <= min(base+1,10); ++i) {
            if(cnt+dp[ans_d][i]>=K){
                ans.push_back(i);
                break;
            }
            cnt+=dp[ans_d][i];
        }
    }
    for(auto i:ans){
        cout<<i;
    }
    cout<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


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

ans=0
l2=[l[0]]
#print(l2)

for i in range(1,n):
    if l2[i-1] <= l[i]:
        l2+=[l[i]]
        continue
    else:
        l2+=[l2[i-1]]
        ans+=(l2[i]-l[i])

print(ans)

Measured memory_bytes: 32304