akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

vector<long long int> temple;
vector<long long int> shrine;

const long long int INF=1e14;

int west_nearest_ind(long long int x, string t_or_s) {
    if(t_or_s=="temple") {
        int ind = lower_bound(temple.begin(), temple.end(), x)-temple.begin();
        if(ind==0) {
            return -1;
        } else {
            return ind-1;
        }
    } else if(t_or_s=="shrine") {
        int ind = lower_bound(shrine.begin(), shrine.end(), x)-shrine.begin();
        if(ind==0) {
            return -1;
        } else {
            return ind-1;
        }
    } else {
        return -2;
    }
}

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    
    temple.resize(A);
    shrine.resize(B);
    for(int a=0; a<A; a++) {
        cin >> temple[a];
    }
    for(int b=0; b<B; b++) {
        cin >> shrine[b];
    }
    
    for(int q=0; q<Q; q++) {
        long long int x;
        cin >> x;

        // cout << west_nearest_ind(x, "temple") << endl;
        // cout << west_nearest_ind(x, "shrine") << endl;
        
        long long int dis=INF, tmpdis;
        if(west_nearest_ind(x, "temple")>=0) {
            if(west_nearest_ind(x, "shrine")>=0) {
                for(int t=0; t<2; t++) {
                    for(int s=0; s<2; s++) {
                        int t_ind=min(west_nearest_ind(x, "temple")+t, A-1);
                        int s_ind=min(west_nearest_ind(x, "shrine")+s, B-1);
                        tmpdis = min(abs(x-temple[t_ind]), abs(x-shrine[s_ind]));
                        tmpdis += abs(temple[t_ind]-shrine[s_ind]);
                        // cout << tmpdis << endl;

                        dis = min(dis, tmpdis);
                    }
                }
            } else {
                for(int t=0; t<2; t++) {
                    int t_ind=min(west_nearest_ind(x, "temple")+t, A-1);
                    int s_ind=0;
                    tmpdis = min(abs(x-temple[t_ind]), abs(x-shrine[s_ind]));
                    tmpdis += abs(temple[t_ind]-shrine[s_ind]);

                    dis = min(dis, tmpdis);
                }
            }
        } else {
            if(west_nearest_ind(x, "shrine")>=0) {
                for(int s=0; s<2; s++) {
                    int t_ind=0;
                    int s_ind=min(west_nearest_ind(x, "shrine")+s, B-1);
                    tmpdis = min(abs(x-temple[t_ind]), abs(x-shrine[s_ind]));
                    tmpdis += abs(temple[t_ind]-shrine[s_ind]);

                    dis = min(dis, tmpdis);
                }
            } else {
                int t_ind=0, s_ind=0; 
                dis = min(abs(x-temple[t_ind]), abs(x-shrine[s_ind]));
                dis += abs(temple[t_ind]-shrine[s_ind]);
            }
        }

        cout << dis << endl;
    }

    return 0;
    
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int M;
int main()
{
	in>>M;
	out<<24-M+24<<std::endl;
	return 0;
}


Measured memory_bytes: 764
N = int(input())
A = list(map(int, input().split()))

temp = A
counter = 0
canDevide = list(map(lambda x:x%2, temp))
while canDevide.count(0) == N:
    counter = counter + 1

    temp = list(map(lambda x: x / 2, temp))
    canDevide = list(map(lambda x:x%2, temp))
print(counter)

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif



