akhauriyash/Code-Regression huggingface dataset:
# ドグラ・マグラ / 夢野久作
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
何故踊る(x::Array{SubString{String},1}) = map(parseInt, x)
母親の心がわかって(x) = split(x)
おそろしいのか() = readline()

function ドグラ_マグラ(arr)
    sx,sy,tx,ty=arr
    ans=""
    if ty>sy
        ans*="U"^(ty-sy)
    else
        ans*="D"^(sy-ty)
    end
    if tx>sx
        ans*="R"^(tx-sx)
    else
        ans*="L"^(sx-tx)
    end
    if ty>sy
        ans*="D"^(ty-sy)
    else
        ans*="U"^(sy-ty)
    end
    if tx>sx
        ans*="L"^(tx-sx+1)
    else
        ans*="R"^(sx-tx+1)
    end
    if ty>sy
        ans*="U"^(ty-sy+1)
    else
        ans*="D"^(sy-ty+1)
    end
    if tx>sx
        ans*="R"^(tx-sx+1)
    else
        ans*="L"^(sx-tx+1)
    end
    if ty>sy
        ans*="D"
    else
        ans*="U"
    end
    if tx>sx
        ans*="R"
    else
        ans*="L"
    end
    if ty>sy
        ans*="D"^(ty-sy+1)
    else
        ans*="U"^(sy-ty+1)
    end
    if tx>sx
        ans*="L"^(tx-sx+1)
    else
        ans*="R"^(sx-tx+1)
    end
    if ty>sy
        ans*="U"
    else
        ans*="D"
    end
    println(ans)
end

function book()
    胎児よ胎児よ = 何故踊る(母親の心がわかって(おそろしいのか()))
    ドグラ_マグラ(胎児よ胎児よ)
end
book()

Measured memory_bytes: 167160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll ans = 0;
    rep(i, n-2) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ans++;
        }
    }

    out(ans);
    re0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

namespace flow {

struct edge {
  int to, cap, rev;
  edge(int t, int c, int r): to(t), cap(c), rev(r) {}
};

class dinic {

private:

  vector<vector<edge>> G;
  vector<int> level;
  vector<int> iter;

  void bfs(int s) {
    fill(level.begin(), level.end(), -1);
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      for(auto& e: G[v]) {
        if(e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          q.push(e.to);
        }
      }
    }
  }

  int dfs(int v, int t, int flow) {
    if(v == t) return flow;
    for(int& i = iter[v]; i < G[v].size(); i++) {
      auto& e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
        if(int d = dfs(e.to, t, min(flow, e.cap))) {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

public:

  dinic(int N) : G(N), level(N), iter(N) {}

  void add_edge(int from, int to, int cap) {
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size()-1);
  }

  int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      int f;
      while((f = dfs(s, t, inf)) > 0) {
        flow += f;
      }
    }
  }

};
}

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

