akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
s = int(0)
for i in range(0,N-1):
    if A[i+1] == A[i]+1:
        s += C[A[i]-1]
print(s+sum(B))

Measured memory_bytes: 3064
n,m,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

a,b = [0], [0]
for i in range(n):
    a.append(a[i]+aa[i])
for i in range(m):
    b.append(b[i]+bb[i])

ans, j = 0, m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)



Measured memory_bytes: 47328
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c, d, e, f;
    scan(a, b, c, d, e, f);
    long w = 100 * a, s;
    double density = 0;
    // ありえる組み合わせで総当りするナリ
    foreach (i; iota(f / (100 * a) + 1))
    {
        foreach (j; iota(f / (100 * b) + 1))
        {
            // 現在の水の量に溶ける砂糖の量を総当り的に求めるナリ
            auto water = 100 * (a * i + b * j);
            auto rest = f - water;
            foreach (k; iota(rest / c + 1))
            {
                // 驚きの4重ループ、計算上は間に合うはずだっちゃ
                foreach (l; iota(rest / d + 1))
                {
                    auto sugar = c * k + d * l;
                    // 100[g]にはe[g]までしか溶けないことに注意でござる
                    if ((a * i + b * j) * e < sugar)
                        break;

                    auto tmp_density = sugar / cast(double)(water + sugar);
                    if (tmp_density > density && water + sugar <= f)
                    {
                        w = water;
                        s = sugar;
                        density = tmp_density;
                    }
                }
            }
        }
    }
    writefln("%s %s", w + s, s);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main()
{
    int nn,k;
    cin>>nn>>k;
    double ans = 0,a1=0;
    ll n=0,d=1;
    for(int i=1;i<=nn;i++)
    {
        int p = i,cc = 0,kk = 1;
        while(p<k)
        {
            p = p*2;
            cc++;
            kk = kk*2;
        }
        kk = kk*nn;
        ll tk = __gcd(d,1LL*kk);
        tk = 1LL*kk*d/tk;
        ll a1 = tk/d;
        n = a1*n+(tk/kk);
        d = tk;
    }
    ans = 1.0*n/d;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int a[3];
    rep(i , 3) cin >> a[i];
    rep(i , 3) cout << (a[(i+2)%3]) << ' '; 
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

answer = 0

for i in range(len(A)):                                                                                                                                                                                     
    answer += B[A[i]-1]                                                                                                                                                                                     
                                                                                                                                                                                                            
    if i < len(A) - 1:                                                                                                                                                                                      
        if A[i] + 1 == A[i+1]:                                                                                                                                                                              
            answer += C[A[i]-1]                                                                                                                                                                             

print(answer)

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin>>a.at(i);
        // cout<<a.at(i)<<endl;
    }
    sort(a.begin(),a.end());
  	reverse(a.begin(),a.end());
    // for (int i=0;i<n;i++){
    //     cout<<a.at(i)<<endl;
    // }
    int alice=0,bob=0;
        for (int i=0 ;i<n;i++){
        if(i %2==0){
        bob+=a.at(i);
        }else{
        alice+=a.at(i);    
        }
    }
    cout<<bob-alice<<endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll beki[100050];
string S;
ll f(int index) {
    if(index == S.size()) return 1;
    if(S[index] == '1') {
        return (2 * f(index + 1) + beki[S.size() - index - 1]) % mod;
    } else {
        return f(index + 1);
    }
}
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    beki[0] = 1;
    for(ll i = 1; i <= 1e5; i++) {
        beki[i] = beki[i-1] * 3 % mod;
    }
    cin >> S;
    cout << f(0) << endl;
    return 0;
}


Measured memory_bytes: 4432
A, B, C, X = [int(input()) for i in range(4)]

res = 0

for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if i * 500 + j * 100 + k * 50 == X:
        res += 1
print(res)

Measured memory_bytes: 2940
line = gets
	
	for i in 1..line.to_i() do
		amount = gets.to_i()
		year = gets.to_i()
		num = gets.to_i()
		max = 0
		for j in 1..num.to_i() do
			line = gets
			sp = line.split(nil)
			r = sp[1].to_f()
			c = sp[2].to_f()
			if sp[0] == "1" then
				last = amount
				r = r +1.0
				for k in 1..year do
					last = last * r - c
					last = last.to_i()
				end
				
			else
				last = amount
				rishi = 0
				for k in 1..year do
					rishi  = rishi + last * r
					last = last - c
					rishi = rishi.to_i()
				end
				last = last + rishi
				last = last.to_i()

			end
			
			if last > max then
				max = last
			end
		end
		print(max)
		print("\n")
	end

