akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=1000+5;

int main(){
    GO();

    int T;
    T=1;
   // cin>>T;
    while(T--){

        ll n,d;
        cin>>n>>d;
        int cnt=0;
        for(int i=0;i<n;i++){
            ll x,y;
            cin>>x>>y;
            if(x*x+y*y<=d*d) cnt++;
        }

        cout<<cnt<<"\n";
    }
}


















































Measured memory_bytes: 3616
#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>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
ll cal(ll a){
    ll ret = (ll)sqrt(a);
    if(ret * ret == a) ret--;
    return ret;
}

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

    int Q;
    cin >> Q;
    while(Q--){
        ll a,b;
        cin >> a >> b;
        if(a > b) swap(a,b);
        ll ans = 0ll;
        if(a == b){
            ans = 2 * (a - 1);
        }else if(a + 1 == b){
            ans = 2 * (a - 1);
        }else{
//            ans = 2 * (a - 1) + (b - a) - 1;
            ll C = cal(a * b);
            ll D = a * b / C;
            if(C * D != a * b){
                if(D == C){
                    ans = 2*C - 2;
                }else{
                    ans = 2*C - 1;
                }
            }else{
                if(D - C > 1){
                    ans = 2 * C - 1;
                }else if(D == C + 1){
                    ans = 2 * C - 2;
                }else if(D == C){
                    ans = 2 * C - 2;
                    if(a < C){
                        ans--;
                    }
                }
            }
        }
        cout << ans << endl;
    }


    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

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

    vi v(3); int K;

    trav(x, v) cin >> x; cin >> K;

    ll ans = 0;
    F0R(i, 3) {
        if (K == 0) break;
        if (K >= v[i]) {
            if (i == 0) ans += v[i];
            if (i == 2) ans += -v[i];
            K -= v[i];
        } else {
            if (i == 0) ans += K;
            if (i == 2) ans += -K;
            K = 0;
        }
    }

    cout << ans << "\n";

}


Measured memory_bytes: 3608
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

def rotate(l_2d):
    l_2d = np.array(l_2d)
    return (l_2d.T).tolist()


# check horizontal direction(done)
done = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = j
        while k < w:
            if s[i][k] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i][j+o] += l
            done[i][j+o] = 1


# check vertical direction
done = [[0] * w for _ in range(h)]
for j in range(w):
    for i in range(h):
        if done[i][j] == 1 or s[i][j] == "#":
            continue
        l = 0
        k = i
        while k < h:
            if s[k][j] == ".":
                l += 1
            else:
                break
            k += 1
        for o in range(l):
            cnt[i+o][j] += l
            done[i+o][j] = 1

print(max(list(map(max, cnt))) - 1)



Measured memory_bytes: 281352
def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    a, b = None, None
    import itertools
    for i, vars in enumerate(itertools.permutations(range(1, N+1))):
        if a is None:
            for j in range(N):
                if vars[j] != P[j]:
                    break
            else:
                a = i
        if b is None:
            for j in range(N):
                if vars[j] != Q[j]:
                    break
            else:
                b = i
        if a is not None and b is not None:
            break
    print(abs(a-b))


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;//long long保险
    cin>>a>>b>>c>>x;//输入这四个数
    for(int i=0;i<=a;i++)//枚举500硬币的个数
        for(int j=0;j<=b;j++)//枚举100硬币的个数
            for(int z=0;z<=c;z++){//枚举50硬币的个数
                int k=i*500+j*100+z*50;//定义k为此时硬币总值
                if(k==x)//如果就是x
                   ans++;//计数器加一
                if(k>x)//这是一个优化，如果k值已经超过了x，后面的z到c时k的值一定大于x，肯定不等于x，所以可以直接退出当前循环
                   break;//退出当前循环
            }
    cout<<ans<<endl;//输出ans的值(AT题都要打换行)
    return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string N;
    cin >> N;

    //vll X(N);
    //REP(i,N) cin >> X[i];


    //本文
    ll size = N.size();
    ll ans = 0;
    REP(i,size){
        ans += N[i]-'0';

    }
    //出力
    if(ans%9==0){
        cout << "Yes";return 0;
    }
    cout << "No" << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}


