akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
// ミント
const int mod = 1e9+7 ;
  //998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
}  ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
 
mint dp[200005] ;
mint co[200005] ;
int main(){
  ll n ; cin>> n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  dp[0]=1 ;
  rep(i,200005) co[i]=0 ;
  rep(i,n){
    mint plus= 0;
    if(i>0 && A[i]!=A[i-1] ) plus= co[A[i]] ;
    dp[i+1]=dp[i]+plus ;
    if(i==0 || A[i]!= A[i-1]) co[A[i]]= dp[i+1] ;
  }
  cout<<dp[n]<<endl ;
    return 0;
  }
   



Measured memory_bytes: 8024
n,k = map(int,input().split())
lis = list(map(int,input().split()))
cou = lis[0]
ans = 0
if cou > k:
    ans += cou-k
    cou = k
for i in range(1,n):
    if cou + lis[i] > k:
        num = cou+lis[i]-k
        cou = lis[i]-num
        ans += num
    else:
        cou = lis[i]
print(ans)

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

int main(){
  int n, K; scanf("%d %d", &n, &K);
  vector<int> a(n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);

  int ans = 0;
  for(int left = 0; left <= K; left++){
    for(int right = 0; right <= K; right++){
      if(left + right > min(n, K)) continue;
      vector<int> data;
      int ans1 = 0;
      for(int i = 0; i < left; i++) data.push_back(a[i]), ans1 += a[i];
      for(int i = n - 1; i > n - 1 - right; i--) data.push_back(a[i]), ans1 += a[i];
      sort(data.begin(), data.end());
      for(int i = 0; i < min(K - left - right, left + right); i++) if(data[i] < 0) ans1 -= data[i];
      ans = max(ans, ans1);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 3784
#include <stdio.h>

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

  for(i=N-2; i>=0; i--){
    if(H[i] == H[i+1]+1)
      H[i]--;
    else if(H[i] > H[i+1]+1)
      break;
    }
  if(i == -1)
    printf("Yes\n");
  else
    printf("No\n");
    
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int arr[100005];
int main()
{
	int n,mx=0;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		mx=max(mx,arr[i]);
	}
	int b=-1;
	for (int i=0;i<n;i++)
	{
		if (arr[i]!=mx && min(arr[i],mx-arr[i])>min(b,mx-b))
		b=arr[i];
	}
	printf("%d %d",mx,b);
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	//入力
	int a, b;
	cin >> a >> b;
	//処理
	//出力
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  unordered_set<ll> st[200005];
int countt=0;
void DFSUtil(long long v, bool visited[]) 
{ 
    // Mark the current node as visited and print it 
    visited[v] = true; 
  //  cout << v << " "; 
    countt++;
    // Recur for all the vertices 
    // adjacent to this vertex 
  
    for(auto i:st[v] ) 
        if(!visited[i]) 
            DFSUtil(i, visited); 
} 
int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ll N,M;
    cin>>N>>M;
  

    ll u,v;
    for(ll i=0;i<M;i++){
        cin>>u>>v;
        --u,--v;
        st[u].insert(v);
        st[v].insert(u);
    }
    
    bool vis[N];
    for(ll i=0;i<N;i++)
        vis[i]=false;
    ll ans=0;
    countt=0;
     for (ll v=0; v<N; v++) 
    { 
        if (vis[v] == false) 
        { 
            // print all reachable vertices 
            // from v 
            DFSUtil(v, vis); 
            if(countt>ans)
                ans=countt;
            countt=0;
          
        } 
    } 
    cout<<ans<<"\n";

}


Measured memory_bytes: 39620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll l, r;
    cin >> l >> r;
    if (r - l >= 2018)  {
        cout << 0 << endl;
        return;
    }
    l %= 2019;
    r %= 2019;
    if (r <= l) r += 2019;
    ll ans = LINF;
    for (int i = l; i < r; i++) {
        for (int j = l + 1; j <= r; j++) {
            chmin(ans, 1LL * i * j % 2019);
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3656
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    t = x // 5

    return t // 100 * 1000 + t % 100 * 5


print(main())





Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int DIM=1010;
long A[DIM];
long B[DIM];
long C[DIM];
long ANS[DIM];



int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    long p;
    int i,j,k;
    int X,Y,Z,K;
    long min=0;
    priority_queue<long> pq;
    cin >> X >> Y >> Z >> K;
    // cout << X << " " << Y << " " << Z << " " << K << "\n";
    for(i=1; i<= X; i++){ cin >> p; A[i]=p;}
    for(j=1; j<= Y; j++){ cin >> p; B[j]=p; }
    for(k=1; k<= Z; k++){ cin >> p; C[k]=p; }

    sort(A+1,A + 1+ X, greater<>());
    sort(B+1,B + 1+ Y, greater<>());
    sort(C+1,C + 1+ Z, greater<>());

      long maxBC = B[1] + C[1];
    long maxC = C[1];


    for(i=1; i<= X; i++){
        // cout << "check A: " << A[i] << "\n";
        if (A[i] + maxBC < min){break;}
        for(j=1; j<= Y; j++){
            if (A[i] + B[j] + maxC < min){break;}
            for(k=1; k<= Z; k++){
                if (A[i] + B[j] + C[k] < min){break;}
                // cout << "size " << pq.size() << " push " << A[i] + B[j] + C[k] << "\n";
                pq.push( -(A[i] + B[j] + C[k]) );
                // cout << "top " << -pq.top() << "\n";
                if (pq.size()>K){
                    // cout << "drop " << - pq.top();
                    pq.pop();
                    min = - pq.top();
                    // cout << " min " << min << "\n";
                }
            }
        }
    }
    //exit(0);
    for(i=1;i<=K;i++){
         ANS[K+1-i]= -pq.top();
         pq.pop();
    }
    for(i=1;i<=K;i++){
        cout << ANS[i] <<  "\n";
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <complex>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)n; ++i)

typedef complex<double> P;
double const EPS = 1e-8;

struct C {
  P p;
  double r;
  int c;
};

vector<C> circle;
int n;
int memo[1<<25];

int dfs(int S) {
  if(memo[S] != -1) return memo[S];
  //  cout<<S<<endl;
  int ret = 0;
  vector<int> hoge[4];
  if((S&1) == 0) hoge[circle[0].c].push_back(0);

  for (int i=1; i<n; ++i) {
    if (S>>i&1) continue;
    bool f = true;
    rep(j,i) {
      if (S>>j&1) continue;
      if (abs(circle[i].p - circle[j].p) < circle[i].r + circle[j].r)
        f = false;
    }
    if (f) {
      hoge[circle[i].c].push_back(i);
    }
  }

  // cout<<"S = "<<S<<endl;
  // for(int i=0; i<4; ++i) {
  //   cout<<i<<" size = "<<hoge[i].size()<<endl;
  //   for(int j=0; j<hoge[i].size(); ++j)
  //     cout<<hoge[i][j]<<" ";
  //   cout<<endl;
  // }
  rep(i,4) {

    if(hoge[i].size() <= 1) continue;
    for(int j=0; j<hoge[i].size(); ++j)
      for(int k=j+1; k<hoge[i].size(); ++k) {
        ret = max(ret, 2+dfs(S|(1<<(hoge[i][j]))|(1<<(hoge[i][k]))));
      }
  }
  return memo[S] = ret;
}

int main() {
  while(cin >> n,n) {
    memset(memo, -1, sizeof(memo));
    circle.clear();
    circle.resize(n);
    rep(i,n) {
      int x,y,r,c;
      cin >> x>>y>>r>>c;
      c--;
      circle[i] = (C){P(x,y),r,c};
    }
    cout << dfs(0)<< endl;
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
void how(long long int n,long long int k)
{
    long long s1,s2;
    n=abs(n-k);
    s1=n;
    n=abs(n-k);
    s2=n;
    cout<<(s1>s2?s2:s1)<<endl;
    return;
}

int main()
{
    long long int n,k;
    cin>>n>>k;
    if(n>k)
    {
        how(n%k,k);
        return 0;
    }
    else how(n,k);

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll a,b;
	cin >> a >> b;
	a--;
	b--;
	cout << ((b+(a-1))/a) << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector < int >p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	vector < double >pp(N);
	double sum = 0;
	for (int i = 0; i < K; i++) {
		pp[i] = (double)(p[i] + 1) / 2;
		sum += pp[i];
	}

	double maxSum = sum;

	for (int i = K; i < N; i++) {
		pp[i] = (double)(p[i] + 1) / 2;

		sum -= pp[i - K];
		sum += pp[i];
		maxSum = max(maxSum, sum);
	}

	printf("%.10f\n", maxSum);

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

ll x;

ll sum2n(ll n){
    return n*(n+1)/2;
}

int main(){
    cin >> x;

    ll lb = 0, ub = x;
    while(ub-lb > 1){
        int mid = (lb+ub)/2;

        if(sum2n(mid) >= x){
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;
}


Measured memory_bytes: 256
function solve() {
    const input = (require('fs').readFileSync("/dev/stdin", "utf8") as string).split("\n");
    const N = +input[0];
    const A = input[1].split(" ").map((x: string): number => +x);
    const B = input[2].split(" ").map((x: string): number => +x);
    const C = input[3].split(" ").map((x: string): number => +x);

    let ans = 0;
    let prev = -1;
    for (let i = 0; i < N; i++) {
        ans += B[A[i] - 1];
        if (prev + 1 == A[i]) {
            ans += C[A[i] - 1 - 1];
        }
        prev = A[i];
    }
    console.log(ans);
}

solve();


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define test() int t; cin>>t; while(t--)
#define ll long long int
int mod = 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> a(n);
	double p = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		p += a[i];
	}
	p = round(p / n);
	double ans = 0;
	for (int i : a) {
		ans += (i - p) * (i - p);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3788
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	int a[n];
	bool ok=true;
	fo0(i,n){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3==0 or a[i]%5==0){

			}
			else{
				ok=false;
			}
		}
	}
	if(!ok){
		cout<<"DENIED";
	}
	else
		cout<<"APPROVED";
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# Bの本を上から読んでいった時の累積時間をリストに入れる
B_acc = [0] * M
B_acc[0] = B[0]
for i in range(1, M):
  B_acc[i] = B_acc[i-1] + B[i]

A_acc = 0
count_max = bisect.bisect(B_acc, K - A_acc)
for i in range(N):
  A_acc += A[i]
  if A_acc <= K:
    count = (i + 1) + bisect.bisect(B_acc, K - A_acc)
    count_max = max(count_max, count)
  else:
    break
print(count_max)

Measured memory_bytes: 118444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long dp[110000];
    int N; cin >> N;

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N+1; ++i) {
        for (int j = 0; j < 7; ++j) {
            if(i + int(pow(9,j)) <= N) {
                chmin(dp[i + int(pow(9,j))], dp[i] + 1);
            }
        }
        for (int j = 0; j < 8; ++j) {
            if(i + int(pow(6,j)) <= N) {
                chmin(dp[i + int(pow(6,j))], dp[i] + 1);
            }
        }
        chmin(dp[i + 1], dp[i] + 1);
    }
    // 答え
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.*;
public class Main {
	
	
	
	public static int Frog2(int n,int k, int h[]) {
		int dp[] = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1]-h[0]);
		
		for(int i=2;i<n;i++) {
			int min = Integer.MAX_VALUE;
			if(i-k>=0) {
				for(int j=i-1;j>=i-k;j--) {
					int minCount = Math.abs(h[i]-h[j])+dp[j];
					if(minCount < min) {
						min = minCount;
					}	
				}
			}else {
				for(int j=i-1;j>=0;j--) {
					int minCount = Math.abs(h[i]-h[j])+dp[j];
					if(minCount < min) {
						min = minCount;
					}	
				}
			}
			
			dp[i] = min;
		}
		
		return dp[n-1];
	}
    
    public static void main(String[] arg) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int h[] = new int[n];
        for(int i=0;i<n;i++) {
        	h[i] = s.nextInt();
        }
        System.out.println(Frog2(n,k,h));
        
    }
}

Measured memory_bytes: 51088
import Control.Applicative
import Control.Monad
import Data.List

main :: IO()
main = do
    [n, _, x] <- map read . words <$> getLine
    gates <- map read . words <$> getLine
    print $ solve n x gates
    
solve :: Int -> Int -> [Int] -> Int
solve n x gates = (calcValueTo0 x gates) `min` (calcValueToN x n gates)

calcValueTo0 :: Int -> [Int] -> Int
calcValueTo0 x gates = length . filter (`elem` gates) $ take x [0..]

calcValueToN :: Int -> Int -> [Int] -> Int
calcValueToN x n gates = length . filter (`elem` gates) $ [x..n]

Measured memory_bytes: 1020
import java.util.Scanner;

//https://onlinejudge.u-aizu.ac.jp/problems/1159
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while (sc.hasNext()) {
	  int n = sc.nextInt();
	  int p = sc.nextInt();
	  int[] stoneOfCandidates = new int[n];

	  if (n == 0 && p == 0) break;
	  int stoneRemain = p;
	  int result = 0;

	  while (true) {
		if (stoneRemain > 0) {
		  stoneOfCandidates[result]++;
		  stoneRemain--;
		} else {
		  stoneRemain += stoneOfCandidates[result];
		  stoneOfCandidates[result] = 0;
		}
		if (stoneOfCandidates[result] == p) break;
		result++;
		if (result == n) result = 0;
	  }
	  System.out.println(result);
	}
  }
}



