akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

ll gcd(ll x, ll y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

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

	ll a, b;
	std::cin >> a >> b;
	ll ans = 1, gcdv = gcd(a, b);
	ll sq = sqrt(gcdv) + 1;
	srep(i, 2, sq + 1) {
		if (gcdv % i == 0)
			ans++;
		while (gcdv % i == 0)
			gcdv /= i;
	}
	if (gcdv > 1)
		ans++;
	std::cout << ans << "\n";
}


Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, M; cin >> N >> M;
	int s[10][10] = { 0 };
	rep(i, M) {
		int k; cin >> k;
		rep(j, k) cin >> s[i][j];
	}
	vector<int> p(M);
	rep(i, M) cin >> p[i];

	int ans = 0;
	rep(bit, 1 << N) {
		bool F = true;
		rep(i, M) {
			int t = 0;
			rep(j, M) {
				int tmp = s[i][j];
				if (tmp == 0) break;
				if (bit & (1 << (tmp - 1))) t++;
			}
			if (t % 2 != p[i]) {
				F = false;
				break;
			}
		}
		ans = (F ? ans + 1 : ans);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
console.log((args=>{
  const [[K,S]] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  let count = 0;
  for ( let x = Math.min(K,S); x >= 0; x-- ) {
    for ( let y = Math.min(K,S-x); y >= Math.max(0,S-x-K); y-- ) count++;
  }
  return count.toString();
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<long long int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n, k;
    in2(n, k)
    VI p(n), c(n);
    inar(n, p) inar(n, c)
    rep(i, n) --p[i];
    int64 ans = INT_MIN;
    rep(i, n)
    {
        int v = i;
        int64 cycle_sum = 0;
        int cycle_count = 0;
        while(true){
            cycle_sum += c[v];
            cycle_count++;
            v = p[v];
            if(v == i) break;
        }
        int64 path = 0;
        int cnt = 0;
        while(true){
            cnt++;
            path += c[v];
            if(cnt > k) break;
            int num = (k-cnt)/cycle_count;
            int64 score = path + max((int64)0, cycle_sum)*num;
            ans = max(ans,score);
            v = p[v];
            if(v == i) break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define int long long

using namespace std;
typedef long long ll;
const int MAXN = 100005;
inline int readint()
{
	int res = 0, f = 1;
	char c = 0;
	while(!isdigit(c))
	{
		c = getchar();
		if(c=='-')
			f = -1;
	}
	while(isdigit(c))
		res = res*10+c-'0', c = getchar();
	return res*f;
}
int n;
pii s[MAXN],t[MAXN];
ll ansp = 1<<30, ansq = 1;
inline void getMin(ll x, ll y)
{
	if((__int128)x*ansq<(__int128)y*ansp)
		ansp = x, ansq = y; 
}
ll pre[MAXN],sum;
inline ll calc(int x, int mid)
{
	int val = max(s[x].fi,s[x].se);
	return t[mid].fi<=val?pre[mid]-val:pre[mid];
}
inline int binSearch(int x)
{
	int left = 1, right = n, res = -1, mid;
	while(left<=right)
	{
		mid = (left+right)>>1;
		if(calc(x,mid)>=sum-s[x].se)
			res = mid, right = mid-1;
		else
		    left = mid+1;
	}
	return res;
}
inline ll gcd(ll a, ll b)
    { return b?gcd(b,a%b):a; }

signed main()
{
	n = readint();
	for(int i = 1; i<=n; i++)
	{
		s[i].fi = readint(), s[i].se = readint();
		t[i].fi = max(s[i].fi,s[i].se), t[i].se = i;
		sum += s[i].fi;
	}
	sort(t+1,t+n+1), reverse(t+1,t+n+1);
	for(int i = 1; i<=n; i++)
		pre[i] = pre[i-1]+t[i].fi;
	for(int i = 1; i<=n; i++)
	{
		int res = binSearch(i);
		if(res<0)
			continue;
		ll val = sum-calc(i,res);
		if(t[res].fi<=max(s[i].fi,s[i].se))
			res--;
		if(val<0)
			continue;
		getMin(1ll*res*s[i].se+val,s[i].se);
	}
	ansq *= n, ansp = ansq-ansp;
	if(ansp<=0)
    {
		cout << 0 << " " << 1 << endl;
		return 0;
	}
	ll g = gcd(ansp,ansq);
	cout << ansp/g << " " << ansq/g << endl;
	return 0;
}


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

int main()
{	
	int colors[9] = {399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 5000};
	int freq[9] = {0};

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

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			if (array[i] <= colors[j])
			{
				freq[j]++;
				break;
			}
		}
	}
	int minimum = 0, maximum = 0;
	for (int i = 0; i < 8; ++i)
	{
		if (freq[i] != 0) minimum++;
	}
	maximum = minimum;
	maximum += freq[8];
	if (minimum == 0) minimum = 1;

	cout << minimum << " " << maximum;

	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

fans = 100000000
for i in range(len(s) - len(t) + 1):
    ans = 0
    for j in range(len(t)):
        if (s[i+j] == t[j]):
            pass
        else:
            ans += 1
    fans = min(fans, ans)

print(fans)

Measured memory_bytes: 9056
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main () {
	SpeedForce;
	double r;
	cin >> n;
	r = n;
	cout << fixed << setprecision(10) << 2 * r * pi << '\n';

	return Accepted;
}

// B...a

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

const ll mod=1000000007;
void solve(){
  ll n;
  cin>>n;
  ll ans=1;
 

  if(n==1) {cout<<"0"<<endl; return ;}
  
  ll all=1;
  ll non=1;
  ll t=1;
    for(ll i=0;i<n;i++) {
          all=(all*10)%mod;
          non=(non*8)%mod;
     t=(t*9)%mod;
    }
   ans=(all+non)%mod;
   ans= (ans-(2*t)%mod + mod)%mod;
   cout<<ans<<endl;

  
 

}


int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
#ifndef ONLINE_JUDGE
      freopen("in.txt", "r", stdin);
     // freopen("ou1.txt","w",stdout);

#endif
  
//   time_t start, end; 
  
   
//     time(&start); 
      int  t;
      t=1;
      while (t--)
            solve();

      // time(&end); 
  
   
//     double time_taken = double(end - start); 
//     cout << "Time taken by program is : " << fixed 
//          << time_taken << setprecision(5); 
//     cout << " sec " << endl; 

      return 0;
}


Measured memory_bytes: 3648
import scala.math._

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

  val a = scanner.nextInt()
  val b = scanner.nextInt()
  val C = scanner.nextInt()
  val c = C / 360.0 * 2 * Pi
  
  val S = b * (a * sin(c)) / 2
  val L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c))
  val h = b * sin(c)

  val outputs = Seq(S, L, h)

  outputs.foreach(println)
}

Measured memory_bytes: 45172
import sys
n=int(input())
s=list(input())
count=0
if len(s)==1:
    print("No")
    sys.exit()
else:
    for i in range(len(s)//2):
        if len(s)%2==0 and s[i]==s[i+len(s)//2]:
            count+=0
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include<cstdio>
#include<bitset>
using namespace std;
const int N=440,M=100100;
int i,j,k,n,m,ch,ff,ans;
int x[M],y[M],fg[N];
bitset<N> A[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int main() {
	R(n);R(m);
	for (i=1;i<=m;i++) R(x[i]),R(y[i]);
	for (i=1;i<=n;i++) A[i][i]=1;
	for (i=m;i;i--) {
		for (j=1;j<=n;j++) if (A[j][x[i]]|A[j][y[i]]) {
			if (A[j][x[i]]&A[j][y[i]]) fg[j]=1;
			else A[j][x[i]]=A[j][y[i]]=1;
		}
	}
	for (i=1;i<=n;i++) if (!fg[i])
		for (j=i+1;j<=n;j++) if (!fg[j] && (A[i]&A[j]).count()==0) ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N;
string s;

V<int> memo[4];

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

    memo[0].resize(N,-1);
    memo[1].resize(N,-1);
    memo[2].resize(N,-1);
    memo[3].resize(N,-1);
    memo[0][0] = 1; memo[0][N-1] = 1;
    memo[1][0] = 1; memo[1][N-1] = 0;
    memo[2][0] = 0; memo[2][N-1] = 1;
    memo[3][0] = 0; memo[3][N-1] = 0;
    REP(i,s.size()) {
        int x = (i-1<0) ? N-1 : i-1;
        int y = (i+1>=N) ? 0 : i+1;
        REP(j,4) {
            if(s[i] == 'o')
                memo[j][y] = (memo[j][i]) ? memo[j][x] : memo[j][x] ^ 1;
            else
                memo[j][y] = (memo[j][i]) ? memo[j][x] ^1 : memo[j][x];
        }
    }

    bool ok[4] = {true,true,true,true};
    REP(i,s.size()) {
        int x = (i-1<0) ? N-1 : i-1;
        int y = (i+1>=N) ? 0 : i+1;
        REP(j,4) {
            if(s[i] == 'o') {
                if(memo[j][i] == 1 && memo[j][x] != memo[j][y]) ok[j] = false;
                if(memo[j][i] == 0 && memo[j][x] == memo[j][y]) ok[j] = false;
            } else {
                if(memo[j][i] == 1 && memo[j][x] == memo[j][y]) ok[j] = false;
                if(memo[j][i] == 0 && memo[j][x] != memo[j][y]) ok[j] = false;
            }
        }
    }
    if(!ok[0] && !ok[1] && !ok[2] && !ok[3]) {
        cout << -1; return 0;
    }

    REP(j,4) {
        if(!ok[j]) continue;
        REP(i,N) {
            if(memo[j][i]) cout << 'S';
            else cout << 'W';
        }
        break;
    }
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define MAX 1e9
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;

int main(){
  int N,Q;
  cin>>N>>Q;  
  vector<event>v;
  rep(i,N){
    int s,t,x;cin>>s>>t>>x;
    v.push_back({s-x,P(-1,x)});
    v.push_back({t-x,P(0,x)});
  }
  rep(i,Q){
    int d;cin>>d;
    v.push_back({d,P(1,i)});
  }
  sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
   for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
  
}


Measured memory_bytes: 28040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n){
    int x;
    cin >> x;
    ans += min(x, k - x);
  }
  cout << ans * 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<int> v[200000];
double dp1[200000];
double dp2[200000];

double dfs1(int u,int prev){
    double ret = 0.0;
    int cnt;
    if(u==prev) cnt = v[u].size();
    else cnt = v[u].size()-1;
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        ret += (dfs1(v[u][i],u)+1.0)/cnt;
    }
    return dp1[u] = ret;
}

void dfs2(int u,int prev){
    double ret = 0.0;
    int cnt = v[u].size();
    int bf = v[prev].size();
    int w = (bf==1?bf:bf-1);
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev){
            ret += ((dp2[prev]*bf-(dp1[u]+1.0))/w+1.0)/cnt;
        }
        else ret += (dp1[v[u][i]]+1.0)/cnt;
    }
    dp2[u] = ret;
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        dfs2(v[u][i],u);
    }
}