Measured memory_bytes: 3728
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{	
	int a,b; cin >> a>>b;
  	cout << max(max(a+b,a*b),a-b) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
    IN(n);
    ll ans=0;
    ans+=(ll)(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int n;
int main(){
    cin >> n;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    sort(ALL(A));
    cout << A[n-1] - A[0] << endl;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = []
con= 0
for _ in range(D):
    S.append(list(map(int, input().split())))
t = [-1]*D
best = [0]*D
last = [0]*26

for i in range(D-6):#1日ごと
    
    score = [-1]*26
    
    for x in range(26):#どの問題を選ぶか
        if i==0:
            con = 0
        else:
            con = best[i-1]
        
        con += S[i][x]
        #last[x] = i+1
        for j in range(26): #減少量の計算 #問題ごと
            if not j==x:
                con -= C[j]*(i-last[j]+1)

        score[x]=con
    m = -100000
    ii = 0
    for k in range(26):
        if m<score[k]:
            m=score[k]
            ii=k
    
    last[ii]=i+1
    best[i]=score[ii]
    t[i]=ii+1

for g in reversed(range(1, 4)):

    p2 = [0]*(26**2)
    for i in range(26):
        for j in range(26):
            #print(i*26+j)
            p2[i*26+j]+=S[D-2*g][i]
            p2[i*26+j]+=S[D-2*g+1][j]
            for k in range(26):
                if not k==i:
                    p2[i*26+j] -= C[k]*(25-last[k])
            for k in range(26):
                if not k==j:
                    if k==i:
                        p2[i*26+j] -= C[k]*2
    ma = 0
    ind = 0
    for h in range(26**2):
        if p2[h]>ma:
            ma=p2[h]
            ind = h
    last[t[D-2*g]]=D-2*g+1
    last[t[D-2*g+1]]=D-2*g+2      
            
    t[D-2*g]= h//26+1
    t[D-2*g+1]=h%26+1
   



        
    
    
    
    
for i in range(D):
    print(t[i])
#print(best)



Measured memory_bytes: 68764
#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);

    int x;
    cin >> x;

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    set<int> S;
    for (auto x : A) {
        S.insert(x);
    }
    pair<int,int> best{123456, -1234};
    for (int i = -200; i <= 200; ++i) {
        if (S.count(i) > 0) {
            continue;
        }
        int diff = abs(i - x);
        best = min(best, make_pair(diff, i));
    }
    cout << best.second << '\n';

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;


int main(){

	vector<int> zeronum;
	zeronum.push_back(0);
	int count = 0;
	for(int i = 1; i <= 1000000; i++){
		int tmp = i;
		while(tmp % 5 == 0){
			count++;
			tmp /= 5;
		}
		zeronum.push_back(count);
	}

	int n = 0;
	while(cin >> n && n != 0){
		cout << zeronum[n] << endl;
	}
	return 0;
}

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

int digit(int n){
  int sum = 0;
  while(n != 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n,b,min,hoge;
  cin >> n;
  min = 9999999;
  for(int a = 1; a < n/2 + 1;a++){
    hoge = 0;
    b = n - a;
    hoge += digit(a);
    hoge += digit(b);
    if(min > hoge) min = hoge;
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
ans = 0
n,a,b = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
start = x[0]
for i in x
  if (i - start) * a > b
    ans += b
  else
    ans += (i - start) * a
  end
  start = i
end
puts ans

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	ll a[20],b[20],c[20];
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		x--;
		a[i]=x;
	}
	for(ll i=0;i<n;i++){
		cin>>b[i];
	}
	for(ll i=0;i<n-1;i++){
		cin>>c[i];
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		ans+=b[now];
		if(i!=n-1){
			ll next=a[i+1];
			if(next==now+1){
				ans+=c[now];
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	int lim = pow(2, N);
	vector<vector<int>> kvec(M);
	vector<int> p(M, 0);
	for (int i = 0; i < M; ++i)
	{
		int n;
		cin >> n;
		kvec[i].resize(n + 1);
		kvec[i][0] = n;
		for (int j = 1; j <= n; ++j)
		{
			cin >> kvec[i][j];
			kvec[i][j]--;
		}
	}
	for (int i = 0; i < M; ++i)
		cin >> p[i];

	int i, j;
	int sum = 0;
	for (i = 0; i < lim; ++i)
	{
		for ( j = 0; j < M; ++j)
		{
			int ct = 0;
			for (int k = 1; k <= kvec[j][0]; ++k)
			{
				if ((i & (1 << kvec[j][k])) != 0)
					++ct;
			}
			if (ct % 2 != p[j])
				break;
		}
		if (j == M)
			sum++;
	}

	cout << sum << endl;
	return 0;
}

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

int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    long long d=c-a-b;
    if(d>0&&d*d>4*a*b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# coding: utf-8
while True:
    n,x = map(int, input().split())
    
    if n == x == 0:
        break

    count = 0
    
    for i in range(1,int(x/3)+1):
        for j in range(i+1,int((x-i)/2)+1):
            k = x - (i + j)
            if j < k <= n:
                count += 1
                
    print(count)

Measured memory_bytes: 7612
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

sum = a.inject(&:+)
x = Array.new(n)
x[0] = a[0]
ans = (x[0] * 2 - sum).abs
for i in 1..n-2
   x[i] = x[i-1] + a[i]
   ans = (x[i] * 2 - sum).abs if ans > (x[i] * 2 - sum).abs
end

puts ans


Measured memory_bytes: 18052
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    string l;
    cin>>l;
    int dig=l.size();
    //dig:1~10^5
    vector<vector<ll>> dp(dig+1,vector<ll>(2,0));
    //桁、越えない確定が1
    dp[0][0]=1;
    dp[0][1]=0;
    for(int i=0;i<dig;i++){
        if(l[i]=='1'){
            dp[i+1][0]=(2*dp[i][0])%mod;
            dp[i+1][1]=(dp[i][0]+dp[i][1]*3)%mod;
        }
        else{
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=(dp[i][1]*3)%mod;
        }
    }
    cout<<(dp[dig][0]+dp[dig][1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;

int isPow(double a){
    for (int i = 2; i < 20; ++i) {
        if(log(a)/log(1.*i)==round(log(a)/log(1.*i)))return i;
    }
    return -1;
}
void _() {
    string s;
    cin >> s;
    int l=0;
    for(auto c : s){
        l+=(2*(c=='+')-1);
    }

    cout << l;



}


int main() {
#if __MINGW32__
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Input.txt", "r", stdin);
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








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

const int N = 505;

int a[N][N], n;

void solve(int L, int R, int k) {
	if (L == R) return;
    int m = L + R >> 1;
    for (int i = L; i <= m; i ++) for (int j = m+1; j <= R; j ++) a[j][i] = a[i][j] = k;
    solve(L, m, k+1);
    solve(m+1, R, k+1);
    return;
}

int main() {
    scanf("%d", &n);
    solve(1, n, 1);
    for (int i = 1; i <= n; i ++) {
        for (int j = i+1; j <= n; j ++) printf("%d%c", a[i][j], " \n"[j==n]);
    }
	return 0;
}


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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])); 
	}
	printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[110], b[110];
  
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++)
  {
    cin >> b[i];
  }
  int maxv = 0;
  int tmp = 0;
  
  for(int i = 0; i < n; i++)
  {
    
    for(int j = 0; j <= i; j++)
    {
      tmp += a[j];
    }
    
    for(int j = i; j < n; j++)
    {
      tmp += b[j];
    }
    maxv = max(tmp, maxv);
    tmp = 0;
  }
  cout<<maxv<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>wq1,wq2;
int main()
{
    int g,h,t,z;
    ll q,x,sp,lo,hi,m,ntz=0;
    scanf("%d %lld",&t,&q);
    for(g=0;g<t;g++){
        scanf("%d",&z);
        if(z>0)wq1.push_back(z);
        else if(z<0)wq2.push_back(z);
        else ntz++;
    }
    sort(wq1.begin(),wq1.end());
    sort(wq2.begin(),wq2.end());
    lo=-1e18, hi=1e18;
    while(lo<hi){
        m=(lo+hi)>>1;
        if(m<0)for(g=h=sp=0;g<wq2.size();g++){
            while(h<wq1.size()&&1LL*wq1[h]*wq2[g]>m) h++;
            sp+=wq1.size()-h;
        }
        else if(m>0){
            sp=wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
            for(g=0,h=wq1.size()-1;g<h;g++){
                while(g<h&&1LL*wq1[g]*wq1[h]>m) h--;
                sp+=h-g;
            }
            for(g=0,h=wq2.size()-1;g<h;h--){
                while(g<h&&1LL*wq2[g]*wq2[h]>m) g++;
                sp+=h-g;
            }
        }
        else{
            sp=wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
        }
        if(sp>=q)hi=m;
        else lo=m+1;
    }
    printf("%lld\n",hi);
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<double> proba(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> proba[i];
    }
    vector<double> dp(N + 1);
    dp[0] = 1;
    for (int i = 0; i <= N; i++) {
        vector<double> new_dp(N + 1);
        double p = proba[i];
        new_dp[0] = dp[0] * (1 - p);
        for (int j = 1; j <= N; j++) {
            new_dp[j] = p * dp[j - 1] + (1 - p) * dp[j];
        }
        dp = new_dp;
    }
    double res = 0;
    for (int i = N / 2 + 1; i <= N; i++) {
        res += dp[i];
    }
    cout << setprecision(15) << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

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

long long modpow(long long a, long long n, long long mod=MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod=MOD) {
    return modpow(a, mod - 2, mod);
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> num(1100000,0);
    rep(i,n){
        cin>>a[i];
        auto pf=prime_factorize(a[i]);
        for(auto p : pf) num[p.first]=max(num[p.first],p.second);
    }
    
    ll LCM=1;
    for(int v=2;v<1100000;v++) LCM=(LCM*modpow(v,num[v]))%MOD;

    ll ans=0;
    rep(i,n){
        ll add=(LCM*modinv(a[i]))%MOD;
        ans=(ans+add)%MOD;
    }

    cout<<ans<<endl;
}

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

vector <int> a(200001);
int n, k;
long long rez;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i], rez += a[i];
    sort(a.begin() + 1, a.begin() + n + 1);
    for (int i = n; i >= max(n - k + 1, 1); --i)
        rez -= a[i];
    cout << rez;
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
int s[10000001];

int main()
{
    s[0] = 0;
    int cnt = 1;
    long long ans = 0;
    while (true)
    {
        s[cnt] = getchar();
        if (s[cnt] == EOF || s[cnt] == '\n')
            break;
        s[cnt] -= '0';
        cnt++;
    }

    while (s[cnt - 1] == 0)
    {
        cnt--;
    } // 处理完最后的0

    for (int i = cnt - 1; i > 0; i--)
    {
        if (s[i] == 5)
        {
            if (s[i - 1] >= 5)
            {
                ans += 10 - s[i]; // 找零
                s[i - 1]++;       // 进位
            }
            else
            {
                ans += s[i]; // 把零头付了
            }
        }
        else if (s[i] > 5)
        {
            ans += 10 - s[i]; // 找零
            s[i - 1]++;       // 进位
        }
        else
        {
            ans += s[i]; // 把零头付了
        }
    }

    ans += s[0];

    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009

int main(){
  string s;
  cin >> s;
  vbool eng(26);
  rep(i,s.size()){
    eng[s[i]-'a'] = true;
  }
  int key = 0;
  bool flag = false;
  rep(i,26){
    if(eng[i] == false){
      key = i;
      flag = true;
      break;
    }
  }
  if(flag) cout << s << (char)('a' + key) << endl;
  else if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
  else{
    int num = INF;
    int numnum = -1;
    for(int i = 25;i >= 0;i--){
      if(s[i] - 'a' > numnum){
        numnum = s[i] - 'a';
      }
      else{
        rep(j,i){
          cout << s[j];
        }
        int ansmin = INF;
        for(int j = i;j < 26;j++){
          if((int)s[i] < (int)s[j])
            ansmin = min(ansmin,(int)s[j]);
        }
        cout << (char)(ansmin) << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll n,d,a;cin >> n >> d >> a;
    vector<pair<ll,ll>> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    vi vec(n);
    rep(i,n) vec[i] = p[i].first;
    vl attacknum(n+10,0);

    ll ans = 0;
    rep(i,n){
        attacknum[i] += attacknum[max(i-1, 0)];
        ll x = p[i].first;
        ll hp = p[i].second;
        hp -= max(attacknum[i] * a, 0LL);

        ll num = dup(hp, a);
        if(num < 0) num = 0;
        attacknum[i] += num;
        ans += num;

        int id = upper_bound(vec.begin(), vec.end(), x + 2 * d) - vec.begin();
        attacknum[min(id, (int)n)] -= num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[101];
	scanf("%s", s);
	size_t len = strlen(s);

	int cnt = 0;
	for (size_t i = 0; i < len/2; i++)
		cnt += s[i] != s[len-1-i];
	printf("%d\n", cnt);
}


Measured memory_bytes: 128
import bisect


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    # 自分より数値が小さい数の個数
    # 1, 3, 2 --> [0, 2, 1]
    B = A.copy()
    B.sort()
    cnt = [0 for _ in range(N)]
    for i, a in enumerate(A):
        idx = bisect.bisect_left(B, a)
        cnt[i] = idx

    ans = 0
    MOD = 1000000007
    for c in cnt:
        ans += c * (K - 1) * K // 2
        ans %= MOD

    # 自分より後ろに存在する自分より小さい数の個数
    # 1, 3, 2 --> [0, 1, 0]
    B = A.copy()
    B = B[::-1]
    cnt = [0 for _ in range(N)]
    array = []
    for i, b in enumerate(B):
        idx = bisect.bisect_left(array, b)
        cnt[i] = idx
        bisect.insort_left(array, b)
    cnt = cnt[::-1]

    for c in cnt:
        ans += c * K
        ans %= MOD

    print(ans)


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        long[] map = new long[N+1];
        map[0] = 2;
        map[1] = 1;
        for (int i = 2; i <= N; i++) {
        	map[i] = map[i-2] + map[i-1];
        }
        
        System.out.println(map[N]);
    }
    
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, Q;
    string S;

    cin >> N >> Q;
    cin >> S;

    vector<int> l(Q), r(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> l[i] >> r[i];
    }


    vector<int> sum(N + 1, 0);
    for (int i = 1; i < N; ++i) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            sum[i + 1] = sum[i] + 1;
        } else {
            sum[i + 1] = sum[i];
        }
    }


    //0 1 2 3 4 5 6
    // A C A C A C
    // 1 2 3 4 5 6
    for (int i = 0; i < Q; ++i) {
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }

    return 0;
}

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

// #define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifndef DBG
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

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

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");
  ll a,b,c;cin>>a>>b>>c;
  PRINTl(max(max(a,b),c)*9+a+b+c);

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, m;
    cin>>n>>m;

    vector<vector<int>> a(1024, vector<int>(1024));
    a[1][1] = 1;
    for (int i = 1; i<=9; i++)
    {
        int N = (1<<i);
        for (int x = 0; x<(1<<i); x++)
            for (int y = 0; y<(1<<i); y++)
            {
                a[x+N][y] = a[x][y];
                a[x+N][y+N] = a[x][y];
                a[x][y+N] = 1-a[x][y];
            }
    }

    for (int i = 0; i<(1<<10); i++) if (a[0][i] == 1)
    {
        for (int j = 0; j<(1<<10); j++) a[j][i] = 1-a[j][i];
    }
    for (int i = 0; i<(1<<10); i++) if (a[i][0] == 1)
    {
        for (int j = 0; j<(1<<10); j++) a[i][j] = 1-a[i][j];
    }

    for (int i = 0; i<(1<<n)-1; i++)
    {
        for (int j = 0; j<(1<<m) - 1; j++) cout<<(a[i+1][j+1] + a[i][j] - a[i+1][j] - a[i][j+1] + 4)%2;
        cout<<endl;
    }


}

Measured memory_bytes: 5376
#include<stdio.h>

int main(){

  int i,n,m,M,Max;

  scanf("%d%d%d",&n,&m,&M);
  Max = M-m;
  if(M<m) m=M;
  for(i=2;i<n;i++){
    scanf("%d",&M);
    if(M-m>Max) Max = M-m;
    if(M<m) m=M;
  }

  printf("%d\n",Max);

  return 0;
}


Measured memory_bytes: 2140
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();

        if (n % 2 == 0)
            System.out.println(((double) 1 / n) * n / 2);
        else
            System.out.println(((double) 1 / n) * ((n / 2) + 0.5));

    }
}


Measured memory_bytes: 81104
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int a, b, c, d;
  int res;

  scanf ( "%d%d%d%d", &a, &b, &c, &d );
  res = a + b + c + d;

  printf ( "%d\n%d\n", res / 60, res % 60 );


  return ( 0 );
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;

	cout<<n*n*n<<endl;

	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> cnt_w(n), cnt_e(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; ++ i){
		if(s[i] == 'W') cnt_w[i] = 1;
		else cnt_e[i] = 1;
	}
	for(int i = 1; i < n; ++ i){
		cnt_w[i] += cnt_w[i - 1];
		cnt_e[i] += cnt_e[i - 1];
	}
	int ans = n;
	for(int i = 0; i < n; ++ i){
		int curr = 0;
		if(i > 0) curr += cnt_w[i - 1];
		if(i < n - 1) curr += cnt_e[n - 1] - cnt_e[i];
		ans = min(ans, curr);
	}
	cout << ans << '\n';
}


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

vector<int> vec(N);
for (int k = 0; k < N; k++) {
  cin >> vec.at(k);
}

for (int i = 0; i < 30; i++) {

for (int j = 0; j < N; j++) {
 vec.at(j) /= 2;
if (vec.at(j) % 2 != 0) {
M = i;
 goto LABEL ;
}
}

}
LABEL:;

if (M != 0 ){
M++;
}
cout << M << endl;
}


Measured memory_bytes: 256
n=int(input())
s=input()
r,g,b=[],[],[]
for i in range(n):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    else:
        b.append(i)
b=set(b)
lb=len(b)
ans=0
for i in r:
    for j in g:
        x,y=min(i,j),max(i,j)
        ans_=lb
        if x-(y-x) in b:
            ans_-=1
        if y+(y-x) in b:
            ans_-=1
        if (x%2==y%2) and (y-x)//2+x in b:
            ans_-=1
        ans+=ans_
print(ans)

Measured memory_bytes: 9232
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int N = 2e4 + 10;

int n, a[N], b[N], p[N];

int main() {

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &p[i]);
	for (int i = 1; i <= n; ++i) {
		a[i] = (n + 1) * (i - 1) + 1;
		b[i] = (n + 1) * (n - i) + 1;
	}
	for (int i = 1; i <= n; ++i) {
		int j = p[i];
		a[j] += i - 1;
	}
	for (int i = 1; i < n; ++i) 
		printf("%d ", a[i]);
	printf("%d\n", a[n]);
	for (int i = 1; i < n; ++i)
		printf("%d ", b[i]);
	printf("%d\n", b[n]);
	
	return 0;
}


Measured memory_bytes: 896
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();
    let d: usize = iter.next().unwrap().parse().unwrap();
    let mut pos = vec![(0, 0); (h * w)].into_boxed_slice();
    for i in 0..h {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        for j in 0..w {
            let num = iter.next().unwrap().parse::<usize>().unwrap();
            pos[num - 1] = (j as i64, i as i64);
        }
    }
    let mut costs = vec![0; (h * w)].into_boxed_slice();
    for i in d..(h * w) {
        costs[i] = costs[i - d] +
            (pos[i].0 - pos[i - d].0).abs() + (pos[i].1 - pos[i - d].1).abs();
    }
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let q = buf.trim().parse::<usize>().unwrap();
    for _ in 0..q {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        let mut l = iter.next().unwrap().parse::<usize>().unwrap();
        let r = iter.next().unwrap().parse::<usize>().unwrap();
        println!("{}", costs[r - 1] - costs[l - 1]);
    }
}