Measured memory_bytes: 6132
#include <iostream>

using namespace std;

int main() {
    int K;
    int i, j;
    int len_S = 0;

    char S[101];
    char head_S[101] = "";

    cin >> K >> S;

    for (i = 0; S[i] != '\0'; i++) {
        len_S++;
    }

    if (len_S > K) {
        for (i = 0; i < K; i++) {
            head_S[i] = S[i];
        }
        for (j = i; j < K + 3; j++) {
            head_S[j] = '.';
        }
        cout << head_S << endl;
    }
    else cout << S << endl;

    

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long int ll;

int main(void) {
    long long int n,k,a[100000];
    cin >> n >> k;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
    }
    k--;
    n--;
    if(n % k == 0)
        cout << n / k << endl;
    else
        cout << (n / k) + 1 << endl;
    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}

		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int n; cin>>n;
  vector<tuple<string,int,int>> u(n);
  rep(i,n){
    string s;
    int p;
    cin>>s>>p;
    u[i]=make_tuple(s,200-p,i+1);
  }
  sort(all(u));
  for(auto t:u){
    string s;
    int p,a;
    tie(s,p,a)=t;
    out(a);
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<numeric>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;

	vector<int> l(N);
	for(int i=0; i<N; i++)
	{
		cin >> l[i];
		l[i] = -l[i];
	}

	sort(l.begin(), l.end());

	int ret = -accumulate(l.begin(), l.begin()+K, 0);
	cout << ret << endl;

	return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int> > job(m);
    rep(i,n){
        int a,b; cin >> a >> b;
        if(a>m) continue;
        job[m-a].push_back(b);
    }

    priority_queue<int> p;
    ll ans=0;

    for(int i=m-1; i>=0; i--){
        rep(j,job[i].size()) p.push(job[i][j]);
        if(!p.empty()){
        ans+=p.top();
        p.pop();
        }
    }

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


Measured memory_bytes: 5632
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    int ans = 0;
    for(int i = 1; i * 2 <= str.size(); i++){
        ans += str[i - 1] != str[str.size() - i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  int a[3],k;
  frn(i,3) cin>>a[i];
  cin>>k;
  sort(a,a+3);
  int ans = a[0]+a[1]+pow(2,k)*a[2];
  cout<<ans;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b >= c ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G') 
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt
cnt = 0

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt += 1

ans = ans - cnt
print(ans)


Measured memory_bytes: 9200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
void solve(void)
{
	int x,a,b;
	scanf("%d %d %d", &x, &a, &b);
	if(b-a>x){
		printf("dangerous\n");
	} else if(b-a>0){
		printf("safe\n");
	} else {
		printf("delicious\n");
	}
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
s = input()
ans = 0
for i in range(len(s)):
  if i%2 != 0:
    if s[i]=='L' or s[i]=='U'or s[i]=='D':
      ans+=1
    else:
      ans+=0
  else:
    if s[i]=='R' or s[i]=='U'or s[i]=='D':
      ans+=1
    else:
      ans+=0
print('Yes' if ans == len(s) else 'No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
int arr[55];
int n;
vector<pair<int, int>> ops;
void solve() { 
	cin >> n;
	int negmin = 1, posmax = -1, whereneg, wherepos;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		if (arr[i] < 0) {
			negmin = min(negmin, arr[i]);
			if (arr[i] == negmin)
				whereneg = i;
		}
		else {
			posmax = max(posmax, arr[i]);
			if (posmax == arr[i])
				wherepos = i;
		}
	}
	if (posmax >= -(negmin)) {
		for (int i = 1; i <= n; ++i) {
			if (arr[i] < 0) {
				ops.push_back({i, wherepos});
			}
		}
		for (int i = 2; i <= n; ++i) {
			ops.push_back({i, i - 1});
		}
	} else {
		for (int i = 1; i <= n; ++i) {
			if (arr[i] >= 0) {
				ops.push_back({i, whereneg});
			}
		}
		for (int i = n - 1; i >= 1; --i) {
			ops.push_back({i, i + 1});
		}
	}
	cout << (int) ops.size() << '\n';
	for (auto j : ops)
		cout << j.second << ' ' << j.first << '\n';
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = n;
    if (ans > k) ans %= k;
    ans = min(ans, abs(k-ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    for(int i = 1; i <= 5; ++i) {
        int x;
        cin >> x;
        if(x == 0) {
            cout << i << ' ';
        }
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3604
n, m = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
ab = m.times.map { gets.chomp.split(" ").map(&:to_i) }
g = Array.new(n) { [] }
ab.each do |a, b|
  g[a - 1] << b - 1
  g[b - 1] << a - 1
end
ans = 0
n.times do |i|
  ans += 1 if g[i].count { |j| h[j] >= h[i] } == 0
end
puts ans

Measured memory_bytes: 27068
#(ai,ai+1),(ai+1,ai+2)...(aj-1,aj)に-1を掛けると
#ai,ajに-1を掛けることができる

n = int(input())
a = list(map(int, input().split()))
n=len(a)
mns = [ai for ai in a if ai<0]
pls = [ai for ai in a if ai>=0]

mns.sort()
pls.sort()
#print(mns)
#print(pls)
lm = len(mns)
m_rem = 0
if lm%2:
    if pls:
        if pls[0]<-1*mns[-1]:
            tmp = -1*mns[-1]
            mns[-1] = -1*pls[0]
            pls[0] = tmp
    m_rem = mns.pop()

print(sum(pls)-sum(mns) + m_rem)

Measured memory_bytes: 64752
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)cin >> d[i];
    int ans = 0;
    rep(i,n){
        rep(j,n){
            if(i != j){
                ans += d[i]*d[j];
               }
        }
    }
    cout << ans/2;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a, b, n, m[1001] = {};
    scanf("%d%d%d", &a, &b, &n);
    for (int i = 0, j, k; i < n; ++i)
    {
        scanf("%d%d", &j, &k);
        ++m[j];
        --m[k];
    }
    for (int i = 1; i < 1001; ++i)
    {
        m[i] += m[i - 1];
    }
    for (int i = a; i < b; ++i)
    {
        if (m[i])
        {
            printf("1\n");
            return 0;
        }
    }
    printf("0\n");
    return 0;
}



Measured memory_bytes: 3152
N, A, B = map(int, input().split())

if A == 0:
    print(0)
    exit()

x = int(N / (A+B))
y = N % (A+B)
z = 0
if y < A:
    z = y
else:
    z = A

blue = 0
if x < 10**100:
    blue = (x * A) + z
else:
    blue = 10*100*A + z
print(blue)


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

typedef long long LL;

int main(){
	LL N;
	while(cin >> N, N ){
		// s[n][t] := nさんはt日目が空いている
		bool s[50][30] = {false};
		
		for(int n=0 ; n < N ; n++ ){
			int f;
			cin >> f;
			for(int i=0 ; i < f ; i++ ){
				int t;
				cin >> t;
				t--;
				s[n][t] = true;
			}
		}
		
		int ans = -1;
		// dp[n] := nさんが持っている地図 (bitで表現)
		LL dp[50] = {0};
		for(int t=0 ; t < 30 ; t++ ){
			LL bits = 0ll;
			for(LL n=0 ; n < N ; n++ ){
				if( s[n][t] ){
					bits |= (1ll << n);
					bits |= dp[n];
				}
			}
			for(LL n=0 ; n < N ; n++ ){
				if( s[n][t] ){
					dp[n] |= bits;
				}
			}
			// 全員が地図を持っているかチェック
			bool flag = false;
			for(LL n=0 ; n < N ; n++ ){
				if( dp[n] == ((1ll << N) - 1ll) ){
					flag = true;
					break;
				}
			}
			// 全員が地図を持っているとき
			if( flag ){
				ans = t+1;
				break;
			}
		}
		cout << ans << endl;
	}
}

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

#define mkp make_pair
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

ll dp[5005][5005];

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<pair<int,int>> v;
  int ma=0;
  int now=0;
  int sx=0,sy=0;
  while(now<N){
    int mi=A[now],mit=now;
    for(int j=now;j<N;j++){
      if(mi>A[j]){
        mi=A[j];
        mit=j;
      }
    }

    bool ok=true;
    for(int j=now;j+1<mit;j++){
      if(A[j]>A[j+1]) ok=false;
    }
    if(ok==false){
      cout<<0<<endl;
      return 0;
    }

    if(mi<ma){
      sx++;
      sy+=mit-now;
      now=mit+1;
    }else{
      if(now>0) v.push_back(mkp(sx,sy));
      sx=1;
      sy=mit-now;
      now=mit+1;
    }

    for(int j=0;j<=mit;j++) ma=max(ma,A[j]);
  }
  v.push_back(mkp(sx,sy));

  dp[0][0]=1;
  for(int i=0;i<v.size();i++){
    int x=v[i].first;
    int y=v[i].second;
    for(int j=0;j<=N;j++){
      if(j+x<=N) add(dp[i+1][j+x],dp[i][j]);
      if(j+y<=N) add(dp[i+1][j+y],dp[i][j]);
    }
  }

  ll ans=0;
  for(int j=0;j<=N;j++){
    if(j<=M&&N-j<=M) add(ans,dp[v.size()][j]);
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 198768
#include<iostream>
#include<string.h>

using namespace std;

int main(void)
{
	char word[1000][32];
	char tmp[32];
	int length[1000];
	int freq[1000]={0};
	int maxlen=0;
	int maxfreq=0;
	int wordnum=0;
	while(cin>>tmp)
	{
		int i;
		for(i=0;i<wordnum;i++)
		{
			if(strcmp(word[i],tmp)==0)
			{
				break;
			}
		}
		strcpy(word[i],tmp);
		wordnum++;
		freq[i]++;
		length[i]=0;
		for(int j=0;word[i][j]!='\0';j++)
		{
			length[i]++;
		}
		if(freq[maxfreq]<freq[i])
		{
			maxfreq=i;
		}
		if(length[maxlen]<length[i])
		{
			maxlen=i;
		}
	}
	cout<<word[maxfreq]<<" "<<word[maxlen]<<endl;
}

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

const int MAXN = 301;

int N;
double lgN;
double expected[MAXN][MAXN][MAXN];

double solve(int x, int y, int z){
		if(x < 0 || y < 0 || z < 0) return 0;
		if(expected[x][y][z] != -1) return expected[x][y][z];
		if(!x && !y && !z) return expected[0][0][0] = 0;
		int T = x+y+z;
		double lT = log(T);
		//expected to remove non-zero = N/T
		double expect = exp(lgN - lT);
		//calc probabilities for 3,2,1 (i.e. solve_next*P(i)/P(non))
		expect += exp(log(x) - lT + log(solve(x-1, y+1, z)));
		expect += exp(log(y) - lT + log(solve(x, y-1, z+1)));
		expect += exp(log(z) - lT + log(solve(x, y, z-1)));
		return expected[x][y][z] = expect;
}

int main(){
		for(int i = 0; i < MAXN; i++){
				for(int j = 0; j < MAXN; j++){
						for(int k = 0; k < MAXN; k++){
								expected[i][j][k] = -1;
						}
				}
		}
		cin >> N;
		lgN = log(N);
		int c3 = 0, c2 = 0, c1 = 0;
		for(int i = 0; i < N; i++){
				int x;
				cin >> x;
				if(x == 3) c3++;
				else if(x == 2) c2++;
				else if(x == 1) c1++;
		}
		cout << setprecision(15) << solve(c3,c2,c1) << endl;
		return 0;
}


Measured memory_bytes: 213504
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
using namespace std;
/*
int main(){
    int N, K;
    cin >> N >> K;

    int64_t ans = N * N;
    for(int b = 1; b <= N; ++b){
        int c = N / b;
        ans -= c * min(b, K);
        cout << b << " " << N * N - ans << endl;
        if(N >= (c+1) * b && N < (c+1) * b + K){
            ans -= N - (c+1) * b;
        }
        cout << b << " " << N*N - ans << endl;
    }
    cout << ans << endl;
}*/

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

    int64_t ans = 0;
    for(int b = K + 1; b <= N; ++b){
        int c = N / b;
        ans += c * (b - K);
        if(K == 0) --ans;
        if(b * c + K <= N){
            ans += N - (b * c + K) + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    long long d;
    scanf("%d%lld", &n, &d);
    d = d * d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (1LL * x * x + 1LL * y * y <= d) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

typedef long long ll;

int main() {
    string s;
    int left, right;
    int ans = 0;
    
    cin >> s;
        
    left = 0;
    right = s.size() - 1;
    while (left<=right) {
        if (s[left] != s[right]) {
            if (s[left] == 'x') {
                left++;
                ans++;
            } else if (s[right] == 'x') {
                right--;
                ans++;
            } else {
                ans = -1;
                break;
            }
        } else {
            left++;
            right--;
        }
    }

    cout << ans << endl;
}


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

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> b.at(i);
    for(int B : b) {
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(a.at(i).at(j) == B) {
                    a.at(i).at(j) = 0;
                }
            }
        }
    }
    bool c = 0;
    if(a.at(0).at(0) == a.at(0).at(1) && a.at(0).at(1) == a.at(0).at(2)) {
        c = 1;
        goto END;
    }
    if(a.at(1).at(0) == a.at(1).at(1) && a.at(1).at(1) == a.at(1).at(2)) {
        c = 1;
        goto END;
    }
    if(a.at(2).at(0) == a.at(2).at(1) && a.at(2).at(1) == a.at(2).at(2)) {
        c = 1;
        goto END;
    }
    if(a.at(0).at(0) == a.at(1).at(0) && a.at(1).at(0) == a.at(2).at(0)) {
        c = 1;
        goto END;
    }
    if(a.at(0).at(1) == a.at(1).at(1) && a.at(1).at(1) == a.at(2).at(1)) {
        c = 1;
        goto END;
    }
    if(a.at(0).at(2) == a.at(1).at(2) && a.at(1).at(2) == a.at(2).at(2)) {
        c = 1;
        goto END;
    }
    if(a.at(0).at(0) == a.at(1).at(1) && a.at(1).at(1) == a.at(2).at(2)) {
        c = 1;
        goto END;
    }
    if(a.at(0).at(2) == a.at(1).at(1) && a.at(1).at(1) == a.at(2).at(0)) {
        c = 1;
        goto END;
    }
END:
    if(c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
n = int(input())
t_pre = 0
x_pre = 0
y_pre = 0
can = 0
for i in range(n) :
    s = input().split(" ")
    t = int(s[0])
    x = int(s[1])
    y = int(s[2])
    sa = t - t_pre - ((x - x_pre) + (y - y_pre))
    if sa >= 0 and sa % 2 == 0 :
        can = 1
    else :
        can = 0
        break
    t_pre = t
    x_pre = x
    y_pre = y
if bool(can) :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=998244353ll,inf=1000000000000000000ll;
const int N=200005;
vector<int>e[N];
int a[N];
void dfs(int v,int f){
	int u,i;
	for(i=0;i<e[v].size();++i){
		u=e[v][i];
		if(u!=f){a[u]+=a[v];dfs(u,v);}
	}
}
int main(){
	int n,q,i,v,u;
	scanf("%d%d",&n,&q);
	for(i=1;i< n;++i){scanf("%d%d",&v,&u);e[v].push_back(u);e[u].push_back(v);}
	while(q--       ){scanf("%d%d",&v,&u);a[v]+=u;}
	dfs(1,0);
	for(i=1;i<=n;++i)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 27264
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
    string a;
    cin>>a;
    int d=753;
    rep(i,a.size()-2){
      int t=(a[i]-'0')*100+(a[i+1]-'0')*10+(a[i+2]-'0');
      d=min(abs(t-753),d);
      if(d==0)break;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#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>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int N, K;
  cin >> N >> K;

  vector<int> X(N);
  for (int i = 0; i < N; i++)
    cin >> X[i];

  int res = 0;
  for (int i = 0; i < N; i++) {
    if (X[i] < abs(X[i] - K))
      res += X[i] * 2;
    else
      res += abs(K - X[i]) * 2;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
//ll const INF=1001001001;
ll const INF=1001001001001001001;
ll const MOD=1000000007;

ll N;
ll A[200000];
ll v[20][20];

int main(){
    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        rep(i,s.size()){
            if(s[i]=='.'){
                repn(j,9){
                    if(i+j<s.size()) continue;
                    else s+='0';
                }
                goto x;
            }
        }
        rep(i,9) s+='0';
        x:;
        ll a=0;
        rep(i,s.size()){
            if(s[i]!='.') a=a*10+(s[i]-'0');
            else continue;
        }
        A[i]=a;
    }

    vector<P> cnt(N);
    //vector<vector<ll>> v(20,vector<ll>(20,0));
    rep(i,N){
        ll two=0, five=0;
        ll a=A[i];
        while(a%2==0 && two<18) a/=2, two++;
        while(a%5==0 && five<18) a/=5, five++;
        //cout<<two<<' '<<five<<endl;
        cnt[i]=P(two,five);
        v[two][five]++;
    }
    //rep(i,19){rep(j,19){cout<<v[i][j]<<' ';}cout<<endl;}
    for(int i=18;i>=0;i--){
        for(int j=18;j>=0;j--){
            v[i][j]+=v[i][j+1]+v[i+1][j]-v[i+1][j+1];
        }
    }
    //cout<<endl;
    //rep(i,19){rep(j,19){cout<<v[i][j]<<' ';}cout<<endl;}

    ll ans=0;
    rep(i,N){
        ll two=18-cnt[i].first;
        ll five=18-cnt[i].second;
        ll res=v[two][five];
        if(two<=cnt[i].first && five<=cnt[i].second) res--;
        //cout<<i<<' '<<res<<endl;
        ans+=res;
    }
    ans/=2;

    cout<<ans<<endl;
}

Measured memory_bytes: 7780
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	bool ok = false ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		if(a&1) ok = true ;
	}
	cout << (ok?"first":"second") << endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int K, X;
    cin >> K >> X;
    int A = X - K + 1;

    for (int a = 0; a < 2 * K-1; a++){
        cout << A;
        cout <<" ";
        A++;
    }
    return 0;
}


Measured memory_bytes: 768
mod = 10**9 + 7

N,M = map(int,input().split())
S = input().split()
T = input().split()

dp = [[-1]*(M+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    dp[i][0] = 1
for j in range(1,M+1):
    dp[0][j] = 1

for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = dp[i][j-1] + dp[i-1][j]
        else:
            dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]
        dp[i][j] %= mod

ans = dp[N][M]
print(ans)

Measured memory_bytes: 72540
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p[3];

  cin >> p[0] >> p[1] >> p[2];

  sort(p, p + 3);

  cout << p[0] + p[1] + (10 * p[2]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long k,sum=0,a[500001],b[500001],minn=99999999;
int main()
{
    scanf("%lld",&k);
    for(register int i=1;i<=k;++i){
    	cin>>a[i];
    	b[i]=a[i];
    }
    sort(a+1,a+1+k);
    for(register int i=a[1];i<=a[k];++i){
    	for(register int j=1;j<=k;++j)
    		sum+=(i-b[j])*(i-b[j]);
    	if(sum<minn)
    		minn=sum;
    	sum=0;
	}
    cout<<minn<<endl;
}

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

int main() {
  int n;
  cin >> n;
  
  int count = 0;
  int ans = -1;
  
  for (int i = 0; i < n; i++) {
    int a,b;
    cin >> a >> b;
    
    if (a == b) {
      count++;
      ans = max(ans,count);
    }
    
    else count = 0;
    
  }
  if (ans > 2) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}

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



int main()
{
	long long N;
	cin >> N;

	long long sam=0;

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

		if (i % 3 == 0) {
			continue;
		}
		if (i % 5 == 0) {
			continue;
		}

		sam += i;

	}
	cout << sam;

}


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

int main() {
    int n,ans=1;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ud=0;
    if(n<3){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 1; i < n; i++) {
        if(ud==1){
            if(a[i]<a[i-1]){
                ans++;  
                ud=0;
            }   
        }
        else if(ud==-1){
            if(a[i]>a[i-1]){
                ans ++;
                ud=0;
            }
        }
        else if(ud==0){
            if(a[i]<a[i-1]){
                ud=-1;
            }
            else if(a[i]>a[i-1]){
                ud=1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3732
import java.util.*;

import javax.xml.crypto.Data;

import java.math.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] k = new int[n];
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			p[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			int s = k[i];
			int now = 0;
			while(s != 0) {
				now %= p[i];
				now++;
				s--;
			}
			System.out.println(now);
		}
	}
	
}

Measured memory_bytes: 20624
#!/usr/bin/ruby
#encoding "UTF-8"

class Answer
  def initialize(ans)
    @ans = ans
  end

  def ans
        print @ans

  end
end
h,a = gets.split.map(&:to_i)
# h = gets.to_i
# a = gets.to_i

i = 0

while(h>0)
  h-=a
  i+=1
end

ans = Answer.new(i)
ans.ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n, c; cin >> n >> c;
  //xr[i] =  原点から右へ歩き，i個取ったときに移動した距離
  //xl[i] =  原点から左へ歩き，i個取ったときに移動した距離
  //vsum[i] = v[1] + ... + v[i]
  //vr[i] =  vsum[i] - xr[i] 原点から右へ歩きi個とったときの実質スコア
  //vl[i] =  vsum[n]-vsum[n-i]-xl[i] 原点から左へ歩きi個とったときの実質スコア
  vector<ll> xr(n+2,0), xl(n+2,0), vsum(n+1,0), vr(n+2,0), vl(n+2,0);
  xr[n+1] = c; xl[n+1] = c; 
  REP(i,n) {
    ll v; cin >> xr[i+1] >> v;
    vsum[i+1] = vsum[i] + v;
    vr[i+1] = vsum[i+1] - xr[i+1];
  }
  REP(i,n){
    xl[i+1] = c - xr[n-i];
    vl[i+1] = vsum[n]-vsum[n-i-1]-xl[i+1];
  }
  ll ans = 0;
  ll vlmax = 0, vrmax = 0;//左からl個とる条件下で原点から右へ行く場合の実質スコアのmax（左で往復する場合，右で往復する場合）
  IREP(l,n+1){
    ll e = 0;
    //左からl個とる
    e += vl[l];
    // i) 左で往復する場合
    e -= xl[l];
    // 右からとる
    e += vlmax;
    ans = max(ans,e);
    // vlmax更新
    ll idx = n-l+1;
    vlmax = max(vlmax,vr[idx]);
    // ii) 右で往復する場合
    //左からとる
    e = vl[l];
    //右からとる
    e += vrmax;
    ans = max(ans,e);
    //vrmax更新
    vrmax = max(vrmax,vr[idx]-xr[idx]);
  } 
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

#define INF 1e16

ll n;
vector<ll> g[1010];
ll x[1010];
bool dp[2][10010];

P dfs(ll v,ll pre){
  vector<P> a;
  ll sum=0;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    P tmp=dfs(nv,v);
    if(tmp==P(-1,-1))return P(-1,-1);
    a.push_back(tmp);
    sum+=tmp.fi+tmp.se;
  }
  ll m=a.size();
  memset(dp,0,sizeof(dp));
  ll crt=0,nxt=1;
  dp[crt][0]=true;
  rep(i,m){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    for(ll j=10005;j>=0;j--){
      if((j-a[i].fi>=0&&dp[crt][j-a[i].fi])||(j-a[i].se>=0&&dp[crt][j-a[i].se]))dp[nxt][j]=true;
    }
    swap(crt,nxt);
  }
  ll res=INF;
  rep(j,10005){
    if(j<=x[v]&&dp[crt][j])minch(res,sum-j);
  }
  if(res==INF)return P(-1,-1);
  return P(res,x[v]);
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  repl(i,1,n){
    ll p;
    cin>>p;
    p--;
    g[p].push_back(i); g[i].push_back(p);
  }
  rep(i,n)cin>>x[i];
  P res=dfs(0,-1);
  if(res==P(-1,-1))cout<<"IMPOSSIBLE"<<endl;
  else cout<<"POSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int vals[200200];

int tmp[200200];

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", vals + i);
	for(int i = 0; i < N; ++i) tmp[i] = vals[i];
	sort(tmp, tmp + N);
	int id = N / 2 - 1;
	for(int i = 0; i < N; ++i){
		if(vals[i] < tmp[id + 1]) printf("%d\n", tmp[id + 1]);
		else printf("%d\n", tmp[id]);
	}
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
int main(){
  int a,b,c,i;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){i=a;a=b;b=i;}
  if(b>c){i=b;b=c;c=i;}
  if(a>b){i=a;a=b;b=i;}
  

  printf("%d %d %d\n",a,b,c);
  
  return 0;
}

Measured memory_bytes: 596
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    scanner.use {
        println(winner(0, arrayOf(it.next(), it.next(), it.next())))
    }
}

fun winner(turn: Int, S: Array<String>): String {

    while (true) {
        if (S[turn] == "") return ('A' + turn).toString()
        else {
            val nextTurn: Int = S[turn].substring(0, 1).codePointAt(0) - "a".codePointAt(0)
            S[turn] = S[turn].substring(1)
            return winner(nextTurn, S)
        }
    }
}

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

long long n,xx,sum,modz,memo[5005][5005];
string s;

long long pangkat(long long x, long long y){
  if(y==1) return x;
  else if(y==0) return 1;
  else{
  	long long tmpz;
  	tmpz = pangkat(x,y/2)%modz;
  	tmpz = (tmpz*tmpz)%modz;
  	if(y%2==1) tmpz = (tmpz*x)%modz;
  	return tmpz;
  }
}

long long dp(int a, int b){
  if(a<0) a=0;
  if(b==0){
  	if(a==xx) return 1;
  	else return 0;
  } else if(memo[a][b]!=-1) return memo[a][b];
  else{
  	long long tmp;
  	tmp = 2*dp(a+1,b-1)+dp(a-1,b-1);
  	tmp %= modz;
  	memo[a][b] = tmp;
  	return tmp;
  }
}

int main(){
  scanf("%lld", &n);
  modz = 1e9+7;
  cin >> s;
  xx = s.length();
  memset(memo,-1,sizeof memo);
  sum = dp(0,n);
  //cout << sum << endl;
  long long bagi = pangkat(2,xx);
  //cout << bagi << endl;
  long long hh = 1e9+5;
  bagi = pangkat(bagi,hh);
  sum = (bagi*sum)%modz;
  printf("%lld\n", sum);
}

Measured memory_bytes: 196224
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb push_back

const int N = 2e6 + 7;
ll n,m,k,ans,cur,ar[N];
ll sum,a,b,c,d;
string str;
vector<ll> v;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);

	// freopen("../in.txt","r",stdin);
	// freopen("../out.txt","w",stdout);
	
	cin >> a >> b;
	cout << max({a-b,a+b,a*b});


	// read question and limits again
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  double v[n];
  for (int i = 0; i < n; i++){
    scanf("%lf", &v[i]);
  }
  
  for (int i = 0; i < n - 1; i++){
    for ( int j = n - 1; j > i; j--){
      if (v[j] > v[j - 1]){
        double temp = v[j];
        v[j] = v[j - 1];
        v[j - 1] = temp;
      }
    }
  }
  
  double ans = 0;
  for (int i = 0; i < n - 1; i++){
    ans += v[i] / pow(2, i + 1);
  }
  ans += v[n - 1] / pow(2, n - 1);
  
  printf("%f\n", ans);
  return 0;
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

class Construction {
    public:
        // cannot pass x between [s, t].
        int s;
        int t;
        int x;
};

vector<Construction> constructions;
vector<int> D;
vector<int> ans;

void solve(const int N, const int Q) {
    set<pair<int, int>> people;
    for (int i = 0; i < Q; i++) {
        people.insert({D[i], i});
    }

    for (int i = 0; i < N; i++) {
        Construction cons = constructions[i];
        int s = max(0, cons.s - cons.x);
        int t = max(0, cons.t - cons.x);
        auto p1 = people.lower_bound({s, -1});
        auto p2 = people.upper_bound({t, INF});

        set<pair<int, int>> should_delete;
        for (auto p = p1; p != p2; p++) {
            chmin(ans[p->second], cons.x);
            should_delete.insert(*p);
        }
        for (auto &p : should_delete) {
            people.erase(p);
        }
    }
}

int main(void) {
    int N, Q;
    cin >> N >> Q;

    constructions.resize(N);
    for (int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        t--;
        constructions[i].s = s;
        constructions[i].t = t;
        constructions[i].x = x;
    }
    sort(constructions.begin(), constructions.end(), [](const auto &a, const auto &b) {
            return a.x < b.x;
            });

    D.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    ans.resize(Q, INF);

    solve(N, Q);

    for (int i = 0; i < Q; i++) {
        if (ans[i] == INF) {
            cout << "-1" << endl;
        } else {
            cout << ans[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	ll n,m;
	cin >> n >> m;
	ll flg[n],c[n];
	for(int i=0;i<n;i++)
		flg[i]=0;
	flg[0]=1;
	for(int i=0;i<n;i++)
		c[i]=1;
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		x--;y--;		
		c[x]--;c[y]++;
		if(flg[x]==1)
			flg[y]=1;
		if(c[x]==0){
			flg[x]=0;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(flg[i]) ans++;
		
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792