Measured memory_bytes: 26976
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> trans(5);
    rep(i,5) cin >> trans[i];
    
    int mintrans = *min_element(ALL(trans));
    
    int ans = 4 + (mintrans-1 + n)/mintrans;
    cout << ans << endl;
    
    
    
    
    
    
    
    
}



signed main() {
    solve();
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll S,N,M;
ll X[2001];
ll T[2010],P[2001];
ll sum[2010];
ll dp[2010][2010];

void monotone_minima(ll i,ll l,ll r,ll prel,ll prer){
  if(l>=r)return ;
  ll j=(l+r)/2;
  ll idx=j;
  minch(dp[i][j],dp[i-1][j]);
  repl(k,prel,min(j,prer)){
    if(dp[i][j]>dp[i-1][k]+T[j-1]*(j-k)-(sum[j]-sum[k])){
      dp[i][j]=dp[i-1][k]+T[j-1]*(j-k)-(sum[j]-sum[k]);
      idx=k;
    }
  }
  monotone_minima(i,l,j,prel,idx+1);
  monotone_minima(i,j+1,r,idx,prer);
}

int main(){
  cin>>S>>N>>M;
  rep(i,S)cin>>X[i];
  rep(i,N){
    cin>>T[i]>>P[i];
    T[i]-=X[P[i]-1];
  }
  sort(T,T+N);
  rep(i,N)sum[i+1]=sum[i]+T[i];

  rep(i,2010)rep(j,2010)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,M){
    monotone_minima(i+1,0,N+1,0,N+1);
  }
  cout<<dp[M][N]<<endl;

  return 0;
}