void solve()
{
    long long n;
    cin>>n;

    vector<long long> items(n);

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



    for(int i=1;i<n;i++){

        if(items[i-1]<items[i]){
            items[i]--;
        }

    }

    bool yes=true;

    for(int i=1;i<n;i++){
        if(items[i]<items[i-1]){
            yes=false;
        }
    }

    if(yes){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

vector<int> friends[100005];
vector<int> groups[100005];

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 蜷����縺ｮ隕ｪ繧定｡ｨ縺咎��蛻�
    vector <ll> siz; // 邏�髮��粋縺ｮ繧ｵ繧､繧ｺ繧定｡ｨ縺咎��蛻�(1 縺ｧ蛻晄悄蛹�)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 蛻晄悄縺ｧ縺ｯ隕ｪ縺ｯ閾ｪ蛻����霄ｫ
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize 縺�縺ｨ縺ｪ縺懊°蛻晄悄蛹悶＆繧後↑縺九▲縺�
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 蛻晄悄縺ｧ縺ｯ隕ｪ縺ｯ閾ｪ蛻����霄ｫ
    }

    // Member Function
    // Find
    ll root(ll x) { // 譬ｹ縺ｮ讀懃ｴ｢
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x 縺ｮ隕ｪ縺ｮ隕ｪ繧� x 縺ｮ隕ｪ縺ｨ縺吶ｋ
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique��医ョ繝ｼ繧ｿ讒矩��繧偵��繝ｼ繧ｸ縺吶ｋ繝��け��主ｰ上ｒ螟ｧ縺ｫ縺上▲縺､縺代ｋ���
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 騾｣邨仙愛螳�
        return root(x) == root(y);
    }

    ll size(ll x) { // 邏�髮��粋縺ｮ繧ｵ繧､繧ｺ
        return siz[root(x)];
    }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind tree1(n+1);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    friends[a].push_back(b);
    friends[b].push_back(a);
    tree1.merge(a, b);
  }
  for (int i = 0; i < k; i++) {
    int c, d;
    cin >> c >> d;
    groups[c].push_back(d);
    groups[d].push_back(c);
  }

  for (int i = 1; i <= n; i++) {
    long long cnt = tree1.size(i)-1; // 閾ｪ蛻��ｒ蠑輔￥
    vector<int> t;
    for (int j = 0; j < friends[i].size(); j++) {
      // 蜿矩＃繧堤ｪ√▲霎ｼ繧�
      t.push_back(friends[i][j]);
    }
    for (int j = 0; j < groups[i].size(); j++) {
      // 騾｣邨先��蛻��°縺､逶ｴ謗･繧ｰ繝ｫ繝ｼ繝励▽縺ｪ縺後ｊ繧堤ｪ√▲霎ｼ繧�
      if (tree1.issame(i, groups[i][j])) {
        t.push_back(groups[i][j]);
      }
    }
    unique(t.begin(), t.end());
    int dif = t.size();
    cout << cnt-(dif);
    cout << ( (i == n) ? "\n" : " ");
  }

  return 0;
}


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

 int main() {
  int n;
  cin >> n;
  
  map<string,int> mp;
  rep(i,n) {
   string s;
   cin >> s;
   sort(s.begin(),s.end());
   mp[s]++;
   }
  
  long long count = 0;
  
  for(auto& p : mp) {
   int s = p.second;
   count += (long long)s*(s-1)/2;
   }
   cout << count;
  
  
 }

Measured memory_bytes: 11264
import * as fs from 'fs'

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n')
const n = parseInt(input[0].split(' ')[0], 10)
const workDays = input[1]
  .split(' ')
  .map((x: string): number => +x)
  .reduce((acc, x) => (acc += x))

const result = n - workDays > -1 ? n - workDays : -1

console.log(result)



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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll Q;
    cin >> Q;

    deque<ll> que;

    while(Q--){
        ll a;
        cin >> a;

        // push
        if(a==0){
            ll d, x;
            cin >> d >> x;
            if(d==0){
                que.push_front(x);
            }else{
                que.push_back(x);
            }
        }
        // random
        else if(a==1){
            ll p;
            cin >> p;
            p(que[p]);
        }
        // pop
        else{
            ll d;
            cin >> d;
            if(d==0){
                que.pop_front();
            }else{
                que.pop_back();
            }
        }
    }

    
    return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
 
#define N 200009
 
using namespace std;
 
int a[N];

