akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

template<typename A, size_t N, typename T>
void stfill(A (&arr)[N], const T &val){
    fill((T*)arr, (T*)(arr+N), val);
}

int h, w, s, low;
int u[100][100], su[101][101];

int mm[33][33][33][33][2];

void init() {
    stfill(u, 0);
    stfill(su, 0);
    stfill(mm, 0);
}

// x1 <= x < x2, y1 <= y < y2
int sum(int y1, int x1, int y2, int x2) {
    return su[y2][x2] - su[y2][x1] - su[y1][x2] + su[y1][x1];
}

/**
 * @returns {P} {number of groups, minimum group demand}
 */
P calc(int y1, int x1, int y2, int x2) {
    if (mm[y1][x1][y2][x2][0]) {
        return make_pair(mm[y1][x1][y2][x2][0], mm[y1][x1][y2][x2][1]);
    }

    int total = sum(y1, x1, y2, x2);
    if (total < low) {
        return make_pair(0, 0);
    }
    
    P res = make_pair(1, total);
    for (int i=y1+1; i<y2; ++i) {
        P up = calc(y1, x1, i, x2);
        P down = calc(i, x1, y2, x2);
        if ( ! up.first || ! down.first) continue;
        P t = make_pair(up.first + down.first, min(up.second, down.second));
        res = max(res, t);
    }
    for (int i=x1+1; i<x2; ++i) {
        P left = calc(y1, x1, y2, i);
        P right = calc(y1, i, y2, x2);
        if ( ! left.first || ! right.first) continue;
        P t = make_pair(left.first + right.first, min(left.second, right.second));
        res = max(res, t);
    }
    mm[y1][x1][y2][x2][0] = res.first;
    mm[y1][x1][y2][x2][1] = res.second;
    return res;
}

int main()
{
    while (cin >> h >> w >> s) {
        if ( ! h) break;
        init();
        
        for (int i=0; i<h; ++i) {
            for (int j=0; j<w; ++j) {
                cin >> u[i][j];
            }
        }
        for (int i=1; i<=h; ++i) {
            for (int j=1; j<=w; ++j) {
                su[i][j] = su[i-1][j] + su[i][j-1] - su[i-1][j-1] + u[i-1][j-1];
            }
        }
        low = sum(0, 0, h, w) - s;
        
        P res = calc(0, 0, h, w);
        cout << res.first << " " << res.second - low << endl;
    }
}


Measured memory_bytes: 12436
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] s = new int[M];
            for (int i = 0; i < M; i++) {
                int k = in.nextInt();
                for (int j = 0; j < k; j++) {
                    s[i] |= (1 << (in.nextInt() - 1));
                }
            }
            int[] p = new int[M];
            for (int i = 0; i < M; i++) {
                p[i] = in.nextInt();
            }

            int count = 0;
            for (int mask = 0; mask < (1 << N); mask++) {
                boolean ok = true;
                for (int i = 0; i < M; i++) {
                    int bit = s[i] & mask;
                    if (Integer.bitCount(bit) % 2 == p[i]) {
                    } else {
                        ok = !true;
                    }
                }
                if (ok) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 24148
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int X;
	cin >> X;
	cout << (X >= 30 ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    int j = 1;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        j = a.at(j - 1);
        count++;
        if (j == 2)
            break;
    }
    if (count == N)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << count << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    vector<string> S(3);
    REP(i, 3) cin >> S[i];

    cout << S[0][0] << S[1][1] << S[2][2] << endl;

    return 0;
}

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

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

using namespace std;