Measured memory_bytes: 7292
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

#define X first
#define Y second
#define MP make_pair

using namespace std;
    
const int N = 3e5 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll t[N * 4], tt[N * 4], dp[2][N], dz[N];
vector< pair<int, ll> > g[N];
vector< ll > gg[N];
int n;

void build(int v, int tl, int tr){
	if(tl == tr){
		t[v] = -INF;
		return;
	}	
	int tm = (tl + tr) / 2;
	build(v * 2, tl, tm);
	build(v * 2 + 1, tm + 1, tr);
	t[v] = max(t[v * 2], t[v * 2 + 1]);
}

void push(int v){
	if(tt[v] == 0)
		return;
	t[v * 2] += tt[v], t[v * 2 + 1] += tt[v];
	tt[v * 2] += tt[v], tt[v * 2 + 1] += tt[v];
	tt[v] = 0;
}

void upd(int v, int tl, int tr, int l, int r, ll val){
	if(tl > r || l > tr)
		return;
	if(tl >= l && tr <= r){
		t[v] += val;
		tt[v] += val;
		return;
	}
	push(v);
	int tm = (tl + tr) / 2;
	upd(v * 2, tl, tm, l, r, val);
	upd(v * 2 + 1, tm + 1, tr, l, r, val);
	t[v] = max(t[v * 2], t[v * 2 + 1]);
}