int main(){
	int i,j,t1,t2,t3,t4,n;
	long long int sum,ans,buf1,buf2,buf3,buf4;
	sum=buf2=0;
	ans=1e18;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	buf1=sum;
	for(i=0;i<n-1;i++){
		buf2+=a[i];
		buf1-=a[i];
		buf3=abs(buf1-buf2);
		ans=min(ans,buf3);
	}
	printf("%lld\n",ans);
	return 0;		
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
i=0
b=A
while len(b)>0:
    c=[]
    for number in b:
        if(number%2==0):
            c.append(number/2)
    i+=len(c)
    b=[]
    for number in c:
        if(number%2==0):
            b.append(number/2)
    i+=len(b)
print(i)

Measured memory_bytes: 4212
#include <iostream>

using namespace std;

int main(){
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            if(s-x-y >=0 and s-x-y<=k) cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
struct node
{
    node* lch,*rch;
    ll s;
    node(ll a, ll b)
    {
        s = a;
        lch  = rch = NULL;
    }
    node() {
        s = 0;
        lch = rch = NULL;
    };
    void pull()
    {
        if(lch==NULL||rch==NULL)return;
        s = max(lch->s,rch->s);
        return;
    }
};
node* build(ll,ll);
void update(node*,ll,ll,ll,ll);
ll query(node*,ll,ll,ll,ll);

ll n,h[200001],a[200001];
int main()
{
    scanf("%lld",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&h[i]);
    }
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&a[i]);
    }
    node* start = build(1,n);
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ll temp = 0;
        temp += query(start,1,h[i]-1,1,n);
        temp += a[i];
        update(start,h[i],temp,1,n);
        ans = max(ans,temp);
    }
    printf("%lld\n",ans);

}
node* build(ll L,ll R)
{
    node *n = new node();
    if(L==R)
    {
        //leaf
        return n;
    }
    ll mid = (L+R)/2;
    n->lch = build(L,mid);
    n->rch = build(mid+1,R);
    n->pull();
    return n;

}
void update(node* n,ll id,ll val,ll L,ll R)
{
    if(L==R)
    {
        n->s = max(n->s,val);
        return;
    }
    ll mid = (L+R)/2;
    if(id<=mid)update(n->lch,id,val,L,mid);
    else update(n->rch,id,val,mid+1,R);
    n->pull();
    return;
}
ll query(node* n,ll l,ll r,ll L,ll R)
{
    if(l>R||r<L)return 0;
    if(l<=L&&r>=R)return n->s;
    ll mid = (L+R)/2;

    return max(query(n->lch,l,r,L,mid),query(n->rch,l,r,mid+1,R));

}


Measured memory_bytes: 19404
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    vector<pll> P(N);
    rep(i, N) {
        int a;
        cin >> a;
        P[i] = {a, i};
    }

    sort(all(P));

    int r = 0, tmp = 0, cnt = 0;
    while (r + 1 <= N - 1) {
        if (P[r].second <= P[r + 1].second)
            cnt++, r++;
        else
            tmp = max(tmp, cnt + 1), r++, cnt = 0;
    }
    tmp = max(tmp, cnt + 1);

    cout << N - tmp << endl;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