int main(){
	int n,q; scanf("%d%d",&n,&q);
	static int a[1000000],perm[1000000];
	rep(i,n) scanf("%d",a+i);
	{
		static pair<int,int> tmp[1000000];
		rep(i,n) tmp[i]=make_pair(a[i],i);
		sort(tmp,tmp+n);
		rep(i,n){
			a[i]=tmp[i].first;
			perm[tmp[i].second]=i;
		}
	}

	set<int> L; // set of leaders
	while(q--){
		char s[7];
		int x; scanf("%s%d",s,&x);
		if(s[0]=='A'){ // ADD
			x--;
			L.insert(perm[x]);
		}
		else if(s[0]=='R'){ // REMOVE
			x--;
			L.erase(perm[x]);
		}
		else{ // CHECK
			// NA or not?
			{
				int r=1000000000;

				int m=0,b[100]; // leaders' score
				for(set<int>::iterator it=L.begin();it!=L.end();++it) b[m++]=a[*it];
				int pre=0,sum=0;
				rep(i,m){
					int now=lower_bound(a,a+n,b[i]-r)-a;
					sum+=max(now-pre,0);
					pre=upper_bound(a,a+n,b[i])-a;
				}
				sum+=n-pre;

				if(sum>x){ puts("NA"); continue; }
			}

			int lo=0,hi=1000000000;
			while(lo<hi){
				int mi=(lo+hi)/2;
				int r=mi;

				int m=0,b[100]; // leaders' score
				for(set<int>::iterator it=L.begin();it!=L.end();++it) b[m++]=a[*it];
				int pre=0,sum=0;
				rep(i,m){
					int now=lower_bound(a,a+n,b[i]-r)-a;
					sum+=max(now-pre,0);
					pre=upper_bound(a,a+n,b[i])-a;
				}
				sum+=n-pre;

				if(sum<=x) hi=mi;
				else       lo=mi+1;
			}
			printf("%d\n",lo);
		}
	}

	return 0;
}

Measured memory_bytes: 16676
n = gets.chomp.to_i

progression = []
n.times { |_i| progression << gets.chomp.to_i}

sorting_progression = progression.sort

n.times do |i|
  remove_number = progression[i]
  if sorting_progression[-1] == remove_number
    puts sorting_progression[-2]
    next
  end
  
  puts sorting_progression[-1]
end


Measured memory_bytes: 7912
#include <iostream>

using namespace std;
using LL = long long;

const int maxN = 605;
const int mod = 1e9 + 7;

int n, K, ans;
int to[maxN], sum[maxN], g[maxN];
int f[maxN][maxN];
bool vis[maxN];

inline int cnt(int i, int j)
{ return sum[j] - sum[i - 1]; }

inline void Mod(int& x)
{ x >= mod ? x -= mod : x < 0 ? x += mod : 0; }

int main()
{
    cin >> n >> K;
    for (int i = 1; i <= K; ++i)
    {
        int a, b;
        cin >> a >> b;
        to[a] = b, to[b] = a;
        ++sum[a], ++sum[b];
    }
    n <<= 1;
    g[0] = 1;
    for (int i = 2; i <= n; i += 2)
        g[i] = (LL)g[i - 2] * (i - 1) % mod;
    for (int i = 1; i <= n; ++i)
        sum[i] += sum[i - 1];
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; j += 2)
        {
            int flag = 0;
            for (int k = i; k <= j; ++k)
                if (to[k] and (to[k] < i or to[k] > j))
                {
                    flag = 1;
                    break;
                }
            if (flag)
                continue;
            f[i][j] = g[j - i + 1 - cnt(i, j)];
            for (int k = i + 1; k < j; k += 2)
                Mod(f[i][j] -= (LL)f[i][k] * g[j - k - cnt(k + 1, j)] % mod);
        }
    }
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; j += 2)
            Mod(ans += (LL)f[i][j] * g[n - j + i - 1 - cnt(1, i - 1) - cnt(j + 1, n)] % mod);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
n=int(input())
v=list(map(int, input().split()))
dp=[[-1] * n for i in range(n)]
def f(a, b):
    if a > b:
        return 0
    elif a == b:
        return v[a]
    elif dp[a][b] == -1:
        c1 = v[a] + min(f(a + 2, b), f(a + 1, b - 1))
        c2 = v[b] + min(f(a, b - 2), f(a + 1, b - 1))
        dp[a][b] = max(c1, c2)
    return dp[a][b]