ll get(int v, int tl, int tr, int l, int r){
	if(tl > r || tr < l)
		return -INF;
	if(tl >= l && tr <= r){
		return t[v];
	}
	push(v);
	int tm = (tl + tr) / 2;
	return max(get(v * 2, tl, tm, l, r), get(v * 2 + 1, tm + 1, tr, l, r));
}

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

	cin >> n;
	int q;
	cin >> q;
	for(int i = 1;i <= q;i++){
		int l, r, v;
		cin >> l >> r >> v;
		g[r].push_back(MP(l, v));
	}

	for(int i = 1;i <= n;i++){
		upd(1, 1, n, i, i, max(0LL, get(1, 1, n, 1, i)));
		for(int j = (int)g[i].size() - 1;j >= 0;j--){
			upd(1, 1, n, g[i][j].X, i, g[i][j].Y);
		}		
	}
	cout << max(0LL, t[1]);
	return 0;
}

Measured memory_bytes: 33152
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = 0;
		
		int i=1;		//最小公倍数を求める
		while(i<=B){
			if((long)A*i%B==0) {
				C=(long)A*i;
				break;
			}
			else{
				i++;
			}
		}
 		 System.out.println(C);
	}		
}

Measured memory_bytes: 23764
#include<iostream>
#include<list>

