akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
 
using namespace std;

static int N = 2;
int pivot;


int main(){
    
    int i, j, k, n;
  
    // ?????§?????°?????? M
    double M[N][N + 1];
    while (cin >> M[0][0] >> M[0][1] >> M[0][2] >> M[1][0] >> M[1][1]>> M[1][2]){
    /*
    for (int i = 0; i < N; ++i){
        for(int j= 0; j < N+1; ++j){
            cin >> M[i][j];
        }
    }*/
    
  

 
    double pivot, mul;
 
    // ????§??????????1??§??£????????????????????????????????????(???????¶????)
    for (i = 0; i < N; ++i){
        // ????§??????????????????????????????§??????????????£??????
        pivot = M[i][i];
        for (j = 0; j < N + 1; ++j){
           M[i][j] = (1 / pivot) * M[i][j];
        }
 
    // ???????????????????????????????????¨?????????????????????????????????
    // i??????????????????0???????????????????????¬?????¢?????????
         for (k = i + 1; k < N; ++k){
            mul = M[k][i];
            for (n = i; n < N + 1; ++n){
                M[k][n] = M[k][n] -  mul * M[i][n];
            }
        }
    }
 
    // ???????????????????????£????????°?????£??\???????????¬??????????§£?????¢?????????(????????£??\)
    // ????????¨??????????????????????????§?????¬??????????§£???????????????
    for (i = N - 1; i > 0; --i){
        for (k = i - 1; k >= 0; --k){
            mul = M[k][i];
            for (n = i; n < N + 1; ++n){    
                M[k][n] = M[k][n] - mul * M[i][n];
            }
        }
    }
    cout << fixed << setprecision(3) << M[0][2] << " " << M[1][2] << endl; 
}}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) {
        int b;
        cin >> b;
        sum += b;
    }
    vector<int> c(n-1);
    rep(i,n-1) cin >> c[i];

    rep(i,n-1) {
        if (a[i]+1 == a[i+1]) sum += c[a[i]-1];
    }
    cout << sum << endl;

}

Measured memory_bytes: 384
def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))

    # 面積として見る: 縦*横
    square = sum(A) ** 2

    # 対角線
    diag = sum([a * a for a in A])

    ans = (square - diag) // 2
    print(ans % MOD)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 31412
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<pair<ll, ll> > p;
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        p.push_back(make_pair(temp, i));
    }
    
    sort(ALL(p));

    for(ll i = 0; i < n; i++) {
        cout<<p[i].second + 1;
        if(i!=n-1){
            cout<<" ";
        }
    } 
    cout<<endl;
}


Measured memory_bytes: 2544
W, H, x, y = map(int, input().split())
ans = []

# 麺先
ans.append(str(W * H / 2))

#分割方法が複数
if x * 2 == W and y * 2 == H:
    ans.append('1')
else:
    ans.append('0')

print(' '.join(ans))

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;