print(2*f(0, n-1) - sum(v))

Measured memory_bytes: 165128
import itertools
l = [0, 1,2,3,4,5]
X = int(input())

flag = False
d = X//100
if (X - 100*d) <= 5*d:
  for c  in itertools.combinations_with_replacement(l, d):
    if sum(c) == X - 100*d:
      print(1)
      flag = True
      break

if not flag:
  print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,s=0;
  cin>>a>>b>>c;
  s=a*100+b*10+c;
  if(s%4==0)
  {
    YES
  }
  else
  {
    NO
  }

  
  

}
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int N, T, A;
	vector<int> vec(1100);

	cin >> N;
	cin >> T >> A;
	double min = 1e5;
	int min_idx = -1;
	double diff;

	rep(i, N)
	{
		cin >> vec.at(i);
		diff = abs(A - (T - vec.at(i) * 0.006));
		if (diff < min)
		{
			min_idx = i + 1;
			min = diff;
		}
	}
	cout << min_idx << endl;

	return 0;
}

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

void swap(int& a, int& b)
{
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
}

int main()
{
        int x, y, z;
        
        cin >> x >> y >> z;

        if(x>y){ swap(x, y); }
        if(y>z){ swap(y, z); }
        if(x>y){ swap(x, y); }

        cout << x << " " << y << " " << z << endl;
        return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double x[55],ans;
string u[55];
int main(void){
	ll n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i]>>u[i];
		if(u[i]=="JPY"){
			ans=ans+x[i];
		}else{
			ans=ans+x[i]*380000;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[300050];
ll s1[300050];
ll s2[300050];
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 1; i <= 3 * N; i++) scanf("%lld", &in[i]);

	priority_queue <ll, vector<ll>, greater<ll>> Hx1;
	priority_queue <ll> Hx2;

	ll s = 0;
	for (i = 1; i <= N; i++) {
		Hx1.push(in[i]);
		s += in[i];
	}
	s1[N] = s;
	for (i = N + 1; i <= 3 * N; i++) {
		Hx1.push(in[i]);
		s += in[i];
		s -= Hx1.top();
		Hx1.pop();
		s1[i] = s;
	}

	s = 0;
	for (i = 2 * N + 1; i <= 3 * N; i++) {
		Hx2.push(in[i]);
		s += in[i];
	}
	s2[2*N+1] = s;
	for (i = 2 * N; i >= 1; i--) {
		Hx2.push(in[i]);
		s += in[i];
		s -= Hx2.top();
		Hx2.pop();
		s2[i] = s;
	}

	ll ans = -LL_INF;
	for (i = N; i <= 2 * N; i++) ans = max(ans, s1[i] - s2[i + 1]);
	return !printf("%lld\n", ans);
}
//*/

Measured memory_bytes: 8436
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;

    if (b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

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

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var cost = new long[N];
            var max = 0L;
            for (var i = 0; i < N; i++)
            {
                var c = ReadLong();
                cost[i] = c;
                if (c > max)
                {
                    max = c;
                }
            }
            return cost.Sum() - max / 2;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<bool> checked(n,false);
  REP(i,n) cin >> s[i];
  sort(s.begin(), s.end());
  
  
  int sn = 1;
  int x = 1;
  for (int i = 1; i < (n); ++i){
      if(s[i-1] == s[i]){
        x++;
      }
      else{
        x = 1;
      }
    sn = max(x,sn);
  }

  
  x = 1;
  for (int i = 1; i < (n); ++i){
      if(s[i-1] == s[i]){
        x++;
      }
      else{
        x = 1;
      }
    if(x == sn){
      checked[i-1] = true;
    }
    if(sn == 1){
      checked[i] = true;
    }
  }  
  
  REP(i,n){
    if(checked[i]){
	  cout << s[i] << endl;
    }
  }

      
}