int main() {
	int N;
	double ans = 0;

	std::cin >> N;

	std::list<double> a;

	for (int i = 0; i < N; i++) {
		double b;
		std::cin >> b;
		a.push_back(b);
	}
	a.sort();

	for (int i = 1; i < N; i++) {
		auto itr = a.begin();
		itr++;
		a.push_back((a.front() + *itr) / 2);

		a.pop_front();
		a.pop_front();

		a.sort();
	}

	std::cout << a.front() << std::endl;
}

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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second
const int LIMIT = 500;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    int L; cin >> L;
    vector<vi> dp(n, vi(LIMIT + 1));
    dp[n-1].assign(LIMIT + 1, n-1);
    for (int i = n-2; i >= 0; i--){
        int pos = arr[i] + L;
        int id = int(upper_bound(arr.begin(), arr.end(), pos) - arr.begin());
        id -= 1;
        dp[i][0] = i;
        for (int j = 1; j <= LIMIT; j++){
            dp[i][j] = dp[id][j - 1];
        }
    }
    int q; cin >> q;
    while (q--){
        int a, b; cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        int res = 0;
        while (dp[a][LIMIT] < b){
            res += LIMIT;
            a = dp[a][LIMIT];
        }
        for (int i = 0; i <= LIMIT; i++){
            if (dp[a][i] >= b) break;
            res++;
        }
        cout << res << "\n";
    }

    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}