int main(){
    int N;cin >> N;
    for (int i = 0; i < N-1; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs1(0,0);
    dfs2(0,0);
    for (int i = 0; i < N; i++) {
        cout << setprecision(10) << fixed << dp2[i] << endl;
    }
    return 0;
}


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


public class Main {

	/**
	 * @param args
	 */

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String tmp = br.readLine();
		int n = Integer.parseInt(tmp);
		
		int[] input = new int[n];

		String[] tmpArray = br.readLine().split(" ");
		
		int numOf4Times = 0;
		int numOfOdd = 0;
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
			if(input[i] % 2 == 1){
				numOfOdd++;
			}
			else if(input[i] % 4 == 0){
				numOf4Times++;
			}
		}
		
		if(n % 2 == 1){
			if(numOfOdd - numOf4Times <= 1){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		
		else {
			if(numOfOdd - numOf4Times <= 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 37152
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]

eo = [0]*2

As = sorted(A)
for i in range(N):
    if i % 2 != bisect.bisect_left(As, A[i]) % 2:
        eo[i % 2] += 1

print(max(eo))


Measured memory_bytes: 8296
import sys
readline = sys.stdin.readline

# 区間DP
# dp[l][r] = 区間[l,r]のスライムを合体するときの最小コスト
# dp[l][r] = min(dp[l][m] + dp[m + 1][r]) + sum(l,r)

N = int(readline())
A = list(map(int,readline().split()))

A = [0] + A
for i in range(1,len(A)):
  A[i] += A[i - 1]

INF = 10 ** 18
dp = [[INF] * N for i in range(N)]
for i in range(N):
  dp[i][i] = 0

# 区間の長さが小さい順にループする(1～N)
for i in range(N): # 区間の長さ
  for l in range(N - i):
    r = l + i
    # lからrまでの区間で最小となるdp[l][m] + dp[m][r]の組み合わせを探す
    # lからrまでのAの累積和
    cums = A[r + 1] - A[l]
    for m in range(l,r):
      if dp[l][m] + dp[m + 1][r] + cums < dp[l][r]:
        dp[l][r] = dp[l][m] + dp[m + 1][r] + cums
        
print(dp[0][-1])


Measured memory_bytes: 75168
#include <iostream>
using namespace std;
int main(){
  long long a, b, k;
  cin >> a >> b >> k;
  if(k<=a) cout << a-k <<" " << b;
  else if(a<k && k<=a+b) cout << 0 <<" " << b+a-k;
  else cout << 0 <<" " << 0;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

int main(){
    int N, M; cin >> N >> M;
    vector<pi> ab(M);
    rep(i, M) cin >> ab[i].second >> ab[i].first;
    sort(ALL(ab));
    int ans = 0, f = 0, pos = 0;
    rep(i, M){
        if(pos < ab[i].second) f = 1;
        if(f) {ans++; f = 0; pos = ab[i].first - 1;}

    }
    cout << ans << endl;

}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    n%=10;
    if(n==3) cout << "bon\n";
    else if(n==0||n==1||n==6||n==8) cout << "pon\n";
    else cout << "hon\n";
    return 0;
}


Measured memory_bytes: 3620
// ALDS1_9_C.cpp
// Heaps - Priority Queue

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
static const int N = 2000000;
int H = 0;
vector<int> heaps(N);

void insert(vector<int> &heaps, int num)
{
    heaps[++H] = num;
    int i = H;
    int parent = i / 2;
    while (parent >= 1 && heaps[parent] < heaps[i]) {
        swap(heaps[parent], heaps[i]);
        i = parent;
        parent = i / 2;
    }
}

void maxHeapify(vector<int> &A, int i)
{
    int l = 2 * i;
    int r = 2 * i + 1;
    int greatest = i;
    if (l <= H && A[l] > A[i]) {
        greatest = l;
    }
    if (r <= H && A[r] > A[greatest]) {
        greatest = r;
    }
    if (greatest != i) {
        swap(A[greatest], A[i]);
        maxHeapify(A, greatest);
    }
}

void extract(vector<int> &heaps)
{
    if (H < 1) {
        return;
    }
    int res = heaps[1];
    heaps[1] = heaps[H--];
    maxHeapify(heaps, 1);
    cout << res << endl;
}

int main()
{
    string cmd;
    int num;

    while(cin >> cmd) {
        if (cmd == "end") break;
        else if (cmd == "insert") {
            cin >> num;
            insert(heaps, num);
        }
        else if (cmd == "extract") {
            extract(heaps);
        }
    }
    return 0;
}

Measured memory_bytes: 10596
main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine
    print $ solve n k

solve :: Int -> Int -> Int
solve n k
    | odd k
    = length [k, k * 2 .. n] ^ 3
    | even k
    = length [(k `div` 2), (k `div` 2 + k) .. n]
        ^ 3
        + length [k, 2 * k .. n]
        ^ 3

Measured memory_bytes: 892
//kagami-mochi ABC_085
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int ans;
  int x=0;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  for(int j=0;j<N;j++){
    if(v.at(j)>x){
      x=v.at(j);
      ans++;
    }
  }
    cout<<ans<<endl;

    
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R' ) {
  cout << "3" << endl;
}
else if (S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'S') {
  cout << "2" << endl;
}
else if (S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'R') {
  cout << "2" << endl;
}
else if (S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'R') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'S') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'S') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'R') {
  cout << "1" << endl;
}
  else if (S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'S') {
  cout << "0" << endl;
}
return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}
 