Measured memory_bytes: 9580
#include<bits/stdc++.h>
#define PB push_back
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=1000005;
int n,m,d[N];
int pp=1,lnk[N],nxt[N*2],to[N*2];
void ae(int k1,int k2){to[++pp]=k2,nxt[pp]=lnk[k1],lnk[k1]=pp;}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		int k1,k2;scanf("%d%d",&k1,&k2);
		ae(k1,k2),ae(k2,k1);
		++d[k1],++d[k2];
	}
	vector<int>d4;
	rep(i,1,n){
		if(d[i]&1){
			puts("No");
			return 0;
		}
		if(d[i]==4){
			d4.PB(i);
		}
	}
	rep(i,1,n){
		if(d[i]>=6){
			puts("Yes");
			return 0;
		}
	}
	if(SZ(d4)>=3){
		puts("Yes");
		return 0;
	}
	if(SZ(d4)<=1){
		puts("No");
		return 0;
	}
	int k1=d4[0],k2=d4[1],tot=0;
	for(int i=lnk[k1];i;i=nxt[i]){
		int lst=k1,cur=to[i];
		while(cur!=k1&&cur!=k2){
			lst=to[lnk[cur]]+to[nxt[lnk[cur]]]-lst;
			swap(lst,cur);
		}
		if(cur==k2)++tot;
	}
	if(tot==2)puts("Yes");else puts("No");
	return 0;
}

Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    if(S[0] == '7' || S[1] == '7' || S[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3620
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if sum(a) < x:
  print(N-1)
  exit()
cnt = 0
su = 0
for i in range(N):
  if su + a[i] <= x:
    su += a[i]
    cnt += 1
  else:
    break
print(cnt)

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

int main(){
	int a, b, i = 1;
	char ch;	

	cin>>a;

	while(1){
		cin>>ch;
		if(ch == '=') break;
		cin>>b;
		if(ch == '+')a += b;
		if(ch == '-')a -= b;
		if(ch == '*')a *= b;
		if(ch == '/')a /= b;
		
	}
	
	cout<<a<<endl;	

	return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#define N 100001

struct Node{
  int p;
  int l;
  int r;
};
struct Node T[N];
int getDepth(int p){
  if(T[p].p == -1) return 0;
  return getDepth(T[p].p)+1;
}
int main()
{
  int n;
  int i,j;
  int sign;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=-1;
  }
  int k,c;
  int id;
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	T[id].l=c;
	T[c].p=id;
	sign=c;
      }
      else{
	T[sign].r=c;
	T[c].p=id;
	sign=c;
      }
    }
  }
  int depth[N];
  for(i=0;i<n;i++)
    depth[i]=getDepth(i);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);
    if(T[i].p==-1)
      printf("root, [");
    else if(T[i].l==-1)
      printf("leaf, [");
    else{
      printf("internal node, [");
    }
    if(T[i].l != -1){
      printf("%d",T[i].l);
      sign = T[i].l;
      while(1){
	if(T[sign].r==-1) break;
	printf(", %d",T[sign].r);
	sign = T[sign].r;
      }
    }
    printf("]\n");
  }
  return 0;
}