int main(void){
    int d,n;
    cin>>d>>n;
    ll num=pow(100,d);
    if(n==100)cout<<num*n+num<<endl;
    else cout<<num*n<<endl;
    return 0;

}

Measured memory_bytes: 384
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;
 
    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
#define mod 1000000007
#define valid(x,y) (x<h&&y<w)
using namespace std;
int h,w;
char a[1005][1005];
ll memo[1005][1005];
ll dp(int i,int j)
{
    if(!valid(i,j))
    {
        return 0;
    }
    if(a[i][j]=='#')
    {
        return 0;
    }
    if(memo[i][j]!=-1)
    {
        return memo[i][j];
    }
    if(i==h-1&&j==w-1)
    {
        return 1;
    }
    ll ret1,ret2;
    ret1=dp(i+1,j);
    ret2=dp(i,j+1);
    return memo[i][j]=(ret1+ret2)%mod;
}
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;++i)
    {
        for(int j=0;j<w;++j)
        {
            scanf(" %c",&a[i][j]);
        }
    }
    memset(memo,-1,sizeof memo);
    printf("%lld",dp(0,0));
    return 0;
}




Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define int             long long

int32_t main() {
 
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



  int n, k;
  cin >> n >> k;

  int a[n];
  int dp[n];

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = 0;
  }
  //cout << dp[0] << dp[1];

  for (int i = 1; i < n; i++) {
    // if (n >= k) {
    dp[i] = INT_MAX;

    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);

        //cout << dp[i] << endl;
      }
      //else
    }
    //}
    //dp[i] = ans;
  }

  cout << dp[n - 1 ];



  return 0;
}