class Sol{
	public void Solve(){
		Array.Sort(A);
		Console.WriteLine(A[2] * 10 + A[1] + A[0]);
	}
	int[] A;
	public Sol(){
		A = ria();
	}
 
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

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

typedef long long ll;
using namespace std;

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

	while(true){
		int n; cin >> n;
		if(n == 0) break;

		bool a[2][202];
		int cnt[2] = {n,n};
		memset(a,0,sizeof(a));
		for (int i = 0;i < n;i++){
			int tmp; cin >> tmp;
			a[0][tmp] = true;
		}
		for (int i = 1;i <= n*2;i++){
			if(!a[0][i]) a[1][i] = true;
		}

		int c = 0,d = 0;
		while(true){
			while(d <= n*2 && !a[c%2][d]) d++;
			if(d > n*2){
				c++; d = 0;
			}else{
				a[c%2][d] = false;
				cnt[c%2]--; 
				if(cnt[c%2] == 0){
					cout << cnt[1] << endl << cnt[0] << endl;
					break;
				}
				d++; c++;
			}
			
		}
	}

	return 0;

}



Measured memory_bytes: 3076
#include<stdio.h>
#include<stdlib.h>
int merge(int *S,int left,int mid,int right,int count){
    int n1,n2,i,j,k;
    double *L,*R;
    n1=mid-left;
    n2=right-mid;
    L=malloc(sizeof(double)*(n1+1));
    R=malloc(sizeof(double)*(n2+1));
    for(i=0;i<n1;i++){
        *(L+i)=*(S+left+i);
    }
    for(i=0;i<n2;i++){
        *(R+i)=*(S+mid+i);
    }
    *(L+n1)=10000000000;
    *(R+n2)=10000000000;

    i=0; j=0;
    for(k=left;k<right;k++){
        if(*(L+i)<=*(R+j)){
            *(S+k)=*(L+i);
            i=i+1;
            count++;
        }
        else{
            *(S+k)=*(R+j);
            j=j+1;
            count++;
        }
    }
    free(L);
    free(R);
    return count;
}