ll dp[200][2][10000 + 100];
int main() {
  string S;
  int N;
  cin >> S >> N;
  dp[0][0][0] = 1;
  dp[0][1][0] = 1;
  REP(i, S.size()) {
    REP(j, N) {
      if (i != 0) {
        REP(k, 10) {
          int n = j + k;
          dp[n % N][0][i + 1] += dp[j][0][i];
          dp[n % N][0][i + 1] %= MOD;
        }
      }
    }
    REP(j, N) {
      int a = S[i] - '0';
      REP(k, a + 1) {
        int n = j + k;
        if (a != k) {
          dp[n % N][0][i + 1] += dp[j][1][i];
          dp[n % N][0][i + 1] %= MOD;
        } else {
          dp[n % N][1][i + 1] += dp[j][1][i];
          dp[n % N][1][i + 1] %= MOD;
        }
      }
    }
  }
  cout << (dp[0][0][S.size()] + dp[0][1][S.size()] - 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 19276
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);
	var D = parseInt(input[1], 10);

	//出力
	console.log('%d', Math.ceil( N / ( 2 * D + 1 )));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
string str[1001][2];
int H;

bool isSym() {
    for (int i = 1; i <= H; i++) if (str[i][0] != str[i][1]) return false;
    for (int i = 1; i <= H/2; i++) if (str[i][0] != str[H+1-i][0] || str[i][1] != str[H+1-i][1]) return false;
    return true;
}

//1 -> 0, 2 -> 1 ... 5 -> 3, 6 -> 2, 7 -> 1, 8 -> 0
void change(const int &x, const int &y) {
    if (y > H/2) {
        if (str[x][1][H-y] == '0') str[x][1][H-y] = '1';
        else str[x][1][H-y] = '0';
    }
    else {
        if (str[x][0][y-1] == '0') str[x][0][y-1] = '1';
        else str[x][0][y-1] = '0';
    }
}


int main()  {

    char buffer[1001];
    int C, x, y, d, sum = 0;
    scanf("%d %d", &C, &H);
    string smpl;
    for (int i = 1; i <= H; i++) {
        scanf("%s", buffer);
        smpl = buffer;
        reverse(smpl.begin()+H/2, smpl.begin()+H/2*2);
        str[i][0] = smpl.substr(0, H/2); str[i][1] = smpl.substr(H/2);
    }

    if (isSym()) sum++;
    for (int i = 0; i < C-1; i++) {
        scanf("%d", &d);
        for (int j = 0; j < d; j++) {
            scanf("%d %d", &x, &y);
            change(x, y);
        }
        if (isSym()) sum++;
    }
    printf("%d\n", sum);




    return 0;
}



Measured memory_bytes: 3764
#include<stdio.h>

void main()
{
	long int x[2], y[2] ;

		int c = 0;
	long long prd[4];

	scanf("%ld %ld %ld %ld", x, x + 1, y , y + 1);
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			prd[c] = x[i] * y[j];
			c++;
		}
	}
	long long max = prd[0];
	for (int i = 1; i < 4; i++)
	{
		if (max < prd[i])
		{
			max = prd[i];
		}
	}
	printf("%lld", max);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

double r;

void solve(){
  cin >> r;
  double s=r*r*M_PI;
  double t=2*r*M_PI;
  printf("%.6f %.6f\n",s,t);
}

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



Measured memory_bytes: 3288
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#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(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i,s.size()) {
    int x = s[i] - 'A';
    x = (x + n) % 26;
    cout << (char)(x + 'A');
  }
  cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x3fffffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define ff first
#define ss second
#define EPS 1e7
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
const ll MOD=1e9+7;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string>) { cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<int>> adj; vector<bool> vis; vector<int> color;
/////////////////// FUNCTIONS ////////////////////////////////////
template<class T>
T maxx(T a, T b) {return a>b?a:b;}
template<typename T, typename... Args>
T maxx(T a, T b, Args... args){return maxx(a>b?a:b, args...);}
ll mexp(ll x, ll n, ull m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
template<class T>
T minn(T a, T b) {return a<b?a:b;}
template<typename T, typename... Args>
T minn(T a, T b, Args... args){return minn(a>b?a:b, args...);}
bool ispow2(ll x){ return x && (!(x&(x-1))); }
ld pow(ld a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}
/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0);   cout<<fixed; cerr<<fixed;
  cout<<setprecision(10); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	int n; cin>>n; int v[2][n];
	for(int i=0;i<2;++i) for(int j=0;j<n;++j) cin>>v[i][j];
	for(int i=1;i<n;++i) v[0][i]+=v[0][i-1],v[1][n-i-1]+=v[1][n-i];
	int ans=0;
	for(int i=0;i<n;++i) ans=maxx(ans,v[0][i]+v[1][i]);
	cout<<ans<<'\n';



	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1000<<"ms.\n";
	#endif
  return 0;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var n,k,x,y int
    fmt.Scan(&n,&k,&x,&y)
    fmt.Println(min32(n,k)*x + max32(n-k,0)*y)
}





func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;