Measured memory_bytes: 5152
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int main(){
    int h,a;scanf("%d %d",&h,&a);
    int ans=0;
    while(1){
        ans++;
        h-=a;
        if(h<=0)break;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	if N == 3 {
		fmt.Println("2 5 63")
		return
	}
	if N == 4 {
		fmt.Println("2 5 20 63")
		return
	}
	if N == 5 {
		fmt.Println("2 5 20 30 63")
		return
	}

	found := []int{}
	for k := 0; len(found) < N; k++ {
		found = append(found, 6*k+2)
		found = append(found, 6*k+3)
		found = append(found, 6*k+4)
		found = append(found, 6*k+6)
	}

	ans := found[:N]
	sum := Sum(ans...)
	switch sum % 6 {
	case 2:
		// ans[0] == 2
		next6 := ans[N-1] + 6 - (ans[N-1] % 6)
		ans[0] = next6
	case 3:
		// ans[1] == 3
		next6 := ans[N-1] + 6 - (ans[N-1] % 6)
		ans[1] = next6
	case 5:
		// 9
		// ans[1] == 3
		var next4 int
		switch ans[N-1] % 6 {
		case 0:
			next4 = ans[N-1] + 4
		case 2:
			next4 = ans[N-1] + 2
		case 3:
			next4 = ans[N-1] + 1
		case 4:
			next4 = ans[N-1] + 6
		}
		ans[1] = next4
	}

	for _, a := range ans {
		fmt.Printf("%d ", a)
	}
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

int main() {
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);

    ll cnt = 1;
    while (true) {
        if (cnt % 2 == 1) {
            C -= B;
        } else {
            A -= D;
        }
        if (C <= 0) {
            cout << YES << endl;
            return 0;
        } 
        if (A <= 0) {
            cout << NO << endl;
            return 0;
        }
        cnt++;
    }
}


Measured memory_bytes: 3768