Measured memory_bytes: 3292
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	rep(i,0,n) cin >> a[i];
	ll neg=0;
	rep(i,0,n){
		if(a[i]<0) neg++;
	}
	ll ans=0;
	if(neg%2){
		ll mini=inf;
		rep(i,0,n){
			ans+=abs(a[i]);
			mini=min(mini,abs(a[i]));
		}
		ans-=2*mini;
	}
	else{
		rep(i,0,n) ans+=abs(a[i]);
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s.size() == 2) {
        cout << s << endl;
    }
    else {
        cout << s[2] << s[1] << s[0] << endl;
    }
    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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    ll minn = INFLL;
    int cnt = 0;
    rep(i,N){
        if(minn > A[i])cnt++;
        chmin(minn,A[i]);
    }
    cout<<cnt<<endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  rep(i, 0, N) { cin >> w[i] >> v[i]; }
  vector<int> dp(1e5 + 100, INF);
  dp[0] = 0;
  rep(i, 0, N) {
    rrep(j, v[i], dp.size()) { chmin(dp[j], dp[j - v[i]] + w[i]); }
  }
  int ans = 0;
  rep(i, 0, dp.size()) {
    if (dp[i] <= W) {
      chmax(ans, i);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#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 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 sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<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 vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll sum = 0;
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        sum += a[i];
    }

    sort(a,a+n);

    sum -= a[n-1];

    if(sum>a[n-1])yn;


    return 0;
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 998244353
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> h(N); rep(i,N)cin>>h[i];
    vector<ll> dp(N,INF); dp[0] = 0;
    rep(i,N){
        if(i+1<N)dp[i+1] = min(dp[i+1],dp[i]+(ll)fabs(h[i+1]-h[i]));
        if(i+2<N)dp[i+2] = min(dp[i+2],dp[i]+(ll)fabs(h[i+2]-h[i]));        
    }
    cout<<dp[N-1]<<endl;
}

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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll memo[3010][3010];
ll v[3010];
ll sum[3010];
int n;

ll dp(int i, int j){
	if(i == j)
		return v[i];
		
	if(memo[i][j] != -1LL)
		return memo[i][j];
		
	ll acu = sum[j] - sum[i-1];
	
	return memo[i][j] = acu - min(dp(i+1, j), dp(i, j-1));
}