Measured memory_bytes: 34784
#include <iostream>
#include <algorithm>
using namespace std;
long long int a, b, c, tot;
int main(){
	cin >> a >> b;
	c = __gcd(a, b);
	for (long long int i=2; i*i <= c; i++) {
		if (c%i == 0) {
			tot++;
			while (c % i == 0) c /= i;
		}
	}
	if(c != 1) tot++; 
	cout << tot+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3][3];
  for(int i =0; i<3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i = 0; i < N; i++){
    cin >> b[i];
  }
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < N; k++){
        if(a[i][j] == b[k]){
          a[i][j] = 0;
          //b.erase(b.begin() + k);
          //N -= 1;
        }
      }
    }
  }
  //tate
  int sum = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      sum += a[i][j];
    }
    if(sum == 0){
      cout << "Yes" << endl;
      return 0;
    }
    sum = 0;
  }

  //yoko
  sum = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      sum += a[j][i];
    }
    if(sum == 0){
      cout << "Yes" << endl;
      return 0;
    }
    sum = 0;
  }

  //naname
  sum = 0;
  for(int i = 0; i < 3; i++){
    sum += a[i][i];
  }
  if(sum == 0){
    cout << "Yes" << endl;
    return 0;
  }
  sum = 0;
  for(int i = 0; i < 3; i++){
    sum += a[i][2-i];
  }
  if(sum == 0){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll b;
int main() {
	while (cin >> b && b > 0) {
		ll ans_len=1;
		ll ans_start=b;
		REP(n, 2, 100000) {
			ll sum = n * (n + 1) / 2;
			if (b < sum) break;

			ll d = b - sum;
			if (d % n == 0) {
				ans_start = d / n + 1;
				ans_len = n;
			}
		}
		p2(ans_start, ans_len);

	}

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0, data = 0;
  for (int i = 0; i < b - a; i++) {
    data += i + 1;
  }
  cout << data - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define		in(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	endl '\n'
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize(num) trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

void constructTree(ll input[], ll segTree[], ll low, ll high, ll pos){
	if(low==high){
		segTree[pos]=input[low];
		return ;
	}
	ll mid=(low+high)/2;
	constructTree(input,segTree,low,mid,2*pos+1);
	constructTree(input,segTree,mid+1,high,2*pos+2);
	segTree[pos]=min(segTree[2*pos+1],segTree[2*pos+2]);
}


vector<ll>adj[200100];
bool visited[200100];

ll arr[200005];
ll b;
ll a;

ll sum=0;
ll dp[200005];
ll frog(ll i){
	if(i==a) return dp[i]=0;
	if(dp[i]!=-1) return dp[i];
	if(i>a) return dp[i]=10005;
	ll temp=inf;
	loop(j,1,b+1){
		temp=min(temp,frog(i+j)+abs(arr[i-1]-arr[i+j-1]));
	}
	return dp[i]=temp;
}

int main() {
	fast;
	time;
  	memset(visited,false,sizeof(visited));
  	memset(dp,-1,sizeof(dp));
	cin>>a>>b;
	loop(j,0,a){
		cin>>arr[j];
	}
	cout<<frog(1);
	return 0;
}

//ends here read(a)

Measured memory_bytes: 12928
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

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

    int count0 = 0,count1;

    for (int i=0;i<s.size();i++){
        if(s[i] == '0'){
            count0++;
        }
    }
    count1 = s.size() - count0;

    printf("%d",2 * min(count0,count1));
}

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

int main(int argc, char const *argv[])
{
    int n;cin>>n;
    int dp[100010][3] ={0};

    for(int i=1;i<=n;i++){
        int a,b,c;cin>>a>>b>>c;
        if(i==1){
            dp[1][0]=a;
            dp[1][1]=b;
            dp[1][2]=c;
        }
        else{
            dp[i][0]=max(dp[i-1][1], dp[i-1][2])+a;
            dp[i][1]=max(dp[i-1][0], dp[i-1][2])+b;
            dp[i][2]=max(dp[i-1][1], dp[i-1][0])+c;
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}


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

int main() {
  int s,a,b,count=0;
  cin >> s;
  a = s/100;
  b = s%100;
  vector<string> ans{"NA","MMYY","YYMM","AMBIGUOUS"};
  if(1 <= a && a <= 12) count += 1;
  if(1 <= b && b <= 12) count += 2;
  cout << ans[count] << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String arg[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        String ans;
        if(c % 3 ==0 ||a % 3 ==0 || b % 3 ==0){
            ans = "Possible";
        }else 
            ans = "Impossible";
        System.out.println(ans);
    }
}

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

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

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

    int m; cin >> m;

    vector<int> p(m), x(m);
    for(int i=0; i<m; i++){
        cin >> p[i] >> x[i];
        p[i] -= 1;
    }

    for(int i=0; i<m; i++){
        cout << sum - t[p[i]] + x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
namespace ConsoleTest {
  class Program {
    static void Main(string[] args) {
      string a = Console.ReadLine();
      int b = 0;
      for (int i = 0; i < 4; i++) {
        if(a.Substring(i, 1) == "+") {
          b++;
        } else {
          b--;
        }
      }
      Console.WriteLine(b);
    }
  }
}

Measured memory_bytes: 11092
import sys

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

def solve():
    readline = sys.stdin.readline
    H, W = map(int, readline().split())
    ch, cw = map(int, readline().split())
    dh, dw = map(int, readline().split())
    S = ['#'] * (W+2)
    for _ in range(H):
        S += ['#'] + list(readline().rstrip()) + ['#']
    S += ['#'] * (W+2)
    H += 2
    W += 2

    uf = UnionFind(H*W)
    for i in range(H*W):
        if S[i] == '#':
            continue
        for d in [-W, -1, 1, W]:
            if S[i+d] == '.':
                uf.union(i, i+d)

    now = ch*(W) + cw
    goal = dh*(W) + dw
    # print(now, goal)
    # print(uf.find(now), uf.find(goal))
    if uf.same(now, goal):
        print(0)
        return
    ans = 0
    q = set()
    q.add(now) 
    next_area = set() 
    visited = [False] * (H*W)

    # for i in range(H):
    #     print(S[6*i:6*i+6])
    while True:
        while q:
            x = q.pop()
            if x == goal:
                print(ans)
                return
            visited[x] = True
            for dy in [-2*W, -W, 0, W, 2*W]:
                for dx in [-2, -1, 0, 1, 2]:
                    xx = x + dy + dx
                    if 0 <= xx < W*H and S[xx] == '.' and not visited[xx]:
                        if uf.same(x, xx):
                            q.add(xx)
                        else:
                            next_area.add(xx)
        if next_area:
            q = next_area
            next_area = set()
        else:
            print(-1)
            return 
        ans += 1

if __name__ == '__main__':
    solve()


Measured memory_bytes: 157244
n=int(input())
s=[input() for _ in range(n)]
c,ca,cb,cab=0,0,0,0
for i in range(n):
    n0=len(s[i])
    if s[i][0]=='B':
        if s[i][n0-1]=='A':cab+=1
        else:cb+=1
    elif s[i][n0-1]=='A':ca+=1
    for j in range(1,n0):
        if s[i][j-1]=='A' and s[i][j]=='B':c+=1
ans=c
if cab>0:
    if ca>0:
        ans+=1
        ca-=1
    ans+=cab-1
    if cb>0:
        ans+=1
        cb-=1
ans+=min(ca,cb)
print(ans)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 2030405060

int main()
{
  int n,m;cin>>n>>m;
  int i,j,k;
  vector<int> s(m);
  vector<int> t(m);
  vector<int> d(m);
  rep(i,m)cin>>s[i]>>t[i]>>d[i];
  vector<vector<int>> g(n,vector<int>(n,INF));
  rep(i,n)g[i][i]=0;
  rep(i,m)
  {
    g[s[i]][t[i]]=d[i];
  }
  rep(k,n)
  {
    rep(i,n)
    {
      rep(j,n)
      {
        if(g[i][k]==INF||g[k][j]==INF)continue;
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  bool ch=false;
  rep(i,n)
  {
    if(g[i][i]<0)
    {
      ch=true;
    }
  }
  if(ch)cout<<"NEGATIVE CYCLE"<<endl;
  else
  {
    rep(i,n)
    {
      rep(j,n)
      {
        if(j!=0)cout<<' ';
        if(g[i][j]==INF)cout<<"INF";
        else cout<<g[i][j];
      }
      cout<<endl;
    } 
  }
}



Measured memory_bytes: 3284
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back

LL c[32];
LL d[32];
int pow3[17];
pair<LL, LL>e[14444444];
pair<LL, LL>f[14444444];
int main() {
	int a;
	LL b;
	cin >> a >> b;
	for (int i = 0; i<a; i++)cin>>c[i]>>d[i];
	int L = a / 2;
	int R = a - L;
	pow3[0] = 1;
	//srand(time(NULL));
	for (int i = 1; i<17; i++)pow3[i] = pow3[i - 1] * 3;
	for (int i = 0; i<pow3[L]; i++) {
		for (int j = 0; j<L; j++) {
			int t = i%pow3[j + 1] / pow3[j];
			if (t == 1) { e[i].first += c[j]; e[i].second += d[j]; }
			if (t == 2) { e[i].first -= c[j]; e[i].second -= d[j]; }
		}
	}
	sort(e, e + pow3[L]);
	LL ret =-LINF;
	for (int i = 0; i<pow3[R]; i++) {
		long long h = 0;
		long long w = 0;
		for (int j = 0; j<R; j++) {
			int t = i%pow3[j + 1] / pow3[j];
			if (t == 1) { h += c[L + j]; w += d[L + j]; }
			if (t == 2) { h -= c[L + j]; w -= d[L + j]; }
		}
		f[i] = mp(-h, w);
	}
	sort(f, f + pow3[R]);
	for (int i = 0; i<pow3[R]; i++)f[i].first = -f[i].first;
	deque<LL>Q;
	int right = 0;
	int left = 0;
	for (int i = 0; i<pow3[R]; i++) {
		while (right<pow3[L] && e[right].first <= b - f[i].first) {
			while (Q.size() && e[right].second >= e[Q.back()].second) {
				Q.pop_back();
			}
			Q.push_back(right);
			right++;
		}
		while (Q.size() && left<pow3[L] && e[left].first<-b - f[i].first) {
			if (Q.front() == left)Q.pop_front();
			left++;
		}
		if (Q.size())ret = max(ret, e[Q.front()].second + f[i].second);
	}
	cout << ret << endl;
}

Measured memory_bytes: 451584
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
}


Measured memory_bytes: 35956
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	char s1,s2;
	scanf("%d %c %d %c %d",&a,&s1,&b,&s2,&c);
	if(a>2019||a==2019&&b>4) printf("TBD");
	else printf("Heisei");
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

struct Edge{
    int to; 
    int cost;    
};

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

void Main(){
    const int INF = 1001001001;
    int k; cin >> k;
    vector<vector<Edge>> G(k);
    rep(i, k){
        G[i].pb({(i+1) % k, 1});
        G[i].pb({(i*10) % k, 0});
    }
    
    vi cost(k, INF);
    deque<int> dq;
    dq.push_front(1);
    cost[1] = 0;
    while(!dq.empty()){
        int now = dq.front(); dq.pop_front();
        for (auto [v, c] : G[now]){
            if(c == 1) {
                if(chmin(cost[v], cost[now] + 1)) dq.push_back(v);
            }
            else {
                if(chmin(cost[v], cost[now])) dq.push_front(v);
            }
        }
    }
    cout << 1 + cost[0] << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	vector<int> v(N);
	REP(i, N) cin >> v[i];
	SORT(v);

	double ans = v[0];
	FOR(i,1,N){
		ans = (v[i] + ans) / 2.0;
	}

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
N = int(input())
ans = 0
array = []
d = {}
for tmp in range(N):
    a = int(input())
    array.append(a)
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
array = list(set(array))
for tmp in range(len(array)):
    if d[array[tmp]]%2 == 1:
        ans += 1
    else:
        pass
print(ans)

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

void solve() {
	vector<int> v(3);
	rep(i, v.size()) scanf("%d", &v[i]);
	sort(v.begin(), v.end());
	int a = v[0], b = v[1], c = v[2];
	int ans = 0;
	if ((c - b) % 2 == 0 && (c - a) % 2 == 0) {
		ans += (c - b) / 2 + (c - a) / 2;
	}
	else if (((c - b) % 2 == 0 && (c - a) % 2 == 1) || ((c - b) % 2 == 1 && (c - a) % 2 == 0)) {
		ans += (c - b) / 2 + (c - a) / 2 + 2;
	}
	else {
		ans += (c - b) / 2 + (c - a) / 2 + 1;
	}

	cout << ans << endl;

}

int main(void) {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,flag=0;
    cin>>n;
    for(int i=1;i<10;i++)
    {
        for(int j=1;j<10;j++)
        {
            if(i*j==n)flag=1;
            if(flag)break;
        }
        if(flag)break;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		if(N == 1){
			myout("Hello World");
		}else{
			myout(nextInt() + nextInt());
		}
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32840