int main() {

  int TC; cin >> TC;
  rep(tc, TC) {

    int W, H; cin >> W >> H;

    vector<vector<int>> G(H);
    rep(i, H) G[i].resize(W);
    int total = 0;
    rep(i, H) rep(j, W) cin >> G[i][j], total += G[i][j];

    flow::dinic dn(H * W + 2);
    const int SRC = H * W, SINK = H * W + 1;
    rep(i, H) rep(j, W) {
      if((i + j) % 2) {
        dn.add_edge(SRC, i * W + j, G[i][j]);
      } else {
        rep(k, 4) {
          int ni = i + dy[k], nj = j + dx[k];
          if(!in_range(ni, nj, H, W)) continue;
          dn.add_edge(ni * W + nj, i * W + j, G[i][j]);
        }
        dn.add_edge(i * W + j, SINK, G[i][j]);
      }
    }

    cout << "Case " << tc + 1 << ": " << total - dn.max_flow(SRC, SINK) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3132
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int n;
    cin >> n;
    int rt = 0;
    vector<int> pars(n, -1);
    vector<vector<int>> graph(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        pars[i] = p;
        graph[p].push_back(i);
    }

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

    vector<int> ord;
    ord.reserve(n);
    {
        ord.push_back(rt);

        for (int i = 0; i < ord.size(); ++i) {
            int u = ord[i];
            for (auto v : graph[u]) {
                ord.push_back(v);
            }
        }
    }
    assert(ord.size() == n);
    reverse(ord.begin(), ord.end());

    const long long INF = 1LL << 32;
    vector<long long> dp(n, INF);
    int mx = *max_element(X.begin(), X.end());
    vector<long long> mins(mx + 1, INF);
    vector<long long> nmins(mx + 1, INF);
    for (auto u : ord) {
        if (graph[u].empty()) {
            dp[u] = 0;
            continue;
        }
        fill(mins.begin(), mins.end(), INF);
        mins[0] = 0;
        for (auto v : graph[u]) {
            fill(nmins.begin(), nmins.end(), INF);
            for (int i = mx; i >= 0; --i) {
                for (long long x : {X[v], dp[v]}) {
                    long long y = X[v] + dp[v] - x;
                    long long ni = i + x;
                    if (ni <= mx) {
                        nmins[ni] = min(nmins[ni], mins[i] + y);
                    }
                }
            }
            swap(nmins, mins);
        }

        for (int i = 0; i <= X[u]; ++i) {
            dp[u] = min(dp[u], mins[i]);
        }
        // cout << u << " " << dp[u] << endl;
    }

    if (dp[0] >= 0 && dp[0] < INF) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 3764
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, C: int):
    use = math.floor(B/A)
    print(min(C,use))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N;
vector<pair<int, int > > tree[101010];
int color[101010];
void dfs(int u, int p, int c){
    color[u] = c;
    for(int i = 0; i < tree[u].size(); i++){
        int v = tree[u][i].first;
        int w = tree[u][i].second;
        if(v == p)continue;
        if(w % 2 == 0)dfs(v, u, c);
        else dfs(v, u, 1 - c);
    }
}
int main(){
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        tree[u].push_back(make_pair(v, w));
        tree[v].push_back(make_pair(u, w));
    }
    dfs(1, -1, 0);
    for(int i = 1; i <= N; i++)cout << color[i] << '\n';

}


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

int isprime(int x){
	int i;
	if(x==2|| x==3)
		return 1;
	if(x < 2||x%2==0)
		return 0;
	i = 3;
	while (i <= sqrt(x)){
		if(x%i == 0)
			return 0;
		i = i + 2;
	}
	return 1;
}

int main(){
  int Array[10000];
  int n;
  int i;
  int s = 0;
  cin >> n;
  for(i=0;i<n;i++){
  cin >> Array[i];
  s += isprime(Array[i]);
  }
  cout << s << endl;
  return 0;
 }