int main() {	
	memset(memo, -1, sizeof(memo));
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> v[i];
		sum[i] = sum[i-1] + v[i];
	}
	
	cout << 2LL*dp(1, n) - sum[n] << endl;

	return 0;	
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
    string N;
    cin >> N;
    reverse(N.begin(), N.end());
    int digit = N.size();
    vector<int> money(digit + 1, 0);
    rep(i, digit)
    {
        money[i] = N[i] - '0';
    }
    rep(i, digit)
    {
        if (money[i] > 5)
        {
            money[i] = 10 - money[i];
            money[i + 1]++;
        }
        else if (money[i] == 5)
        {
            if (money[i + 1] >= 5)
            {
                money[i] = 10 - money[i];
                money[i + 1]++;
            }
        }
    }
    int ans = 0;
    rep(i, digit + 1)
    {
        ans += money[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5380
import collections
import math

n = int(input())
a = list(map(int, input().split(" ")))

s = [0]
for i in range(1, n + 1):
    s.append(s[i-1] + a[i-1] )

ans = 0
for v in collections.Counter(s).values():
    if v >= 2:
        ans += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
print(ans)

Measured memory_bytes: 111588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	ll n;
	cin >> n;

	printf("%lld", n * (n - 1LL) / 2LL);

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int ans = 90909;

    if(n < 10){
      ans = n;
    } else if(n < 100){
      ans = 9;
    } else if(n < 1000){
      ans = n - 90;
    } else if(n < 10000){
      ans = 909;
    } else if(n < 100000){
      ans = n -9090;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

vector <int> v;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ll n;
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0;
    while(n > 0) {
        v.push_back(n % 10);
        ans += n % 10;
        n /= 10;
    }
    reverse(v.begin(), v.end());
    int s = 0;
    for(i = 0; i < v.size(); i++) {
        ans = max(ans, s + v[i] - 1 + ((int) v.size() - i - 1) * 9);
        s += v[i];
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1200031;

int dp[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	for (int i=0;i<=1000000;i++){
		dp[i]=1e9;
	}
	dp[0]=0;
	for (int i=0;i<1000000;i++){
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for (int j=6;j+i<=1000000;j*=6){
			dp[i+j]=min(dp[i+j],dp[i]+1);
		}
		for (int j=9;j+i<=1000000;j*=9){
			dp[i+j]=min(dp[i+j],dp[i]+1);
		}
	}

	int n;
	cin>>n;
	cout<<dp[n]<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(n) for (int i = 0; i < (n); ++i)
int main()
{
    int n;
    string s;
    cin >> n>>s;
    bool ans;
    if(n%2==0){
        ans=true;
        rep(n/2){
            if(s[i]!=s[i+n/2])ans=false;
        }
    }else{
        ans=false;
    }
    cout<<((ans)?"Yes":"No");
}

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

int main(){
  string h;
  int A_iks;

  //sorry

  for(;;){
    int sum = 1,top = 1,dice[4] = {2,3,4,5};
    cin >> A_iks;
    if(A_iks == 0) break;
    for(int i = 0 ; i < A_iks ; i++){
      cin >> h;
      int tmp = top;
      if( i == 0 ) top = 1;
      if(h == "North"){
	top = dice[0];
	dice[0] = 7 - tmp;
	dice[3] = tmp;
      }
      else if(h == "East"){
	top = dice[2];
	dice[2] = 7 - tmp;
	dice[1] = tmp;
      }
      else if(h == "West"){
	top = dice[1];
	dice[1] = 7 - tmp;
	dice[2] = tmp;	
      }
      else if(h == "South"){
	top = dice[3];
	dice[3] = 7 - tmp;
	dice[0] = tmp;
      }
      else if(h == "Right"){
	tmp = dice[3];
	dice[3] = dice[2];
	dice[2] = dice[0];
	dice[0] = dice[1];
	dice[1] = tmp;
      }
      else{
	tmp = dice[3];
	dice[3] = dice[1];
	dice[1] = dice[0];
	dice[0] = dice[2];
	dice[2] = tmp;	
      }
      sum += top;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5,mod=1e9+7;
vector< pair<ll,ll> > adj[N];
ll n,m,s,t,dp[N][2],D[N][2];
priority_queue< pair<ll,ll> > pq;
void SSSP(ll s,ll w){
    D[s][w]=0;
    dp[s][w]=1;
    pq.push({0,s});
    while(!pq.empty()){
        ll v = pq.top().second;
        ll d = -pq.top().first;
        pq.pop();
        if(d>D[v][w])continue;
        for(auto &u:adj[v]){
            if(D[u.first][w] > D[v][w] + u.second){
                dp[u.first][w] = 0;
                D[u.first][w] = D[v][w] + u.second;
                pq.push({-D[u.first][w] , u.first});
            }

            if(D[u.first][w] == D[v][w] + u.second){
                dp[u.first][w]+=dp[v][w];
                if(dp[u.first][w]>=mod)dp[u.first][w]-=mod;
            }
        }
    }
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m>>s>>t;
    for(ll i=1;i<=m;i++){
        ll u,v,d;cin>>u>>v>>d;
        adj[u].push_back({v,d});
        adj[v].push_back({u,d});
    }
    memset(D,0x3f,sizeof(D));
    SSSP(s,0);
    SSSP(t,1);

    ll ans = dp[t][0]*dp[t][0];
    ans%=mod;


    for(ll i=1;i<=n;i++){
        if(D[i][0]*2==D[t][0] && D[i][1]*2==D[t][0])
            ans = (ans - dp[i][0]*dp[i][1]%mod*dp[i][0]%mod*dp[i][1]%mod + mod)%mod;
    }

    for(ll i=1;i<=n;i++){
        for(auto &u:adj[i]){
            if(D[i][0] + u.second + D[u.first][1] == D[t][0] && D[i][0]*2<D[t][0] && D[u.first][1]*2<D[t][0] )
                ans = (ans - dp[i][0]*dp[u.first][1]%mod*dp[i][0]%mod*dp[u.first][1]%mod + mod)%mod;
        }
    }

    cout<<ans;
}

Measured memory_bytes: 18288
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {
	
	static int triplets(int x){
	    int cnt = 0;
	    for(int i = 1; i <= (int)(1e2); i++){
	        for(int j = 1; j <= (int)(1e2); j++){
	            for(int k = 1; k <= (int)(1e2); k++){
	                if(i * i + j * j + k * k + i * j + j * k + k * i > x)break;
	                if(i * i + j * j + k * k + i * j + j * k + k * i == x)cnt++;
	            }
	        }
	    }
	    return cnt;
	}
	 
	 

	public static void main(String[] args) {
		FastScanner stdIn = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = stdIn.nextInt();
		 
		    for(int i = 1; i <= n; i++){
		        out.println(triplets(i));
		 
		    }
		 
		 
		out.flush();
	}

}


Measured memory_bytes: 34256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int m,na,nb;
		cin>>m>>na>>nb;
		if(!m)break;
		int p[m];
		rep(i,m)cin>>p[i];
		int s=0;
		int ans;
		REP(i,na,nb){
			if(s<=p[i-1]-p[i]){
				s=p[i-1]-p[i];
				ans=i;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3016
#include <cstdio>

using namespace std;

long long ans;

int n,suma,sumb,a[10000010];

int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  int l=1,r=0;
  while(l<=n)
  {
    while((suma^a[r+1])==(sumb+a[r+1])&&r<n)
    {
      suma^=a[r+1];
      sumb+=a[r+1];
      r++;
    }
    ans=ans+(r-l+1);
    suma=suma^a[l];
    sumb=sumb-a[l];
    l++;
  }
  printf("%lld",ans);
}


Measured memory_bytes: 2512
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  string ans;
  if (s[0] == s[1] && s[1] == s[2]) ans = "Yes";
  else if (s[1] == s[2] && s[2] == s[3]) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}

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

class SegmentTree {
	const int n;
	const int id = 1;
	vector<int> data;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void sub(int l, int r, int node, int lb, int ub, int val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data[node] += val;
			return;
		}
		sub(l, r, node * 2, lb, (lb + ub) / 2, val);
		sub(l, r, node * 2 + 1, (lb + ub) / 2, ub, val);
	}
public:
	SegmentTree(int n_) :
		n(size(n_)), data(n * 2, 0) {}
	void add(int l, int r, int val) {
		sub(l, r + 1, 1, 0, n, val);
	}
	int get(int i) {
		i += n;
		int res = data[i];
		while (i >>= 1) {
			res += data[i];
		}
		return res;
	}
};

int main()
{
	int n, q, b, i, s, t, x;
	cin >> n >> q;
	SegmentTree raq(n);
	while (q--) {
		cin >> b;
		if (b) {
			cin >> i;
			cout << raq.get(i - 1) << endl;
		}
		else {
			cin >> s >> t >> x;
			raq.add(s - 1, t - 1, x);
		}
	}
	return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const int INF = (1LL<<31)-1;

int main(){
    ll K; cin >> K;
    vector<vector<P> > G(K);
    for(int i=0;i<K-1;i++){
        G[i].push_back({10*i%K,0});
        G[i].push_back({(i+1),1});
    }
    G[K-1].push_back({10*(K-1)%K,0});
    G[K-1].push_back({0,1});
    vector<int> dist(K,INF);

    deque<P> que; que.push_back({1,1});
    
    while(!que.empty()){
        P cur = que.front();
        que.pop_front();
        int v = cur.first;
        int cost = cur.second;
        if(dist[v]!=INF) continue;
        dist[v] = cost;

        for(auto nxt : G[v]){
            int nv = nxt.first;
            int c = nxt.second;
            if(dist[nv]==INF){
                if(c){
                    que.push_back({nv,cost+1});
                }else{
                    que.push_front({nv,cost});
                }
            }
        }
    }
    cout << dist[0] << endl;
}

Measured memory_bytes: 9580
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> data(m);
    for(int i = 0; i < m; ++i) {
        cin >> data[i];
    }
    ll sum = accumulate(data.begin(), data.end(), 0LL);
    int ans = 0;
    if(n >= sum){
        ans = n - sum; 
    } else {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b; cin >> a >> b;
	int n = b - a;
	cout << n*(n + 1)/2 - b << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    double l;
    cin>>l;
    cout<<fixed<<setprecision(10)<<(l/3)*(l/3)*(l/3)<<endl;
}


Measured memory_bytes: 256