int main()
{
	ll n, mon[100005], arr[100005];
	ll mn = 0;
	cin >> n;
	for (int i = 0; i <= n; i++)
		cin >> mon[i];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = 0; i < n; i++)
	{
		mn += min(arr[i], mon[i]);
		if (arr[i] > mon[i])
		{
			mn += min(arr[i] - mon[i], mon[i + 1]);
			if (mon[i + 1] > arr[i] - mon[i])mon[i + 1] -= arr[i] - mon[i];
			else mon[i + 1] = 0;
		}
	}
	cout << mn;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
 
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b");
    }else if(a > b){
        printf("a > b");
    }else if(a == b){
        printf("a == b");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int k;
char c[6][6];
bool select_h[6] = {false};
bool select_w[6] = {false};
int cnt_k=0;
int cnt_out=0;

bool check(int h,int w){
    cnt_k = 0;
    REP(i,h){
        if(select_h[i] == true) continue;
        REP(j,w){
            if(select_w[j] == true) continue;
            if(c[i][j] == '#') cnt_k++;
            //cout << c[i][j];
        }
    }
    if(cnt_k == k) return true;
    else return false;
}

void dfs_w(int i,int h,int w){
    i++;
    if(i==w){
        if(check(h,w)) cnt_out++;
        return;
    }
    select_w[i] = false;
    dfs_w(i,h,w);
    select_w[i] = true;
    dfs_w(i,h,w);
}

void dfs_h(int i,int h,int w){
    i++;
    if(i==h){
        dfs_w(-1,h,w);
        return;
    }
    select_h[i] = false;
    dfs_h(i,h,w);
    select_h[i] = true;
    dfs_h(i,h,w);
}

int main() {
    int h,w;cin >> h >> w >> k;
    REP(i,h){
        REP(j,w) cin >> c[i][j];
    }
    dfs_h(-1,h,w);
    cout << cnt_out << endl;
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    char s[3];
    char t[3];
    cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if(s[i] == t[i])++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
void swap(long long *x,long long *y){
    long long tmp;
    tmp=*x;
    *x=*y;
    *y=tmp;
}
int main(void){
    long long A,B,C,D;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    long long C2=C,D2=D;
    long long missC=0,missD=0,missCD=0;
    long long a=C2*D2;
    if(C2<D2){
        swap(&C2,&D2);
    }
    long long r=C2%D2;
    while(r!=0){
        C2=D2;
        D2=r;
        r=C2%D2;
    }
    long long MCM=a/D2;
   // printf("MCM=%lld:",MCM);
    missC=B/C-(A-1)/C;
    missD=B/D-(A-1)/D;
    missCD=B/MCM-(A-1)/MCM;
    //printf("missC=%lld:missD=%lld:missCD=%lld\n",missC,missD,missCD);
    long long count=(B-A+1)-missC-missD+missCD;
    printf("%lld",count);
    return 0;

}

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

int main () {
  int N, b, c, d;
  b = 1;
  c = 0;
  d = 1;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  while (b != 2) {
    b = a.at(d - 1);
    a.at(d - 1) = -1;
    d = b;
    c++;
    if (b == -1) {
      break;
    }
  }
  if (b == -1) {
    cout << b << endl;
  }
  else {
    cout << c << endl;
  }
}

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

int n, m;
int dp[100010];
vector<int> g[100010];

int calc(int u) {
    int &y = dp[u];
    if(y != -1) return y;
    y = 0;
    for(auto&v: g[u]) {
        y = max(y, 1+calc(v));
    }
    return y;
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	while(m--) {
	    int x, y;
	    cin >> x >> y;
	    g[x].push_back(y);
	}
	int ans = 0;
	for(int i=1; i<=n; ++i) {
	    ans = max(ans, calc(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11284
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K = int(readline())
    S = readline().strip()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")



if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  3e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   LEVEL =  log2(N)+1;

ll test = 1;
string s;

void solve(){
	vll v[2];
	cin >> s;
	int i = 0, n = s.size(), ans = 0;
	while(i < n){
		int j = i;
		while(j < n && s[i] == s[j]) j++;
		v[s[i]-'R'].pb(j-i);
		i = j;
	}
	v[0].pb(0);
	sort(all(v[0]),greater<>());
	deb1(v[0][0])
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  set<ll> ans;
  rep(i, n) {
    if(ans.find(a[i]) == ans.end()) ans.insert(a[i]);
    else ans.erase(a[i]);
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 8732
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    int[] p = new int[n];
    ArrayList<String> list = new ArrayList<String>();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

    for(int i = 0; i < n; i++) {
      s[i] = sc.next();
      p[i] = sc.nextInt();
      if(!(list.contains(s[i]))) list.add(s[i]);
      map.put(p[i], i);
    }

    Collections.sort(list);
    for(int i = 0; i < list.size(); i++) {
      String str = list.get(i);
      ArrayList<Integer> list2 = new ArrayList<Integer>();
      ArrayList<Integer> list3 = new ArrayList<Integer>();
      for(int j = 0; j < n; j++) {
        if(str.equals(s[j])) {
          list2.add(j);
          list3.add(p[j]);
        }
      }
      Collections.sort(list3);
      for(int j = list3.size() - 1; j >= 0; j--) {
        System.out.println(map.get(list3.get(j)) + 1);
      }
    }    
  }
}


Measured memory_bytes: 21972
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  //input = input.split("\n");
  tmp = input.split(" ");
  //文字列から10進数に変換するときはparseIntを使います
  var a = parseInt(tmp[0], 10);
  var b = parseInt(tmp[1], 10);
  var c = parseInt(tmp[2], 10);
  var bool = false;
  var ans = "NO";
  if (a === 7 && b === 5 && c === 5) {
    bool = true;
  } else if (a === 5 && b === 7 && c === 5) {
    bool = true;
  } else if (a === 5 && b === 5 && c === 7) {
    bool = true;
  }

  if (bool) {
    ans = "YES";
  }
  //出力
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
//Main("5 5 7");
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s)
{
    cout << s << endl;
}

int main()
{
    ciosup;
    int n;
    cin >> n;
    vector<vint> a(n, vint(n - 1));
    queue<pint> que;
    REP(i, n)
    {
        vecin(a[i]);
        REP(j, n - 1)
        {
            a[i][j]--;
        }
    }
    REP(i, n)
    {
        if(a[i][0] > i && a[a[i][0]][0] == i)
        {
            que.emplace(make_pair(i, a[i][0]));
        }
    }
    vint now(n,0);
    vector<bool> used(n,false);
    ll ans = 1;
    while (que.size())
    {
        pint cd = que.front();
        if (used[cd.FI] || used[cd.SE]){
            ++ans;
            REP(i,n){
                used[i] = false;
            }
            continue;
        }
        que.pop();
        ++now[cd.FI];
        ++now[cd.SE];
        used[cd.FI] = used[cd.SE] = true;
        if (now[cd.FI] < n-1){
            int k = a[cd.FI][now[cd.FI]];
            if (now[k] < n - 1 && a[k][now[k]] == cd.FI) que.emplace(make_pair(cd.FI,k));
        }
        if (now[cd.SE] < n - 1)
        {
            int k = a[cd.SE][now[cd.SE]];
            if (now[k] < n - 1 && a[k][now[k]] == cd.SE)
                que.emplace(make_pair(cd.SE, k));
        }
    }
    bool flag = false;
    REP(i, n)
    {
        if (now[i] != n - 1){
            flag = true;
            break;
        }
    }
    if (flag)
        ans = -1;
    cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
string S;
int main(){
	fast;
  cin>>S;
  
  if (S[2] == S[3] && S[4] == S[5]) cout<<"Yes";
  else cout<<"No";
	
}


Measured memory_bytes: 256
/* Bell + Pascal + Catalan + Pythogorian + triangular + Fibonaci*/

#include <iostream>
#include <algorithm>
using namespace std;
#include <vector>
#include <map>
#include <set>
#include <cmath>    //floor ceil
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>
#include <cstdlib>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <unordered_map>

#define mp make_pair
#define pb push_back
#define endl "\n"
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define lli long long int
#define ll long long
#define f first
#define s second
#define MOD 1000000007

int main () {
    int s,t,d;
    cin >> d>>t>>s;
    if(s*t>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int s[1000];
int main()
{   int a,b;
    while(cin>>a>>b)
    {   int sum=0;
        for(int i=0;i<a;i++)
        {scanf("%d",&s[i]);}
        sort(s,s+a);
        for(int i=a-1;i>=a-b;i--)
        {
            sum=sum+s[i];
        }
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 256
/**
   	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

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

    
    vector<int> p(n);
    int count = 0;

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

    for(int i = 1; i < n-1  ;i++ ){
        if( p[i-1] < p[i] && p[i] < p[i+1]){
            count++;
        }
        else if( p[i-1] > p[i] && p[i] > p[i+1]){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main(){
	int a, b, k;
	long long ta = 0, mu = 0;
	cin >> a >> b >> k;
	ta = a;
	mu = b;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			mu += ta / 2;
			ta /= 2;
		}
		else {
			ta += mu / 2;
			mu /= 2;
		}
	}
	cout << ta << " " << mu << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 998244353;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!^(-1)
    ll c = rf[k]; // = k!^(-1)
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!^(-1)
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}
void add(ll &a, ll b)
{
    a = (a+b) % MOD;
}
int main()
{
    init();
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for(int i = 0; i <= n; i++)
    {
        ll num = k - a * i;
        if(num < 0) break;
        if(num % b) continue;
        add(ans, C(n, i) * C(n, num/b) % MOD);
    }
    add(ans, MOD);
    cout << ans << endl;
}


Measured memory_bytes: 159880
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100009
ll ar[mx+10];
ll mem[mx+10];
ll n;

ll dp(ll ind){
    if(ind>n)  return INT_MAX;
    else if(ind==n) return 0;
    else if(mem[ind]!=-1) return mem[ind];

    ll x=abs(ar[ind]-ar[ind+1])+dp(ind+1);
    ll y=abs(ar[ind]-ar[ind+2])+dp(ind+2);
    mem[ind]=min(x,y);
    return mem[ind];
}

int main()
{

    memset(mem,-1,sizeof(mem));
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>ar[i];
    }
    cout<<dp(1)<<endl;
    return 0;
}


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

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

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

    int N,K; cin >> N >> K;

    if(K == 1) cout << 0 << endl;
    else cout << N-K << endl;

    return 0;

}

Measured memory_bytes: 256
N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to, cost = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, cost))
    edges[to].append((fr, cost))

Q, K = map(int, input().split())
K -= 1
XY = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(Q)]

minDist = [10**18] * N
minDist[K] = 0
st = [K]
while st:
    now = st.pop()
    dist = minDist[now]
    for to, c in edges[now]:
        d = dist + c
        if minDist[to] > d:
            minDist[to] = d
            st.append(to)

ans = [minDist[x] + minDist[y] for x, y in XY]
print(*ans, sep='\n')


Measured memory_bytes: 63316
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <climits>
#include <math.h>
 
using namespace std;
typedef unsigned long ul;
typedef pair<int, int> P;

int main() {
	vector<P> events;
	int n,q,s,t,x,d;
	cin>>n>>q;
	for(int i=0;i<n;i++) {
		cin>>s>>t>>x;
		events.push_back(P(s-x,x));
		events.push_back(P(t-x,-x));
	}
	sort(events.begin(),events.end());

	set<int> block;
	for(int i=0,t=0;i<q;i++){
		cin>>d;
		for(;t<n*2&&events[t].first<=d;t++){
			x = events[t].second;
			if(x > 0) block.insert(x);
			else block.erase(-x);
		}
		if(block.empty()) cout<<-1<<endl;
		else cout<<*block.begin()<<endl;
	}
}

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

using namespace std;
#define ll long long


string k;
const int N = 1e4 + 5, mod = 1e9 + 7;
int dp[N][2][105], d;

//complexity 1e4 * 1e2 * 2 * 10

int add(int a, int b, int Mod)
{
    return (a + b) % Mod;
}
int solve(int idx, bool smaller, int sum)
{
    if(idx == k.size())
        return sum == 0;
    int &ans = dp[idx][smaller][sum];
    if(ans != -1)
        return ans;
    ans = 0;
    for(int digit = 0; digit <= 9; digit++)
    {
        if(!smaller && digit > k[idx] - '0')
            continue;
        bool new_smaller;
        if(smaller)
            new_smaller = 1;
        else
            if(digit < k[idx] - '0')
                new_smaller = 1;
            else
                new_smaller = 0;
        ans = add(ans, solve(idx + 1, new_smaller, add(sum, digit, d)), mod);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> k >> d;
    memset(dp, -1, sizeof dp);
    cout << (solve(0, 0, 0) - 1 + mod) % mod;
    return 0;
}


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


int main() {
double a,b;
  cin >>a >>b;
  if(a>b) cout <<"GREATER" <<endl;
  else if(a==b) cout << "EQUAL" <<endl;
  else cout << "LESS"<<endl;
}
  


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int min = Integer.MAX_VALUE;
        int max = 0;
        
        for(int i = 0; i < n; i++){
            int j = sc.nextInt();
            min = Math.min(min, j);
            max = Math.max(max, j);
        }
        
        System.out.println(max-min);
    }
}


Measured memory_bytes: 25044
n, c = map(int, input().split())

x_list = []
v_list = []
one_list = []
round_list = []
r_one_list = []
r_round_list = []

total = 0

for i in range(n):
    x, v = map(int, input().split())
    x_list.append(x)
    v_list.append(v)
    total = total + v
    one_list.append(total - x)
    round_list.append(total - (2 * x))

prev = 0

for i in range(n):
    if prev > one_list[i]:
        one_list[i] = prev
    else:
        prev = one_list[i]

prev = 0

for i in range(n):
    if prev > round_list[i]:
        round_list[i] = prev
    else:
        prev = round_list[i]


total = 0
for i in range(1, n+1):
    total = total + v_list[-i]
    r_one_list.append(total - (c - x_list[-i]))
    r_round_list.append(total - 2 * (c - x_list[-i]))

prev = 0
for i in range(n):
    if prev > r_one_list[i]:
        r_one_list[i] = prev
    else:
        prev = r_one_list[i]

prev = 0
for i in range(n):
    if prev > r_round_list[i]:
        r_round_list[i] = prev
    else:
        prev = r_round_list[i]

ret = 0

for i in range(n-1):
    tmp = max(one_list[i] + r_round_list[-i-2],
              round_list[i] + r_one_list[-i-2])
    if tmp > ret:
        ret = tmp

ret = max(one_list[-1], r_one_list[-1], ret)

print(ret)


Measured memory_bytes: 26852
fun main(args: Array<String>){
    val (N, X, Y) = readLine()!!.split(" ").map{it.toInt()}

    val ans = Array(N-1){0}
    for(i in 1..N-1){
        for(j in i+1..N){
            val dist = Math.min(Math.abs(X - i) + Math.abs(Y - j) + 1, j - i)
            ans[dist-1]++
        }
    }
    for(i in ans){
        println(i)
    }
}

Measured memory_bytes: 43328
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  int memo=-1;
  for(int i=n-1;i>0;i--){
    if(p[i]>p[i-1]) {
      memo=i;
      break;
    }
  }

  if(memo==-1) {
    cout << 1000 << endl;
    return 0;
  }

  ll mon=1000;
  ll ka=0;

  rep(i,n){
    if(i==memo){
      mon+=ka*p[i];
      break;
    }
    if(p[i-1]<p[i] && !(i+1<n && p[i]<p[i+1])) {
      mon+=ka*p[i];
      ka=0;
    }
    if(i<n-1 && p[i]<p[i+1]){
      ka+=mon/p[i];
      mon-=(mon/p[i])*p[i];
    }
  }

  cout << mon << endl;
}

Measured memory_bytes: 3524
N, K, S = map(int, input().split())

d = S
if S == int(1e9):
    d -= 1
else:
    d += 1

ans = [1 for _ in range(N)]
for i in range(N):
    if K > 0:
        ans[i] = S
        K -= 1
    else:
        ans[i] = d

print(*ans)


Measured memory_bytes: 46880