Measured memory_bytes: 3140
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0099
"""
import sys
import bisect



def main(args):
    #data = [(1, 4), (2, 5), (1, 3), (3, 6), (2, 7)]
    #data = [(1, 4), (2, 5), (2, -3),(3, 4), (1, -1)]
    fisher, event = [int(x) for x in input().split(' ')]
    fishes = [0 for _ in range(fisher + 1)]

    winner = 9999999999
    max_fish = -1
    for _ in range(event):
        id, fish = [int(x) for x in input().strip().split(' ')]
        fishes[id] += fish
        if fish > 0:
            if fishes[id] > max_fish:
                max_fish = fishes[id]
                winner = id
            elif fishes[id] == max_fish:
                winner = min(winner, id)
            else:
                pass
        else:
            if winner == id:
                max_fish = max(fishes)
                winner = fishes.index(max_fish)
        print('{} {}'.format(winner, max_fish))


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

Measured memory_bytes: 15768
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
string S, T;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for (int i=0; i<n; i++) S+='0'+m;
	for (int i=0; i<m; i++) T+='0'+n;
	
	cout<<min(S, T)<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B, C, D;
  cin >> A >> B >> C >> D;
  
  if ( (A + B) > (C + D))
    cout << "Left" << endl;
  if ( (A + B) < (C + D))
    cout << "Right" << endl;
  if ( (A + B) == (C + D))
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+A[i]
    S[i+1]%=K
X=[(S[i]-i)%K for i in range(N+1)]
D=dict()
for i in range(N+1):
    if X[i] in D:
        D[X[i]].append(i)
    else:
        D[X[i]]=[i]
ans=0
for k in D:
    for i in D[k]:
        L=bisect.bisect_left(D[k],i-K+1)
        R=bisect.bisect_right(D[k],i+K-1)
        ans+=R-L-1
print(ans//2)


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

int main() {
  int N,X,T;
  cin >> N >> X >> T;
  if (N%X == 0){
    cout << T *(N/X) << endl;
  }
  else {
    cout << T * (1 + N/X) << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3+3;
double dp[N][N], p[N];
int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		dp[i][0] = 1;
		cin >> p[i];
	}
	dp[n][0] = dp[n+1][0] = 1;
	for(int i = n; i > 0; --i)
		for(int heds = 1; heds <= n; ++heds){
			dp[i][heds] = p[i-1] * dp[i+1][heds-1];
			dp[i][heds] += (1 - p[i-1]) * dp[i+1][heds];
		}
	cout << setprecision(11) << dp[1][(n+2)/2];
	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int K;
  cin >> K;
  if (K % 2 == 0) {
    cout << K * K / 4 << endl;
  } else {
    cout << ((K - 1) / 2) * (K / 2 + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    rp(i,n) cin >> a[i];
    ll ans1 = 0;
    ll ans2 = 0;
    ll cur = 0;
    ll delta;
    rp(i,n){
        cur +=a[i];
        if(i%2 ==1 && cur <= 0){
            delta = abs(cur) + 1;
            cur = 1;
            ans1 +=delta;
        }
        if(i%2 == 0 && cur >= 0){
            delta = (-1)*(cur+1);
            cur = -1;
            ans1 += abs(delta);
        }
    }
    cur = 0;
    rp(i,n){
        cur +=a[i];
        if(i%2 ==0 && cur <= 0){
            delta = abs(cur) + 1;
            cur = 1;
            ans2 +=delta;
        }
        if(i%2 == 1 && cur >= 0){
            delta = (-1)*(cur+1);
            cur = -1;
            ans2 += abs(delta);
        }
    }
    cout << min(ans1, ans2)<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main(){
	float weight, height;
	int id;
	bool hoge = false;
	while(scanf("%d,%f,%f", &id, &weight, &height) != EOF){
		if(25 <= weight / pow(height, 2)){
			hoge = true;
			cout << id << endl;
		}
	}
	if(!hoge) cout << "該当なし" << endl;
}

Measured memory_bytes: 1228
s = input()
s += 'B'

ans = 0
cnt = 0
for c in s:
    if (c == 'A' or c == 'C'
            or c == 'G' or c == 'T'):
        cnt += 1
    else:
        if (ans < cnt):
            ans = cnt
        cnt = 0

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1e9+7
#define oo 1000006
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n,k;
int a[oo];
int b[oo];
int c[oo];
int f[oo][4];
void ReadInPut()
{
    n=read();
    F(i,1,n){a[i]=read();b[i]=read();c[i]=read();}
}
void Solve()
{
    f[n][1]=a[n];
    f[n][2]=b[n];
    f[n][3]=c[n];
    FD(i,n-1,1)
    {
        f[i][1]=a[i]+max(f[i+1][2],f[i+1][3]);
        f[i][2]=b[i]+max(f[i+1][3],f[i+1][1]);
        f[i][3]=c[i]+max(f[i+1][2],f[i+1][1]);
    }
    cout<<max(f[1][1],max(f[1][2],f[1][3]));
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    ll N;
    cin >> N;
    vec<ll> L(90,0);
    L[0] =2,L[1] =1;
    for(int i=2;i<=N;++i){
        L[i] = L[i-1]+L[i-2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n=3,i;
    ll arr[n+5];
    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    cout<<arr[n-1]-arr[0]<<endl;
    return 0;
}


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

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

using namespace std;

typedef long long ll;
const ll LLINF = LLONG_MAX;

struct Data {
  int x,y;
  ll cost;
  bool operator < ( const Data &data ) const { return cost > data.cost; }
};

int H,W,N,sx,sy,gx,gy;
ll cost[1010][1010],mini[1010][1010];
int dx[] = {0,1,0,-1}; // D R U L
int dy[] = {1,0,-1,0};
char opr[1100];

void update(int x,int y,int T){
  x = 2 * x + 1, y = 2 * y + 1;
  int limit = strlen(opr);
  rep(_,T){
    rep(i,limit){
      int dir = ((opr[i]=='D')?0:((opr[i]=='R')?1:((opr[i]=='U')?2:3)));
      int nx = x + dx[dir] * 2, ny = y + dy[dir] * 2;
      if( 0 <= nx && nx < 2 * W + 1 && 0 <= ny && ny < 2 * H + 1 ) {
	++cost[ny-dy[dir]][nx-dx[dir]];
	x = nx, y = ny;
      }
    }
  }
}

typedef pair<int,int> ii;
int main(){
  scanf("%d %d %d",&W,&H,&N);
  scanf("%d %d %d %d",&sx,&sy,&gx,&gy);
  rep(i,N){
    int x,y,T;
    scanf("%d %d",&x,&y);
    scanf("%d %s",&T,&opr[0]);
    update(x,y,T);
  }

  rep(i,2*H+1) rep(j,2*W+1) mini[i][j] = LLINF;
  mini[2*sy][2*sx] = 0;
  priority_queue<Data> Q;
  Q.push((Data){2*sx,2*sy,0});
  while( !Q.empty() ){
    Data data = Q.top(); Q.pop();
    int x = data.x, y = data.y;
    if( x == 2*gx && y == 2*gy ) { printf("%lld\n",data.cost); return 0; }
    rep(i,4){
      int nx = x + dx[i] * 2, ny = y + dy[i] * 2;
      if( 0 <= nx && nx < 2 * W + 1 && 0 <= ny && ny < 2 * H + 1 ) {
	if( mini[ny][nx] > data.cost + cost[ny-dy[i]][nx-dx[i]] ) {
	  mini[ny][nx] = data.cost + cost[ny-dy[i]][nx-dx[i]];
	  Q.push((Data){nx,ny,mini[ny][nx]});
	}
      }
    }
  }
  return 0;
}

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

int main() {
  
  string S;
  cin >> S;
  
  int cnt=0;
  
  for(int i=0; i<3; i++){
    if(S.at(i) == '1'){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <algorithm>
#define M 4010
#define P 998244353
#define int long long

using namespace std;

typedef long long ll;

char ch[M];

int n, S[M], F[M][M];

signed main() {
    scanf("%s", ch + 1), n = strlen(ch + 1);
    for(int i = 1; i <= n; i++) S[i] = S[i - 1] + ch[i] - '0';
    F[0][0] = 1;
    for(int i = 0; i < n * 2; i++)
        for(int j = max((i < n ? i - (2 * i - S[i]) : i - (2 * n - S[n])), 0ll); j <= (i < n ? S[i] : S[n]); j++)
            F[i + 1][j] = (F[i + 1][j] + F[i][j]) % P,
            F[i + 1][j + 1] = (F[i + 1][j + 1] + F[i][j]) % P;
    ll ans = 0;
    printf("%lld\n", (F[2 * n][S[n]] % P + P) % P);
    return 0;
}

Measured memory_bytes: 123392
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());

  int ans = 0;
  int pos = 0;
  while (pos < n) {
    int cnt = 0;
    int now = a[pos];
    while (pos < n && now == a[pos]) {
      cnt++;
      pos++;
    }
    if (cnt%2) ans++;
  }

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

Measured memory_bytes: 640
//#include<bits/stdc++.h> 
#include<stdio.h>
using namespace std;
int main() {
	int n,k,t=1;
	scanf("%d %d",&n,&k);
	while(n--){
		if(t<k)
			t*=2;
		else
			t+=k;
	} 
	printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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 T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n), sum(n+1), ss(n+1);
    rep(i, n) {
        cin >> a[i];
        ss[i+1] = ss[i] + a[i];
        sum[i+1] = max(sum[i], sum[i] + a[i]);
    }

    ll ans = 0;
    rep(i, n-k+1) {
        ll l = sum[i], r = sum[n] - sum[i+k], mid = max(ll(0), ss[i+k]-ss[i]);
        chmax(ans, l+r+mid);
    }
    cout << ans << endl;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int n = in();
	int sum = 0;
	vi t;
	
	rep(i, n) {
		int po = in();
		t.push_back(po);
		sum += po;
	}

	int m = in();
	rep(i, m) {
		int p = in() - 1, x = in();
		cout << sum - t[p] + x << endl;
	}
}



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

// [0, MaxNumPlusOne - 1 ] の範囲の整数が素数であるかどうかを表す配列を返す関数
// 配列の要素が 1であれば素数
// 配列の要素が-1であれば素数でない
vector<int> Eratosthenes(int MaxNumPlusOne) {
	vector<int> isPrimeArray(MaxNumPlusOne, 1);
	int MaxNum = MaxNumPlusOne - 1;
	isPrimeArray[0] = -1;
	isPrimeArray[1] = -1;
	for (int i = 2; i <= sqrt(MaxNum); i++) {
		if (isPrimeArray[i] == 1) {
			for (int j = 2; j <= MaxNum; j++) {
				if (i * j > MaxNum) break;
				isPrimeArray[i * j] = -1;
			}
		}
	}
	return isPrimeArray;
}

int main() {
    
    int q; cin >> q;
	const int p = 100001;
	vector<int> isPrimeNumber = Eratosthenes(p); // [0, 100000] の範囲を調べる場合
	vector<int> accum(p, 0);
	for (int i = 1; i <= p; i++) {
		accum[i] += accum[i - 1];
		if (isPrimeNumber[i] == 1 && isPrimeNumber[(i + 1) / 2] == 1) {
			accum[i]++;
		}
	}
	for (ll i = 0; i < q; i++) {
        int l, r; cin >> l >> r;
		cout << accum[r] - accum[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>

int main()
{
  int H,W,j,i;
  
  while(1){
    
    scanf("%d", &H);
    
    scanf("%d", &W);
    
    
    
    if(H == 0 && W == 0)
      break;
    
    
    
    for(i = 1; i <= H; i++)
      {
	for(j = 1; j <= W; j++)
	  { 
	    if(i!=1 && i!=H){
	      if(j!=1 && j!=W){
		printf(".");
	      }else{
		printf("#");
	      }
	    }else{
	      printf("#");
	    }
	    /*
	      if(i>1 && i<H && j>1 && j<W)printf(".");
	      else printf("#");
	     */
	  }
	printf("\n");
      }
    printf("\n");
  }      


  return 0;
}

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

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (A < B) swap(A, B);
  if (A < C) swap(A, C);
  cout << B * C << endl;
}

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

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int[] dp1 = new int[1000001];
        int[] dp2 = new int[1000001];
        for (int i = 1; i <= 1000000; i++) {
            dp1[i] = dp2[i] = i;
        }

        for (int i = 2; i < 200; i++) {
            int t = i * (i + 1) * (i + 2) / 6;

            if (t > 1000000) {
                break;
            }

            for (int j = t; j <= 1000000; j++) {
                dp1[j] = Math.min(dp1[j], dp1[j - t] + 1);
                if (t % 2 == 1) {
                    dp2[j] = Math.min(dp2[j], dp2[j - t] + 1);
                }
            }
        }

        while (true) {
            int n = ni();

            if (n == 0) return;

            out.println(dp1[n] + " " + dp2[n]);
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

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

    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vector<ll> sma(n+1, 0), smb(m, 0);
    rep1(i, n+1) sma[i] = a[i-1] + sma[i-1];
    smb[0] = b[0];
    rep1(i, m) smb[i] = b[i] + smb[i-1];

    ll res = 0;
    rep(i, n+1){
        ll cnt_a = i;
        ll remain = k-sma[i];
        if(remain < 0) break;

        ll cnt_b = upper_bound(smb.begin(), smb.end(), remain) - smb.begin();
        
        res = max(res, cnt_a+cnt_b);
    }

    cout << res << endl;

    return 0;
}

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

ll N;
string S;

int main() {
    std::cin >> N;
    std::cin >> S;
    string M=S;
    char last;
    
    ll where = 1;
    ll count=1;
    while(count>0){
        count=0;
        for (int i = 0; i < N; i++) {
            if(S[i]==' '){
                where++;
                continue;
            }
            if(i>0){
                if(last =='(' && S[i]==')'){
                    S[i-where]=S[i]=' ';
                    count++;
                    where=1;
                }
            }
            last = S[i];
            where=1;
        }
    }
    for (int i = 0; i < N; i++) {
        if(S[i]==')'){
            M = '('+M;
        }else if(S[i]=='('){
            M = M+')';
        }
    }
    std::cout << M << std::endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  ll a,b,c,d,e,f; cin>>a>>b>>c;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  ans1(a+b>=c);

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;

int main(){
  cin >> n;
  cout << (n+1)*n/2 <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ALL(x) begin(x),end(x)
#define ll long long
#define ld long double
     
int main(){
  //入力
  vector<vector<ll>> a(3,vector<ll>(3));
  rep(i,3)rep(j,3) cin >> a.at(i).at(j);
  ll n; cin >> n;
  vector<ll> b(n); rep(i,n) cin >> b[i];
  sort(ALL(b));
  
  //ビンゴ判定
  bool bingo = false;
  //横方向
  rep(i,3){
    if(find(ALL(b),a.at(i).at(0)) != b.end()
       &&find(ALL(b),a.at(i).at(1)) != b.end()
       &&find(ALL(b),a.at(i).at(2)) != b.end()) bingo = true;
  }
  //縦方向
  rep(i,3){
    if(find(ALL(b),a.at(0).at(i)) != b.end()
       &&find(ALL(b),a.at(1).at(i)) != b.end()
       &&find(ALL(b),a.at(2).at(i)) != b.end()) bingo = true;
  }
  //左上to右下
  if(find(ALL(b),a.at(0).at(0)) != b.end()
       &&find(ALL(b),a.at(1).at(1)) != b.end()
       &&find(ALL(b),a.at(2).at(2)) != b.end()) bingo = true;
  
  //左下to右上
  if(find(ALL(b),a.at(2).at(0)) != b.end()
       &&find(ALL(b),a.at(1).at(1)) != b.end()
       &&find(ALL(b),a.at(0).at(2)) != b.end()) bingo = true;
  
  //出力
  if(bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/

using namespace std;

int n;

double x,sum;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> x;
        sum+=(1.0/x);
    }
    sum=1.0/sum;
    cout << fixed << setprecision(5) << sum << endl;
    return 0;
}


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





int main() {
			int n; cin >> n;
			string s;
			cin >> s;
			vector<char> vec;
			vec.push_back(s[0]);
			for(int i = 1; i < n; i++) {
				if(s[i] != vec.back()) vec.push_back(s[i]);
			}
			cout << vec.size() << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.math.*;
 
public class Main {
        static Scanner sc = new Scanner(System.in);
        public static void main(String args[]) {
                for(int i = 0, N = sc.nextInt(); i < N; i++) {
                        String s = new BigInteger(sc.next()).add(new BigInteger(sc.next())).toString();
                        System.out.println(s.length() > 80 ? "overflow" : s);
                }
        }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(w>=v){
        cout << "NO" << endl;
        return 0;
    }
    if (abs(b - a) <= t * (v-w))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i=0;
  cin >> N;

  string x,text;
 
  while(i < N){
    cin >> x;
    if(x == "Y"){
      text = "Four";
      break;
    }

    text = "Three";
    i++;
  }


cout << text << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){int x;scanf("%d",&x);return x;} 
int main(){
	int n=read();
	long long sum=0,xmin=1E9+7,e=1;
	while(n--){
		long long a=read(),b=read();
		if(a!=b)e=0;
		sum+=a;
		if(a>b)xmin=min(xmin,b);
	}
	if(e)printf("0\n");
	else printf("%lld\n",sum-xmin);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int z;
	int min;
	int max;
	long int sum;
	min = 1000000;
	max = -1000000;

	sum = 0;

	scanf("%d",&a);

	for(b=0; b<a; b++)
	{
		scanf("%d",&z);
		
		if(min > z)
		{
			min = z;
		}
		if(max < z)
		{
			max =z;
		}
		sum = sum + z;
	}
	
	printf("%d %d %ld\n",min,max,sum);

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    vi a(n); for(auto& e : a) cin >> e;
    sort(_all(a));
    a.emplace_back(-1);

    vi b;
    int pre = a[0];
    int cnt = 1;
    rep(i, 1, n+1){
        if(a[i] == pre){
            cnt++;
        }
        else {
            b.emplace_back(cnt);
            cnt = 1;
        }
        pre = a[i];
    }

    sort(_all(b));
    int m = b.size();
    int res = 0;
    rep(i, m - K){
        res += b[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2800
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    boolean sort = true;
    int v;
    int count = 0;
    while(sort) {
      sort = false;
      for(int i = n - 1; i > 0; i--) {
        if(a[i - 1] > a[i]) {
          v = a[i - 1];
          a[i - 1] = a[i];
          a[i] = v;
          sort = true;
          count++;
        }
      }
    }
    for(int i = 0; i < n; i++) {
      if(i == n - 1) {
        System.out.println(a[i]);
      } else {
        System.out.print(a[i] + " ");
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 26296
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var K = Number.parseInt(inputStr[1]);
  inputStr = input[1].split(" ");
  var H_arr = inputStr.map( inputStr => parseInt(inputStr));
  
  //解法としてDPを用いる
  var i = 0;	//今たっている場所
  var ans = []; //回答格納用配列
  //ansの配列要素Nの確定と初期化
  for(var i=0 ; i<N ; i++){
    ans.push(0);
  }
  
  //階段の0段目のコストをメモ。値は0
  ans[0] = 0;
  //階段の1段目に進んだ時のコストをメモ
  ans[1] = Math.abs(H_arr[1]-H_arr[0]); 
  //階段の3段目以降のコストをforループで処理
  for( var i=2 ; i<N ; i++){
    var last = Number.MAX_VALUE;
    for(var j=1 ; j<=K ; j++){
      if( i >= j){
        //自分のところ(i段目)にj段前から来た場合の値を格納
        var tmp = ans[i-j]+Math.abs(H_arr[i]-H_arr[i-j]);
        last = Math.min(tmp,last);
      }
    }
    //より小さい値(最小コスト)を回答配列の自分の段に格納
    ans[i] = last;
  }
  //結果表示
  console.log(ans[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27860
/**
 * Boris Sokolov
 * Software Engineer at Ring Ukraine
 * Kiev, Ukraine | Los Angeles, CA
 */

#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
// using black magic;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = static_cast<int>(1e9);
const int MOD = static_cast<int>(1e9) + 7;

int a[(int)1e5 + 9];
int b[(int)1e5 + 9];
int c[(int)1e5 + 9];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &c[i]);
    }

    sort(a, a + n);
    sort(b, b+ n);
    sort(c, c + n);

    ll res = 0;
    int i = -1;
    int j = 0;
    int k = 0;
    while (j < n) {
        while (i + 1 < n && a[i + 1] < b[j]) {
            ++i;
        }
        while (k + 1 < n && c[k] <= b[j]) {
            ++k;
        }

        if (i != -1 && k != -1 && c[k] > b[j]) {
            res += ((ll)i + 1) * (n - k);
        }

        ++j;
    }
    printf("%lld\n", res);

    return 0;
}


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

int main()
{
	int n,j,i,s;
	cin>>n;
	int * a=new int[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	
	for(i=0;(n/2)>i;i++)
	{
		s=a[i];
		a[i]=a[n-1-i];
		a[n-1-i]=s;
		}
	for(i=0;i<n;i++){
		cout<<a[i];
		if(i!=n-1)
			cout<<" ";
		}
		cout<<endl;
	
	delete[] a;
	
	return 0;
}

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

int main(){
    double a,b,h,m,PI=acos(-1);
    cin >> a >> b >> h >> m;
    double tansin=h*30+m/2,tyousin=m*6,kakudo=min(abs(tansin-tyousin),360-abs(tansin-tyousin));
    //cout << kakudo << endl;
    printf("%.20f\n",sqrt(a*a+b*b-2*a*b*cos(kakudo*PI/180)));
    return 0;
}

Measured memory_bytes: 4228
//N+10個のボールのうち15個を黒く塗る。前半5個のボールまでは、
//手前の黒いボール(or先頭)までにあるボールが偶数個になってほしい。何通りの入れ方があるか？
#include <iostream>
#include <vector>
#define int long long
using namespace std;
typedef vector<int> Array;
typedef vector<Array> Mat;

Mat identify(int n) {
	Mat mat(n, Array(n, 0));
	for (int i = 0; i < n; i++) mat[i][i] = 1;
	return mat;
}

Mat multiply(Mat a, Mat b, int mod) {
	Mat mat(a.size(), Array(b[0].size(), 0));
	for (int i = 0; i < a.size(); i++) {
		for (int k = 0; k < b.size(); k++) {
			for (int j = 0; j < b[0].size(); j++) {
				mat[i][j] += a[i][k] * b[k][j];
				mat[i][j] %= mod;
			}
		}
	}
	return mat;
}

Mat powmat(Mat a, int n, int mod) {
	if (n == 0) return identify(a.size());
	if (n % 2 == 0) return powmat(multiply(a, a, mod), n / 2, mod);
	return multiply(a, powmat(a, n - 1, mod), mod);
}

//a * b(縦ベクトル). a[0].size() == b.size()
Array multiply(Mat a, Array b, int mod) {
	Array ret(a.size(), 0);
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			ret[i] += a[i][j] * b[j];
		}
	}
	return ret;
}

int solve(int n) {
	int mod = 1000000007;
	int i, j;
	
	//dp[i][仕切り数j][個数偶奇k]. vector(i)[2 * j + k] = dp[i][j][k]と表現すると、
	//初期値：vector(0)[0] = 1, vector(0)[0以外] = 0.
	//求めたい：vector(n + 10)[30] + vector(n + 10)[31].
	//
	//dp[i][j][k] -> dp[i+1][j'][k']と遷移するとき、2j' + k'行2j + k列目に遷移数(1)を書いた行列mat
	//を作ると、vector(n) = mat^n * vector(0). mat部分は繰り返し累乗で32^3 * logNくらい.
	Array vec0(32, 0);
	vec0[0] = 1;
	
	Mat mat(32, Array(32, 0));
	
	//遷移行列の生成. [仕切り数i][個数偶奇j].
	for (i = 0; i <= 15; i++) {
		for (j = 0; j < 2; j++) {
			//仕切る
			if (i < 15 && (i >= 5 || j == 0)) {
				mat[2 * (i + 1) + 0][2 * i + j] += 1;
			}
			//仕切らない
			mat[2 * i + (!j)][2 * i + j] += 1;
		}
	}
	
	//行列計算
	Mat resMat = powmat(mat, n + 10, mod);
	Array resVec = multiply(resMat, vec0, mod);
	
	return (resVec[30] + resVec[31]) % mod;
}

signed main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		cout << solve(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 4588
<?php
for(;fscanf(STDIN,'%d %d', $a, $b);) {
    echo gcd($a,$b), ' ', lcm($a,$b), PHP_EOL;
}
function lcm($a, $b) {
    $g = gcd($a, $b);
    return $g * ($a/$g) * ($b/$g);
}
function gcd($a, $b) {
    while(true) {
        $mod = $a % $b;
        if ($mod === 0) {
            $g = $b;
            break;
        }
        $a = $b;
        $b = $mod;
    }
    return $g;
}

Measured memory_bytes: 15224
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 1e5 + 10;
int n, a[maxn], dp[maxn];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        dp[i] = 0;
    }
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i] <= a[i-1]) {
            dp[i] = dp[i-1] + 1;
        }
        if (dp[i] > ans) ans = dp[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int dp[N];

signed main() {
	IOS;
	int ans = 0;
	string s;	cin >> s;
	for(int i = 0; i < (int)s.length(); i++){
		int temp[2019] = {0};
		int c = s[i]-'0';
		for(int j = 0; j < 2019; j++){
			int n = (j*10 + c)%2019;
			temp[n] = dp[j];
		}
		temp[c]++;
		for(int j = 0; j < 2019; j++)
			dp[j] = temp[j];
		ans += dp[0];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

ll solve() {
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    for ( int h = 0; h < H; h++ ) {
        cin >> S[h];
    }

    vector<int> dh = {0, 1, 0, -1}, dw = {1, 0, -1, 0};

    auto check = [&](int sh, int sw) {
        vector<vector<int>> d(H, vector<int>(W,-1));
        queue<pii> q;
        q.push(pii(sh,sw));
        d[sh][sw] = 0;
        while ( !q.empty() ) {
            ll h0 = q.front().first;
            ll w0 = q.front().second;
            q.pop();
            for ( int i = 0; i < 4; i++ ) {
                ll h = h0 + dh[i];
                ll w = w0 + dw[i];
                if ( h < 0 || h >= H ) continue;
                if ( w < 0 || w >= W ) continue;
                if ( S[h][w] == '#' ) continue;
                if ( d[h][w] >= 0 ) continue;
                d[h][w] = d[h0][w0] + 1;
                q.push(pii(h,w));
            }
        }
        int m = 0;
        for ( int h = 0; h < H; h++ ) {
            for ( int w = 0; w < W; w++ ) {
                m = max(m, d[h][w]);
            }
        }
        return m;
    };

    int m = 0;
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            if ( S[h][w] == '#' ) continue;
            int x = check(h,w);
            m = max(m, x);
        }
    }
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll x;
	cin>>x;
	ll g=gcd(x,360);
	ll result=(360*(x/g))/x;
	cout<<result<<endl;
	
}

Measured memory_bytes: 3604