int mergeSort(int *S, int left,int right,int count){
    int mid;
    if((left+1)<right){
        mid=(left+right)/2;
        count=mergeSort(S,left,mid,count);
        count=mergeSort(S,mid,right,count);
        count=merge(S,left,mid,right,count);
    }
    return count;
}
int main(void){
    int n,*S,i,count=0;
    scanf("%d",&n);
    S=malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",(S+i));
    }
    count=mergeSort(S,0,n,count);
    for(i=0;i<n-1;i++){
        printf("%d ",*(S+i));
    }
    printf("%d\n",*(S+i));
    printf("%d\n",count);
    free(S);
    return 0;
}


Measured memory_bytes: 7316
import java.util.*;
import java.util.stream.*;

public class Main {
	Scanner sc;
	int A,B,C;
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	/**
	 * アルゴリズム本体
	 */
	private void calc() {
		int remain = A-B;
		out(Math.max(0, C - remain));
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	private void input() {
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
	}
	
//======
// main
//
	public static void main(String[] args) {
		Main m = new Main();
		m.input();
		m.calc();
	}

}

Measured memory_bytes: 22740
/******* all required header files *******/
#include<iostream>
#include<algorithm>
#include<cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define mp make_pair
#define ll long long int
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int a, b;
	cin >> a >> b;
	if(a==1) a+=13;
	if(b==1) b+=13;
	if(a>b)
    cout << "Alice" << endl;
	else if(a<b)
	cout << "Bob" << endl;
	else
	cout << "Draw" << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N; std::cin >> N;
    int sum(0);
    std::vector<int> ans(N, NIL), a(N-1), b(N-1), c(N);
    for(int i(0), i_len(N-1); i < i_len; ++i){
        std::cin >> a[i] >> b[i];
        --a[i]; --b[i];
    }
    for(int i(0); i < N; ++i){
        std::cin >> c[i];
        sum += c[i];
    }
    std::sort(std::rbegin(c), std::rend(c));
    std::cout << sum - c[0] << "\n";
    ans[a[0]] = c[0]; ans[b[0]] = c[1];
    for(int i(2); i < N; ++i){
        for(int j(0), j_len(N-1); j < j_len; ++j){
            if((ans[a[j]] != NIL && ans[b[j]] != NIL)) continue;
            if((ans[a[j]] == NIL && ans[b[j]] == NIL)) continue;
            if(ans[a[j]] == NIL){
                ans[a[j]] = c[i]; break;
            }
            if(ans[b[j]] == NIL){
                ans[b[j]] = c[i]; break;
            }
        }
    }
    for(int i(0); i < N; ++i){
        if(i) std::cout << " ";
        std::cout << ans[i];
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3716
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: u8 = sc.read();
    let w: u8 = sc.read();
    if w >= s {
        println!("unsafe");
    } 
    else {
        println!("safe");
    }
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX_A = 90000;
int px[MAX_A+1], py[MAX_A+1], imos[MAX_A];

int main() {
    int h, w, d, a, q, l, r;
    cin >> h >> w >> d;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a;
            px[a] = j, py[a] = i;
        }
    }
    for (int i = d + 1; i <= h * w; i++) {
        imos[i] = imos[i-d] + abs(px[i] - px[i-d]) + abs(py[i] - py[i-d]);
    }
    cin >> q;
    while(q--) {
        cin >> l >> r;
        cout << imos[r] - imos[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

map<char, string(*)(string)> functions;


string rev_J(string s){
    string t = "";
    for(int i=0; i<s.size(); i++)
        t += s[(i+s.size()-1)%s.size()];
    return t;
}

string rev_C(string s){
    string t = "";
    for(int i=0; i<s.size(); i++)
        t += s[(i+1)%s.size()];
    return t;
}

string rev_E(string s){
    int n = s.size();
    for(int i=0; i<n/2; i++){
        swap(s[i], s[i+(n+1)/2]);
    }
    return s;
}

string rev_A(string s){
    reverse(s.begin(), s.end());
    return s;
}

string rev_P(string s){
    for(int i=0; i<s.size(); i++){
        char &c = s[i];
        if('0'<=c && c<='9'){
            c = (c-'0'-1+10)%10 + '0';
        }
    }
    return s;
}

string rev_M(string s){
    for(int i=0; i<s.size(); i++){
        char &c = s[i];
        if('0'<=c && c<='9'){
            c = (c-'0'+1)%10 + '0';
        }
    }
    return s;
}

void solve(){
    string members, message;
    cin >> members >> message;
    
    for(int i=members.size()-1; i>=0; i--){
        message = functions[members[i]](message);
    }
    cout << message << endl;
}


//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    functions['A'] = rev_A;
    functions['J'] = rev_J;
    functions['C'] = rev_C;
    functions['E'] = rev_E;
    functions['M'] = rev_M;
    functions['P'] = rev_P;
    
    int T; cin >> T;
    while(T--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
int N,Z,W;
ll a[2000];
ll memo[2000][2];
ll solve(int n,bool turn) {
    if(memo[n][turn]!=-1) return memo[n][turn];
    if(turn) { //Xさん
        ll t=0;
        for(int i=1;i<N-n;i++) {
            t = max(t, solve(n + i, turn ^ 1));
        }
        ll Y;
        if(n==0) Y=W;
        else Y=a[n-1];
        t=max(t,abs(a[N-1]-Y));
        return memo[n][turn]=t;
    }else { //Yさん
        ll t=INF;
        for(int i=1;i<N-n;i++) {
            t = min(t, solve(n + i, turn ^ 1));
        }
        t=min(t,abs(a[N-1]-a[n-1]));
        return memo[n][turn]=t;
    }
}
int main() {
    cin>>N>>Z>>W;
    for(int i=0;i<N;i++) cin>>a[i];
    memset(memo,-1,sizeof(memo));
    cout<<solve(0,1)<<endl;
}

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

int compare_int(const void *a,const void *b){
  return *((int*) b) - *((int*) a);
}

int main() {


  int n;
  int d[100];
  bool m[110];

  cin >> n;
  for(int i=0; i<n ; i++)
    cin >> d[i];

  for(int i=0 ; i<110 ; i++)
    m[i] = false;

  int count = 0;
  for(int i=0 ; i<n ; i++){
    if(!m[d[i]]){
      ++count;
      m[d[i]]=true;
    }
  }

  cout << count << endl;
  

  
  return 0;
}



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

				
int main(){
	std::vector<int> a,b;
	a.resize(4);
	b.resize(4);
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		int hit = 0;
		int blow = 0;
		for(int i = 0; i <= 3; ++i){
			if(a.at(i) == b.at(i))
				++hit;
		}
		for(int i = 0; i <= 3; ++i){
			for(int j = 0; j <= 3; ++j){
				if(a.at(i) == b.at(j))
					++blow;
			}
		}
		
		std::cout << hit << " " << blow - hit << std::endl;
	}
	
	return 0;
}
	
	
	

Measured memory_bytes: 1196
import math
a, b, x = map(int, input().split())
s = x / a
if s <= a * b / 2.0:
  c = s / b * 2.0
  d = (b ** 2 + c ** 2) ** 0.5
  h = s / d * 2.0
  theta = math.acos(h / b)
else:
  s = a * b - s
  c = s / a * 2.0
  d = (a ** 2 + c ** 2) ** 0.5
  h = s / d * 2.0
  theta = math.asin(h / a)
print(math.degrees(theta))

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

int main(void) {
	int n;
	
	cin >> n;
	
	if (n == 1) {
		cout << "Hello World" << endl;
	} else if (n == 2) {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	
	return 0;
}


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

int64_t si(string s){
  int64_t res=0;
  int64_t m=s.size();

  for(int i=0;i<s.size();++i){
  int64_t n=s[i]-'0';
  res +=  n*(int64_t)pow(10,m-i-1);
  }

  return res;
}

int main(){  
  int K;
  cin>>K;
  vector<string> t(200100);
  queue<string> que;
  int cnt=0;

  for(int i=0;i<10;++i){
    que.push(to_string(i));    
    if(i>0){
      ++cnt;
      t[i]=to_string(i);
    }
  }
  
  ++cnt;


  while(true){
    string s=que.front();    
    que.pop();
    
    int n=s[0]-'0';
    
    if(n==0){
      que.push("0"+s);
      que.push("1"+s);
      t[cnt]="1"+s;
      ++cnt;
    }
    else if(n<9){
      for(int i=-1;i<=1;++i){
        int j=i+n;
        que.push(to_string(j)+s);
        if(n!=1 || i!=-1){
        t[cnt]=to_string(j)+s;
        ++cnt;
        }
      }
    }
    else if(n==9){
      que.push("8"+s);
      t[cnt]="8"+s;
      ++cnt;
      que.push("9"+s);
      t[cnt]="9"+s;
      ++cnt;
    }
    if(cnt>200000) break;
  }

  vector<int64_t> u(200001,0);
  for(int i=1;i<200000;++i) u[i]=si(t[i]);
  sort(u.begin(),u.end());
  cout<<u[K+1]<<endl;
}


Measured memory_bytes: 22412
import collections
import sys

N=int(input())
S = []
for i in range(N):
  S.append(input())
S.sort()
c = collections.Counter(S)
ans = c.most_common()

if len(ans)==1:
  print(ans[0][0])
  sys.exit(0)
  
print(ans[0][0],sep=" ")
for i in range(N-1):
  if ans[i][1]==ans[i+1][1]:
    print(ans[i+1][0],sep=" ")
  else:
    sys.exit(0)

Measured memory_bytes: 49428
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

struct Unionfind{
  vector<int>d;
  Unionfind(int n):d(n,-1){}
  int root(int x){
    if(d[x]<0){return x;}
    return d[x]=root(d[x]);
  }
  bool unite(int x,int y){
    x=root(x);y=root(y);
    if(x==y){return false;}
    if(d[x]>d[y]){swap(x,y);}
    d[x]+=d[y];
    d[y]=x;
    return true;
  }
  bool same(int x,int y){return root(x)==root(y);}
  int size(int x){return -d[root(x)];}
};
int main(){
  int N,M;
  cin>>N>>M;
  Unionfind uf(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf.unite(a,b);
  }
  int MAX=0;
  for(int i=0;i<N;i++){
    chmax(MAX,uf.size(i));
  }
  cout<<MAX<<endl;
  return 0;                       
}

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

const int MAX_P = 1000011;
bool is_prime[MAX_P];

int main() {
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 0; i * i <= MAX_P; ++i) {
        if (!is_prime[i]) continue;
        for (int j = (i << 1); j < MAX_P; j += i) {
            is_prime[j] = false;
        }
    }
    
    int a, d, n;
    while (cin >> a >> d >> n, a || d || n) {
        int cnt = 0;
        for (int i = 0; i < MAX_P; i++) {
            const int x = a + d * i;
            if (is_prime[x]) {
                cnt++;
                if (cnt == n) {
                    cout << x << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2140
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
using namespace std;

int main()
{
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N, R;
    cin >> N >> R;
    
    if (N >= 10) {
        cout << R;
    } else {
        cout << 100 * (10 - N) + R;
    }

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll MIN_INF = -1000000000000;
ll N, M; 

vector<vector<ll > > G;

bool warshall(){
    //中継点に関して
    for(ll reley = 0; reley < N; reley++){
        for(ll from = 0; from < N; from++){
            for(ll to = 0; to < N; to++){
                if(G[from][to] < G[from][reley] + G[reley][to]){
                    G[from][to] = G[from][reley] + G[reley][to];
                }
            }

            //閉路があって無限にポイントを増やせる時
            /*
            if(G[from][from] > 0){
                cout << "inf" << endl;
                return false;
            }
            */
        }
    }

    return true;
}

int main(){

    //頂点数と辺の数
    cin >> N >> M;
    G.assign(N, vector<ll >());
    
    //初期化
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            if(i == j){
                //自分から自分へ
                G[i].push_back(0);
            }else{
                G[i].push_back(MIN_INF);
            }
        }       
    }
    //cout << G.size() << " " << G[0].size() << endl;
    //辺入力
    for(ll i = 0; i < M; i++){   
        ll u, v, w;
        cin >> u >> v >> w;
        //適宜揃える
        u--;
        v--;
        //有向か無向かでコメントアウト　多重辺も防止
        G[u][v] = w;
    }

    //実行
    if(warshall() == false){
        return 0;
    }
    if( G[0][0] > 0){
        cout << "inf" << endl;
    }else{
        cout << G[0][N-1] << endl;
    }
    

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ft first
#define sd second
#define maxn 1000005
#define mod
#define PI 3.14159265
#define MP make_pair
#define PB push_back
#define heap priority_queue
#define Bjerg ""
using namespace std;

void read()
{

}
void solve()
{

}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Bjerg".inp","r",stdin);
    string s;
    cin >> s;
    if(s[s.length()-1]=='s') cout <<s+"es";
    else cout << s+"s";
    return 0;
}


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

int main()
{
   string s;
   cin>>s;
   if (s[0]=='S')
    cout<<"Cloudy"<<endl;
   else if (s[0]=='R')
    cout<<"Sunny"<<endl;
   else
    cout<<"Rainy"<<endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 2010;

int N;
vector< pair<int, int> > A;
int dp[MAX_N][MAX_N];

// i 番目を見ていて、 左から l 個までは詰まっているときの最大値
int dfs(int i, int l) {
    if(i >= N) { return 0; }
    int r = N - (i - l) - 1;  // 次に右に入れたときの位置

    int& ret = dp[i][l];
    if(~ret) { return ret; }

    // 左に詰める
    int val = A[i].first * abs(A[i].second - l);
    ret = dfs(i + 1, l + 1) + val;
    // 右に詰める
    val = A[i].first * abs(A[i].second - r);
    chmax(ret, dfs(i + 1, l) + val);

    return ret;
}

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

    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        A.push_back(make_pair(a, i));
    }
    SORT(A);
    reverse(A.begin(), A.end());

    MINUS(dp);
    int ans = dfs(0, 0);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 35544
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n")[0],n="",t=["dream","dreamer","erase","eraser"],o=r.length-1;o>=0;o--){n=r[o]+n;for(var u=!1,i=0;i<4;i++)n==t[i]&&(n="",u=!0);if(!u&&n.length>=7)return void console.log("NO")}""==n?console.log("YES"):console.log("NO")}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 9036
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int INF=1000000007;
using ll=long long;

int main(){
	int n,a[M],b[M]={};
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		rep(j,0,3)b[a[i]+j]++;
	}
	int ans=0;
	rep(i,0,M){
		ans=max(ans,b[i-1]);
	}
	cout<<ans<<endl;
}


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

using namespace std;
int main(void){
    string str("2019/04/30");
    string input;
    vector<string> a;

    cin >> input;
    a.push_back(str);
    a.push_back(input);

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    if(a.at(0)==str)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll a,b;
	std::string s;
	std::cin >> a >> s;
	b = (s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
	a *= b; a /= 100;
	std::cout << a << std::endl;
	return 0;
}


Measured memory_bytes: 3624