int main(void) {
	int n, m, R;
	int r[9];
	int a[20001], b[20001], c[20001];
	int dp[201][201] = {};
	int dist = INF;
	int pos;

	FOR(i, 1, 200) {
		FOR(t, 1, 200) {
			dp[i][t] = INF;
		}
	}

	cin >> n >> m >> R;
	vector<int>v(R);
	FOR(i, 1, R) {
		cin >> r[i];
		v[i-1] = r[i];
	}
	FOR(i, 1, m) {
		cin >> a[i] >> b[i] >> c[i];
		dp[a[i]][b[i]] = c[i];
		dp[b[i]][a[i]] = c[i];
	}
	
	FOR(i, 1, n) {
		dp[i][i] = 0;
	}
	
	FOR(k, 1, n) {
		FOR(i, 1, n) {
			FOR(t, 1, n) {
				dp[i][t] = min(dp[i][t], dp[i][k] + dp[k][t]);
			}
		}
	}

	sort(v.begin(), v.end());
	
	do {
		pos = 0;
		FOR(i, 1, R - 1) {
				pos += dp[v[i-1]][v[i]];
			
		}
		//cout << pos << endl;
		if (pos < dist) {
			dist = pos;
		}
	} while (next_permutation(v.begin(), v.end()));
	
	cout << dist << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct edge{
    int y,c,w;
    edge(){y=c=w=0;}
    edge(int _y,int _c,int _w){y=_y;c=_c;w=_w;}
};
int n,q,a,b,c,d,x,y,u,v,anc;
vector<edge> g[100100];
int dep[100100];
int fa[100100][17];
void dfslca(int x,int p,int cd){
    fa[x][0]=p;
    dep[x]=cd;
    for(edge &e:g[x])if(e.y!=p)dfslca(e.y,x,cd+1);
}
void initlca(){
    dfslca(1,-1,0);
    for(int j=0;j<16;j++){
        for(int i=1;i<=n;i++){
            if(fa[i][j]==-1)fa[i][j+1]=-1;
            else fa[i][j+1]=fa[fa[i][j]][j];
        }
    }
}
int lca(int x,int y){
    if(dep[x]<dep[y])swap(x,y);
    for(int i=16;i>=0;i--)
        if(fa[x][i]!=-1&&dep[fa[x][i]]>=dep[y])x=fa[x][i];
    if(x==y)return x;
    for(int i=16;i>=0;i--)
        if(fa[x][i]!=fa[y][i]){
            x=fa[x][i];
            y=fa[y][i];
        }
    return fa[x][0];
}
struct query{
    int id,x,y;
    query(int _id=-1,int _x=-1,int _y=-1){
		id=_id;x=_x;y=_y;
    }
};
vector<query> qs[100005];
int sum[100005],cnt[100005],ans[300005];
void dfs(int x,int p,int d){
    for(query q:qs[x])
		ans[q.id]=d+cnt[q.x]*q.y-sum[q.x];
    for(edge e:g[x])if(e.y!=p){
        sum[e.c]+=e.w;cnt[e.c]++;
		dfs(e.y,x,d+e.w);
        sum[e.c]-=e.w;cnt[e.c]--;
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>q;
    for(int i=1;i<n;i++){
        cin>>a>>b>>c>>d;
        g[a].push_back(edge(b,c,d));
        g[b].push_back(edge(a,c,d));
    }
    initlca();
    for(int i=1;i<=q;i++){
        int x,y,u,v,anc;
        cin>>x>>y>>u>>v;
        anc=lca(u,v);
        qs[anc].push_back(query(i,x,y));
        qs[u].push_back(query(i+q,x,y));
        qs[v].push_back(query(i+q+q,x,y));
    }
    dfs(1,-1,0);
    for(int i=1;i<=q;i++)
        cout<<-ans[i]-ans[i]+ans[i+q]+ans[i+q+q]<<endl;
    return 0;
}


Measured memory_bytes: 30816
n, k = map(int, input().split())
#print(n,k)

h = list(map(int, input().split()))
#print(h)
h.sort()
#print("sorted = ", h)
h.reverse()
#print(h)
score = 0
for i in range(k, n):
	score = score + h[i]
print(score)

Measured memory_bytes: 26024
while True: 
    h, w = map(int, input().split())
    if h == 0 and w == 0:break
    for j in range(h):
        for i in range(w):
            if j == 0 or j == h-1 or i == 0 or i == w-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()            



Measured memory_bytes: 7004
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<algorithm>
#define ll long long
using namespace std;
 
const int maxn = 210000;
 
int n;
int fa[maxn],s[maxn];
int findfa(const int x){ return fa[x]==x?x:fa[x]=findfa(fa[x]);}
 
struct node{int x,p,i;}a[maxn],b[maxn];
inline bool cmpx(const node x,const node y){return x.x<y.x;}
inline bool cmpi(const node x,const node y){return x.i<y.i;}
 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i].x); a[i].i=i;
		a[0].x^=a[i].x;
	}
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&b[i].x); b[i].i=i;
		b[0].x^=b[i].x;
	}
	sort(a,a+n+1,cmpx); sort(b,b+n+1,cmpx);
	a[0].p=0;
	for(int i=0;i<=n;i++) 
	{
		if(a[i].x!=b[i].x) return puts("-1"),0;
		b[i].p=a[i].p=a[i-1].p+(a[i].x!=a[i-1].x?1:0);
	}
	sort(a,a+n+1,cmpi); sort(b,b+n+1,cmpi);
	
	for(int i=0;i<=n;i++) fa[i]=i;
	for(int i=0;i<=n;i++) if(a[i].p!=b[i].p) s[a[i].p]++;
	for(int i=0;i<=n;i++) if(a[i].p!=b[i].p)
	{
		int x=findfa(a[i].p),y=findfa(b[i].p);
		if(x!=y) fa[y]=x,s[x]+=s[y];
	}
	int re=0;
	if(a[0].p==b[0].p) re++;
	for(int i=0;i<=n;i++) if(findfa(i)==i)
		if(s[i]>1) re+=s[i]+(i==findfa(a[0].p)?0:1);
	if(re) re--;
	printf("%d\n",re);
	
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 K;
  cin >> K;
  string S;
  cin >> S;
  if(S.size() <= K) {
    cout << S << endl;
  }
  else {
    cout << S.substr(0, K) << "..." << endl;
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<int> v(13);
    rep(i, n) {
        int d;
        cin >> d;
        v[d]++;
    }

    bool ok = true;
    rep(i, 13) if(v[i] >= 3) ok = false;
    if(v[0] != 0) ok = false;
    if(v[12] >= 2) ok = false;
    if(!ok){
        cout << "0" << endl;
        return 0;
    }

    vector<int> u(25), x;
    for(int i=1; i<=11; i++){
        if(v[i] == 2){
            u[i] = 1;
            u[24 - i] = 1;
        }
        if(v[i] == 1) x.push_back(i);
    }
    if(v[12] == 1){
        v[12] = 0;
        u[12] = 1;
    }
    u[0] = 1;

    int ans = 0;

    for(int bit = 0; bit < (1<<(int)(x.size())); bit++){
        auto y = u;
        rep(i, x.size()){
            if(bit & (1<<i)) y[24-x[i]] = 1;
            else y[x[i]] = 1;
        }

        int s = 1e9;
        for(int i=1; i<y.size(); i++){
            if(y[i] == 0) continue;
            for(int j=1; j<y.size(); j++){
                if(y[j] == 1 && i != j) s = min(s, abs(i - j));
            }
        }

        for(int i=1; i<=23; i++){
            if(y[i] == 1) s = min(s, min(i, 24-i));
        }

        ans = max(ans, s);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<queue>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<deque>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define MP make_pair
#define mxN (int)2e5 + 2
#define sz(n) (int)(n).size()
#define fasterIO ios::sync_with_stdio(0); cin.tie(0);
LL gcd(LL a, LL b)
{
    if(b == 0LL) return a;
    return gcd(b, a % b);
}
LL bigmod(LL a, LL b, LL mod)
{
    if(b == 0LL) return 1LL;
    LL sq = bigmod(a, b/2LL, mod);
    sq = (sq * sq) % mod;
    if(b&1LL) return (sq * (a%mod)) % mod;
    return sq;
}
int h, w;
char maze[1002][1002];
int dp[1010][110][2];
#define INF 1000000
int visit(int i, int j, char prev)
{
  	if(i == h-1 && j == w-1) return (maze[i][j] == '#' && prev != '#');
    if(i >= h || j >= w) return INF;
    
    if(dp[i][j][(int)(prev == '#')] != -1) return dp[i][j][(int)(prev == '#')];
  
    int ans = visit(i, j+1, maze[i][j]) + (int) (maze[i][j] == '#' && prev != '#');
    ans = min(ans, visit(i + 1, j, maze[i][j]) + (int)(maze[i][j] == '#' && prev != '#'));
    return dp[i][j][(int)(prev == '#')] = ans;
}

int main()
{
    fasterIO
    cin >> h >> w;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < h; i++)
    {
        scanf("%s", maze[i]);
    }
    int ans = visit(0, 0, '.');
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[1000000]={0},dp[1000000],k;
ll fun(ll n)
{
    if(n>0)
    {
        if(dp[n]!=-1)
        return dp[n];
    }
    if(n==1)
    return 0;
    if(n<=0)
    return INT_MAX;
    else
    {
        ll ans=INT_MAX;
       // return min((h[n]-h[n-1]+fun(n-1)),(h[n]-h[n-2]+fun(n-2)));
       /*if(n-1>0)
       f=abs(a[n]-a[n-1])+fun(n-1);
       if(n-2>0)
       s=abs(a[n]-a[n-2])+fun(n-2);
       return dp[n]=min(f,s);*/
       for(ll i=1;i<=k;i++)
       {
           if(n-i>0)
           {
               ans=min(ans,abs(a[n]-a[n-i])+fun(n-i));
           }
       }
       return dp[n]=ans;
    }
}
int main()
{
    ll n;
    cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++)
    cin>>a[i];
    cout<<fun(n)<<endl;
}

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

// dp[i]
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;

  vector<int> v(N);
  for (int i = 0; i < N; ++i) cin >> v[i];
  if (N == 2) {
      cout << max(v[0], v[1]) << endl;
      return 0;
  }

  if (N & 1) {
    vector<long long> dp0(N, 0);
    vector<long long> dp1(N, 0);
    vector<long long> dp2(N, 0);
    for (int i = 0; i < N; ++i) {
      dp0[i] = (i-2>=0 ? dp0[i-2] : 0) + v[i];
      dp1[i] = max((i-3>=0 ? dp0[i-3] : 0), (i-2>=0 ? dp1[i-2] : 0)) + v[i];
      dp2[i] = max({
        (i-4>=0 ? dp0[i-4] : 0),
        (i-3>=0 ? dp1[i-3] : 0),
        (i-2>=0 ? dp2[i-2] : 0)
      }) + v[i];
    }
    cout << max({dp0[N-3], dp1[N-2], dp2[N-1]}) << endl;
  } else {
    vector<long long> dp(N);
    dp[N - 1] = v[N - 1];
    for (int i = N - 3; i >= 0; i -= 2) {
      dp[i] = dp[i + 2] + v[i];
    }
    long long sum = 0;
    long long result = dp[1];
    for (int i = 0; i < N; i += 2) {
        sum += v[i];
        result = max(result, sum + (i+3<N ? dp[i+3] : 0));
    }
    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 8744
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  rep(i,s.size())if(s[i]=='A')break;
  for(j=s.size()-1;j>=0;j--)if(s[j]=='Z')break;
  cout<<j-i+1<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()

{
	string s;
	cin >> s;
	
	map<string, int> mp;
	mp.insert(make_pair("SUN", 7));
	mp.insert(make_pair("MON", 6));
	mp.insert(make_pair("TUE", 5));
	mp.insert(make_pair("WED", 4));
	mp.insert(make_pair("THU", 3));
	mp.insert(make_pair("FRI", 2));
	mp.insert(make_pair("SAT", 1));
	
	cout <<mp[s] <<endl;
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Maximal Value
https://atcoder.jp/contests/abc140/tasks/abc140_c

"""
import sys


def solve(N, B):
    ans = B[0]
    for a, b in zip(B, B[1:]+ [B[-1]]):
        ans += min(a, b)
    return ans


def main(args):
    N = int(input())
    B = [int(b) for b in input().split()]
    ans = solve(N, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main(){
  string A,B;
  cin >> A >> B;
  bool res = false;
  for(int i=0;i<(int)A.size()-(int)B.size()+1;i++){
    bool f=true;
    for(int j=0;j<(int)B.size();j++){
      if( !(A[i+j] == B[j] || B[j] == '_') ){
	f=false;
	break;
      }
    }
    if( f ){ res = true; break; }
  }
  if( res ) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 4020
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m,K;
ll dp[sz][sz],sum[sz][sz];
ll ans;

int main()
{
	file();
	read(n,m,K);
	dp[0][0]=1;rep(i,0,m) sum[0][i]=1;
	rep(i,1,n+m)
	{
		rep(j,0,m)
		{
			dp[i][j]=(sum[i-1][j]-(j-K>=0?sum[i-1][j-K]:0ll)+mod)%mod;
			ll cur=(dp[i][j]-dp[i-1][j]+mod)%mod;
			if (j%(K-1)==m%(K-1)&&1+i*(K-1)-j<=n) (ans+=cur)%=mod; 
		}
		sum[i][0]=dp[i][0];rep(j,1,m) sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 253440
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
// この方法で関数を出せば多分できる
// https://nlab.itmedia.co.jp/nl/articles/1805/04/news002.html

const int MAX = 100 / 0.08;
int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if (10%p == 0) { // pが2 or 5
        ll ans = 0;
        // 2か5で割り切れるというのは、1桁目を見るだけで判断可能なので
        // 1桁目の余りが0だったらOK
        // 通り数は、桁数と同等なのでr+1をnまで足せばOK
        rep(r, n) {
            if ((s[r]-'0') % p == 0) {
                ans += r+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    // 累積和の配列
    // 各桁の余りの合計
    vector<int> d(n+1);
    int ten = 1;
    // 1桁目から計算する
    for (int i = n - 1; i >= 0; --i) {
        int a = (s[i]-'0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p);
    ll ans = 0;
    for (int i = n; i >= 0; --i) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;



int main(int argc, const char * argv[]) {

 
    

       
   int n;
   cin >> n;
   int a,b;
   cin >> a >> b;
   
   for(int i=a; i<=b; i++){
       if(i%n==0){
           cout << "OK" << endl;
           return 0;
       }
           
   }

   cout << "NG";
   

    return 0;
}


Measured memory_bytes: 3592
module mod_segment_tree
  implicit none
  integer, private, parameter :: intkind = 4
  type segment_tree
    integer(intkind) :: default = 0
    integer :: n, p
    integer(intkind), private, allocatable :: body(:)
  contains
    procedure :: init => init
    procedure :: update => update
    procedure :: query => query
  end type
  interface segment_tree
    module procedure :: newst0
  end interface
contains
  integer(intkind) function op(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    res = max(x, y)
  end
  type(segment_tree) function newst0(n, def) result(res)
    integer, intent(in) :: n
    integer(intkind), optional, intent(in) :: def
    integer :: p
    p = 1
    do while (p < n)
      p = lshift(p, 1)
    end do
    if (present(def)) res%default = def
    res%n = n
    res%p = p
    allocate(res%body(2 * p - 1))
    res%body = res%default
  end
  subroutine init(this, n, def)
    class(segment_tree), intent(inout) :: this
    integer, intent(in) :: n
    integer(intkind), optional, intent(in) :: def
    integer :: p
    p = 1
    do while (p < n)
      p = lshift(p, 1)
    end do
    if (present(def)) this%default = def
    this%n = n
    this%p = p
    allocate(this%body(2 * p - 1))
    this%body = this%default
  end
  subroutine update(this, i, v)
    class(segment_tree), intent(inout) :: this
    integer, intent(in) :: i
    integer(intkind), optional, intent(in) :: v
    integer :: x
    x = i + this%p - 1
    this%body(x) = merge(v, this%default, present(v))
    do while (x > 1)
      x = x / 2
      this%body(x) = op(this%body(2 * x), this%body(2 * x + 1))
    end do
  end
  integer(intkind) function query(this, a, b) result(res)
    class(segment_tree), intent(in) :: this
    integer, intent(in) :: a, b
    integer :: l, r
    res = this%default
    l = a + this%p - 1
    r = b + this%p - 1
    do while (l <= r)
      if (mod(l, 2) == 1) then
        res = op(res, this%body(l))
        l = l + 1
      end if
      if (mod(r, 2) == 0) then
        res = op(res, this%body(r))
        r = r - 1
      end if
      l = l / 2
      r = r / 2
    end do
  end
end module mod_segment_tree
program flat_subsequence
  use mod_segment_tree
  implicit none
  integer :: n, k, a(300000) = 0, p, q, m, l, r, i
  type(segment_tree) :: st
  read(*,*) n, k
  read(*,*) (a(i), i = 1, n)
  p = minval(a(1:n))
  if (p == 0) then
    a(1:n) = a(1:n) + 1
    p = p + 1
  end if
  q = maxval(a(1:n))
  st = segment_tree(q)
  do i = 1, n
    l = max(p, a(i) - k)
    r = min(q, a(i) + k)
    m = st%query(l, r) + 1
    call st%update(a(i), m)
  end do
  write(*,'(i0)') st%query(p, q)
end program flat_subsequence

Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long double sum=0.0;
	double const p=380000;
	while(n--){
	double z;
	cin>>z;
	string v;
	cin>>v;
		if(v=="JPY"){
			sum+=z;
		}
		else{
			sum+=(z*p);
		}
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i1,n) for(int i=(int)(i1);i<(int)(n);i++)
#define ll long long
#define vi vector<int>

int main() {
  long double x=0;
  cin>>x;
  long double xrad=x*3.1415926535897932/180;
  vector<long double> a(4);
  vector<long double> now={0,1};
  vector<long double> govec={0,1};
  a.at(0)=cos(xrad);
  a.at(1)=sin(xrad)*-1;
  a.at(2)=sin(xrad);
  a.at(3)=cos(xrad);
  ll count=1;
  while(true){
    vector<long double> newgovec={govec.at(0)*a.at(0)+govec.at(1)*a.at(1),govec.at(0)*a.at(2)+govec.at(1)*a.at(3)};
    now.at(0)+=newgovec.at(0);
    now.at(1)+=newgovec.at(1);
    count++;
    govec=newgovec;
    long double gosa=0.000000000001;
    if(abs(now.at(0))<=gosa&&abs(now.at(1))<=gosa){
      break;
    }
  }
  cout<<count;
}

Measured memory_bytes: 4076
#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 n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;
    rep(i, n) {
        if (i % 2 ==0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;

    return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		if (!n) break;

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

		int64_t max = -100000 * 5001;
		for (int i = 0; i < n; i++) {
			int64_t x = 0;
			for (int j = i; j < n; j++) {
				x += v.at(j);
				if (x > max) {
					max = x;
				}
			}
		}

		cout << max << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(void){
    int A[3];
    int v;
    for(int i=0;i<3;i++)cin>>A[i];
    
    for(int i=1;i<3;i++){
        v=A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
    }
    
    for(int i=0;i<3;i++){
        cout<<A[i];
        if(i<2)cout<<" ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <math.h>
using namespace std;



int main() {
	double a;
	while(cin >> a){
		double t = a/9.8;
		double y = 4.9*t*t;
		int y_c = ceil(y);
		int N = y_c/5 + (y_c%5 > 0);
		cout << N+1 << endl;
	}
	 
	return 0;
}

Measured memory_bytes: 1236
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
      int N = Integer.parseInt(in.readLine());
      int[] s = new int[N];
      int sum = 0;
      for(int i=0;i<N;i++){
        s[i] = Integer.parseInt(in.readLine());
        sum += s[i];
      }
      Arrays.sort(s);
      for(int i=0;i<N;i++){
        if(sum % 10 != 0){
          System.out.println(sum);
          return;
        }
        if(s[i]%10==0){
          continue;
        }
        sum -= s[i];
      }
      System.out.println(0);
    }catch(IOException e){
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

bool check (string S, string T, int k)
{
   corner(T.size() + k > S.size(),"Out of Size");
   bool check = 1;
   for (int i = 0; i < T.size(); i++)
   {
    if((S[k+i] == T[i] || S[k+i] == '?')^(true)) check = 0;
   }

   return check;
}

string fill(string S,string T,int k)
{
  string filled = S;
  for (int i = 0; i < T.size(); i++)
  {
    filled[k+i] = T[i];
  }
  for (int i = 0; i < S.size(); i++)
  {
    if(filled[i] == '?')filled[i] = 'a';
  }
  
  return filled;
}
void solve(void)
{ 
  string str;
  cin>>str;

  if(((str[0]==str[1])&&(str[1]==str[2]))||((str[3]==str[2])&&(str[1]==str[2])))
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
    
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 42880
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  const int N=1e9+5;
   vector<bool> primes(N,false);
   bool isprime(int n)
   {
     for(int i=2;i*i<=n;i++)
     {
       if(n%i==0)
        return false;
     }
     return true;
   }
   //Sieve of Erastothenes
   void sieve()
   {
     primes[2]=false;
     for(int i=2;i*i<=N;i++) //this is actual marking 
     {
        if(!primes[i])
        {
            for(ll j =i*2;j<=N;j+=i)
            {
                primes[j]=true;
            }
        }
     }
   }
   int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

  int32_t main()
  { 
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
    IOS
    int n;
    cin>>n;
    set<string> s;
    string x;
    for(int i=0;i<n;i++)
    {
      
      cin>>x;
      s.insert(x);
    }
    cout<<s.size();
   return 0;
   
}



Measured memory_bytes: 140888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
//#include<>                                                                    
using namespace std;


int main(){
  set<long long> primefacts;
  long long n,i,ans;
  cin>>n;
  ans=n;
  i=2;
  //nの素因数を羅列                                                             
  while(n>1 && i*i<=n){
    if(n%i==0){
      primefacts.insert(i);
      n/=i;
    }
    else i+=1;
  }
  if(n!=1)primefacts.insert(n);



  //オイラー関数                                                                
  set<long long>::iterator itr;
  long long  v1=1,v2=1;
  itr=primefacts.begin();
  do{
    v1*=*itr-1;
    v2*=*itr;
  }while(++itr!=primefacts.end());

  ans=llroundl((long double)ans*v1/v2);

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

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;


int main() {
    int n; cin >> n;
    vector<double_t> v(n);
    double_t ans=0;
    rep(i,n){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    ans+=v.at(0);
    rep2(i,n){
       ans=ans/2+v.at(i)/2; 
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
           int n;
           cin>>n;
           cout<<(n-1)/2<<endl;
}

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

using namespace std;

int a[200005];
unordered_map <int, int> cnt;

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	long long res = 0;
	
	for (int i = 0; i < n; i++) {
		res += cnt[i - a[i]];
		cnt[a[i] + i]++;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 19444
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

    lng luc[100];
    luc[0] = 2;
    luc[1] = 1;
    FOR(i, 2, N) {
        luc[i] = luc[i-1]+luc[i-2];
    }
    cout << luc[N];
}


Measured memory_bytes: 256
query = gets

a = [?{]
indent = [0]

while gets
	s = $_.chomp
	if s =~ /^(\s*)(\w+): (.+)$/
		i = $1.size
		while i < indent[-1]
			a << " " * indent.pop + "},"
		end
		if i > indent[-1]
			indent << i
		end
		a << %(#{$1}"#{$2}" => "#{$3}",)
	else
		s =~ /^(\s*)(\w+):$/ 
		i = $1.size
		while i < indent[-1]
			a << " " * indent.pop + "},"
		end
		if i > indent[-1]
			indent << i
		end
		a << %(#{$1}"#{$2}" => {)
	end
end

loop do
	indent.pop
	break if indent.empty?
	a << " " * indent[-1] + "},"
end

a << ?}

yaml = eval a.join

query.scan(/(?<=\.)\w+/) do |key|
	if yaml.class == String
		puts "no such property"
		exit
	end
	yaml = yaml[key]
	if !yaml
		puts "no such property"
		exit
	end
end

if yaml.class == String
	puts %(string "#{yaml}")
else
	puts 'object'
end

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

using namespace std;

int mod = 1e9 + 7; ///A simpler way to write 1,000,000,007

int main(){

    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int dp[n + 1][k + 1];
    dp[0][0] = 1;
    for (int i = 1; i <= k; i++){
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; i++){
        int sums[k + 1];
        sums[0] = dp[i - 1][0];
        for (int j = 1; j <= k; j++){
            sums[j] = (sums[j - 1] + dp[i - 1][j]) % mod; ///Calculate the prefix sums for i-1
        }
        for (int j = 0; j <= k; j++){
            int tr = sums[j];               ///Sum of dp[i-1][0...j]
            int unreachable = j - a[i] - 1; ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
            if (unreachable >= 0){
                tr = (tr - sums[unreachable] + mod) % mod; ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j] = tr;
        }
    }
    cout << dp[n][k];
    return 0;
}

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

const int MAXN = 190;
int f[2][MAXN][MAXN][MAXN];
int H, W;
char mat[MAXN][MAXN];
int pre[MAXN][MAXN];
inline void getmax(int & x, int y) { x < y ? x = y : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> H >> W;
	for (int i = 1; i <= H; ++i) {
		std::cin >> mat[i] + 1;
		for (int j = 1; j <= W; ++j)
			pre[i][j] = mat[i][j] == '.';
	}
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
			pre[i][j] += pre[i][j - 1];
	int now = 1, lst = 0;
	for (int l = 1; l <= W; ++l)
		for (int r = l; r <= W; ++r) {
			int rcur = 1, ns = 0;
			for (int u = 1; u <= H; ++u) {
				while (rcur <= H) {
					int t = (rcur - u) * (r - l + 1);
					// std::cout << "CH " << l << ' ' << r << ' ' << u << ' ' << rcur << ' ' << ns << std::endl;
					if (ns != 0 && t != ns) break;
					// std::cout << "DD " << rcur << ' ' << l << ' ' << r << ' ' << std::count(mat[rcur] + l, mat[rcur] + r + 1, '.') << std::endl;
					ns += pre[rcur][r] - pre[rcur][l - 1];
					++rcur;
				}
				int t = (rcur - u) * (r - l + 1);
				f[now][l][r][u] = rcur - 1 - (ns != 0 && t != ns);
				// std::cout << "DDD " << l << ' ' << r << ' ' << u << " : " << rcur - 1 - (ns != 0 && t != ns) << " , " << ns << std::endl;
				ns -= pre[u][r] - pre[u][l - 1];
			}
		}
	for (int T = 0; ; ++T) {
		if (f[now][1][W][1] == H) {
			std::cout << T << std::endl;
			break;
		}
		std::cerr << "ROUND" << std::endl;
		std::swap(now, lst);
		memcpy(f[now], f[lst], sizeof(f[now])); // ?
		for (int l = 1; l <= W; ++l)
			for (int u = 1; u <= H; ++u) {
				int cur = l - 1;
				for (int r = l; r <= W; ++r) {
					getmax(f[now][l][r][u], f[lst][l][r][f[lst][l][r][u] + 1]);
					while (!(f[lst][l][cur][u] >= f[lst][cur + 1][r][u] &&
						   f[lst][l][cur + 1][u] <= f[lst][cur + 2][r][u]) && cur + 2 <= r)
						++cur;
					// std::cout << "DBG " << l << ' ' << r << ' ' << u << " " << cur << std::endl;
					getmax(f[now][l][r][u], std::min(f[lst][l][cur - 1][u], f[lst][cur][r][u]));
					getmax(f[now][l][r][u], std::min(f[lst][l][cur][u], f[lst][cur + 1][r][u]));
					getmax(f[now][l][r][u], std::min(f[lst][l][cur + 1][u], f[lst][cur + 2][r][u]));
				}
			}
	//	for (int i = 1; i <= 5; ++i)
	//		for (int j = i; j <= 5; ++j)
	//			std::cout << "DD " << i << ' ' << j << ' ' << f[now][i][j][1] << std::endl;
	}
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	int x;
	cin >> n;
	int tbl[n] = {0};
	
	for(int i = 0; i < n-1; i++) {
		cin >> x;
		tbl[x] += 1;
	}
	
	for(int i = 1; i < n; i++) {
		cout << tbl[i] << endl;
	}
	cout << 0 << endl; 
}


Measured memory_bytes: 4432
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,d;cin>>a;
  vector<vector<ll>>b(2,vector<ll>(a)),c(2,vector<ll>(a));
  rep(i,2)rep(o,a)cin>>b[i][o];
  c[0][0]=b[0][0];
  c[1][0]=c[0][0]+b[1][0];
  c[0][1]=c[0][0]+b[0][1];
    rep(o,a-1){
      c[0][o+1]=c[0][o]+b[0][o+1];
    }
    rep(o,a-1){
      c[1][o+1]=max(c[1][o]+b[1][o+1],c[0][o+1]+b[1][o+1]);
    }
    cout<<c[1][a-1];
}

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

int main() {
	int n, k; cin >> n >> k;
	if ((n - 1) % (k - 1) == 0)
		cout << (n - 1) / (k - 1) << endl;
	else
		cout << (n - 1) / (k - 1) + 1 << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200 + 10;
using ll = long long;
ll a[maxn];

const int L = 63;
ll d[L];
bool add(ll x){
    for(int i = L - 1; i >= 0; i--) if(x & 1ll << i){
        if(d[i] == -1){d[i] = x; return true;}
        x ^= d[i];
    }
    return false;
}

int main(){
//    Fast;
    int t; scanf("%d", &t); while(t--){
        memset(d, -1, sizeof d);
        
        int n; scanf("%d", &n);
        for(int i = 0; i < n; i++) scanf("%lld", a + i);
        char s[maxn]; scanf("%s", s);
        int flag = 0;
        for(int i = n - 1; i >= 0; i--){
            if(add(a[i]) && s[i] == '1'){
                flag = 1;
                break;
            }
        }
        printf("%d\n", flag);
    }
    return 0;
}


Measured memory_bytes: 3772
void main() {
	auto N = ri;
	auto S = rs;
	auto arr = new int[](N);
	arr[0] = S[0] == '.' ? 1 : 0;
	foreach(i; 1..N) arr[i] = S[i] == '.' ? 1 + arr[i-1] : arr[i-1];
	ulong res = S.count('.');
	foreach(i; 0..N) {
		res = min(res, (i+1 - arr[i]) + arr.back - arr[i]);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 3452
import java.util.*;

class Main{
  static String s;
  static int n;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    s=sc.next();
    n=s.length();
    long ans=0;
    for(int i=1<<(n-1);i<2<<(n-1);i++){
      long ku=0;
      for(int j=0;j<n;j++){
        ku*=10;
        ku+=s.charAt(j)-'0';
        if((i>>j&1)==1){
          ans+=ku;
          ku=0;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

ll solve() {
    int l = s.size();
    ll res = 0;
    for (int m = 0; m < (1 << (l-1)); m++) {
        ll sum = 0, num = 0;
        for (int i = 0; i < l; i++) {
            num = 10 * num + s[i] - '0';
            if ((m >> i) & 1) {
                sum += num;
                num = 0;
            }
        }
        res += sum + num;
    }
    
    return res;
}

void input() {
    cin >> s;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string N; cin >>N;
  if (N[0]=='9' or N[1]=='9') cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int A;
  for (int i = 0; i < m; i++) {
    scanf("%d", &A);
    n = n - A;
  }
  if (n >= 0) {printf("%d", n);}
  else {printf("%d", -1);}
  return 0;
}

Measured memory_bytes: 1720
#include <cstdio>
#include <algorithm>
using std::sort;

int main(void)
{
    int i,N,*a;
    scanf("%d",&N);
    a=new int [N];
    for(i=0;i<N;i++)
        scanf("%d",a+i);

    sort(a,a+N);
    if(a[N/2-1]==a[N/2])
        printf("0\n");
    else
        printf("%d\n",a[N/2]-a[N/2-1]);
    delete [] a;
    return 0;
}


Measured memory_bytes: 640