akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char s[100005];
	scanf("%s",s+1);
	int l=strlen(s+1);
	for(int i=1;i<=l;i+=2)
	{
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

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

	W := make([]int, 0, N)
	all := 0
	for i := 0; i < N; i++ {
		var w int
		fmt.Scan(&w)
		W = append(W, w)
		all += w
	}

	sum := 0
	min := all
	for i := 0; i < N; i++ {
		sum += W[i]
		c := all - sum - sum
		if c < 0 {
			c = -c
		}
		if c < min {
			min = c
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

max_A = max(A, key=int)
max_A_number = A.index(max_A)
A.remove(max_A)
next_A = max(A, key=int)

for i in range(N):
    if i == max_A_number:
        print(next_A)
    else:
        print(max_A)


Measured memory_bytes: 12520
march = ['M', 'A', 'R', 'C', 'H']
counter = [0, 0, 0, 0, 0]
N = int(raw_input())
for i in range(0, N):
	s = raw_input()
	for j in range(0, 5):
		if s[0] == march[j]:
			counter[j] = counter[j] + 1
ans = 0
for i in range(0, 5):
	for j in range(i+1, 5):
		for k in range(j+1, 5):
			ans = ans + counter[i] * counter[j] * counter[k]

print ans

Measured memory_bytes: 5764
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

signed main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  int Maxi = 0;
  rep(i, N) {
    if (10 * i > Maxi) {
      cout << "no" << endl;
      return 0;
    }
    Maxi = max(Maxi, 10 * i + d[i]);
  }
  int Mini = 10 * (N - 1);
  rep(i, N) {
    if (Mini > 10 * (N - 1 - i)) {
      cout << "no" << endl;
      return 0;
    }
    Mini = min(Mini, 10 * (N - 1 - i) - d[N - 1 - i]);
  }
  cout << "yes" << endl;
}



Measured memory_bytes: 5212
while True:
    line = input()

    if line == '?':
        break

    a, op, b = line.split()
    a = int(a)
    b = int(b)

    if op == '?':
        break
    elif op == '+':
        ans = a + b
    elif op == '-':
        ans = a - b
    elif op == '*':
        ans = a * b
    elif op == '/':
        ans = int(a / b)
    else:
        break

    print(ans)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll x, k, q;
ll r[maxn];
ll t[maxn], a[maxn];

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

    cin>>x;
    cin>>k;
    for (int i=0; i<k; i++) {
	cin>>r[i];
    }

    cin>>q;
    for (int i=0; i<q; i++) {
	cin>>t[i]>>a[i];
    }

    auto bound = [&](ll val, ll l, ll r) {
	val = min(val, r);
	val = max(l, val);
	return val;
    };


    int ri=0;
    ll sgn = -1;
    ll lo = 0;
    ll hi = x;
    ll dx = 0;
    ll last = 0;

    // The answer is bounded between [lo,hi]. Once they converge to lo=hi, the answer is pre-determined.
    // dx is added to the initial condition a[qi], but we still bound the answer by [lo,hi].
    
    for (int qi=0; qi<q; ) {
	if (ri==k || t[qi] < r[ri]) {
	    ll res = bound(dx+a[qi], lo, hi);
	    res += sgn*(t[qi]-last);
	    res = bound(res, 0, x);
	    cout<<res<<"\n";
	    qi++;
	    
	} else {
	    ll dr = sgn*(r[ri]-last);

	    lo = bound(lo+dr, 0, x);
	    hi = bound(hi+dr, 0, x);
	    dx += dr;

	    last = r[ri];
	    ri++;
	    sgn = -sgn;	    
	}
    }
    
    
    return 0;
}


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

int main(){
  int N,A;
  cin >> N >> A;
  if(N < 1 || 10000 < N || A < 0 || A > 1000){
    cout << "error" << endl;
  	exit(0);
  }
  if(N % 500 <= A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    
    
  

Measured memory_bytes: 256
S = int(input())

d_num = 10 ** 9 + 7

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

ans = 0
if S <= 2:
    print(0)
else:
    n = S // 3
    for i in range(1, n + 1):
        if i == 1:
            ans += 1
        else:
            r = S - i * 3
            x = r + i - 1
            ans += cmb(x, r)
    ans %= d_num
    print(ans)

Measured memory_bytes: 9496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aizu
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var s = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var q = int.Parse(Console.ReadLine());
			var t = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			var count = 0;
			foreach(var value in t)
			{
				var startIndex = 0;
				var endIndex = n - 1;

				while (startIndex <= endIndex)
				{
					var index = (startIndex + endIndex) / 2;

					if (s[index] == value)
					{
						count++;
						break;
					}
					else if(s[index] < value)
					{
						startIndex = index + 1;
					}
					else
					{
						endIndex = index - 1;
					}
				}
			}

			Console.WriteLine(count);
		}
	}
}



Measured memory_bytes: 30640
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	ll mna = INF,mxa = -INF;
	ll mxb = -INF,mxc = -INF;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		mxa = max(x+y,mxa);
		mna = min(x+y,mna);
		mxb = max(x-y,mxb);
		mxc = max(y-x,mxc);
	}
	cout<<max(mxa-mna,mxb+mxc);
}



Measured memory_bytes: 3632
n, k = gets.chomp.split
nums = gets.chomp.split.map(&:to_i)

use_nums = (0..9).to_a - nums

rank_up = false

ans = []
n.each_char do |c|
  ci = c.to_i

  if rank_up
    ans << use_nums.min
  else
    found = false
    use_nums.each do |un|
      if un < ci
        next 
      elsif un == ci
        ans << un
        found = true
        break
      else
        ans << un
        found = true
        rank_up = true
        break
      end
    end
    unless found
      min = use_nums.min
      head = if min == 0
              use_nums[1]
            else
              min
            end

      if ans.size == 0
        ans << head
      else
        next_min = use_nums.select{|un| ans.last < un}.min
        unless next_min
          ans << min
        else
          ans[ans.size-1] = next_min
        end
      end

      ans << min
      rank_up = true
    end
  end
end

puts ans.join

Measured memory_bytes: 1788
n = int(input())
train_list = []
for i in range(n-1):
    train_list.append([ int(v) for v in input().split() ])

def ride(a,t):
    global train_list
    if a == n - 1:
        return t
    else:
        duration, first, interval = train_list[a]
        if t <= first:
            time = first + duration
        else:
            b = (t - first + interval - 1) // interval
            time = first + duration + interval * b
        return ride(a+1,time)

for i in range(n):
    print(ride(i,0))

Measured memory_bytes: 51436
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        ll n, k;
        cin >> n >> k;

        vector<ll> a(n), neg, zero, pos;
        REP(i, n) {
                cin >> a[i];

                if (a[i] < 0) {
                        neg.push_back(-a[i]);
                } else if (a[i] == 0) {
                        zero.push_back(a[i]);
                } else {
                        pos.push_back(a[i]);
                }
        }

        sort(neg.begin(), neg.end());
        sort(zero.begin(), zero.end());
        sort(pos.begin(), pos.end());

        auto check = [&](ll x) {
                ll c = 0;

                if (x < 0) {
                        ll nx = -x;
                        for (ll e : neg) {
                                auto itr = lower_bound(pos.begin(), pos.end(), nx / e + 1);
                                c += pos.end() - itr;
                        }
                } else if (x == 0) {
                        c = neg.size() * pos.size();
                } else {
                        for (ll e : neg) {
                                auto itr = lower_bound(neg.begin(), neg.end(), (x + e - 1) / e);
                                c += itr - neg.begin() - (e * e < x);
                        }

                        for (ll e : pos) {
                                auto itr = lower_bound(pos.begin(), pos.end(), (x + e - 1) / e);
                                c += itr - pos.begin() - (e * e < x);
                        }

                        c /= 2;

                        c += zero.size() * (neg.size() + pos.size()) + zero.size() * (zero.size() - 1) / 2;
                        c += neg.size() * pos.size();
                }

                return c < k;
        };
        
        constexpr ll inf = 1e18;
        ll l = -(inf + 1), r = inf + 1;
        
        while (r - l > 1) {
                ll m = (r + l) / 2;

                if (check(m)) {
                        l = m;
                } else {
                        r = m;
                }
        }

        cout << l << endl; 

        return 0;
}


Measured memory_bytes: 4084
// AtCode ABC 119 A
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	heisei := time.Date(2019, 5, 1, 0,0,0, 0 , time.UTC)

	S := read()
	ymd := strings.Split(S, "/")
	y, _ := strconv.Atoi(ymd[0])
	m, _ := strconv.Atoi(ymd[1])
	d, _ := strconv.Atoi(ymd[2])
	date := time.Date(y, time.Month(m), d, 0 ,0 ,0, 0, time.UTC)
	if heisei.After(date) {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}

func read() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int p[1005][3] = { 0 }, er[1005] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c, sum = 0;
		cin >> a >> b >> c;
		sum = a + b + c;
		p[i][0] = min(a, min(b, c));
		p[i][2] = max(a, max(b, c));
		p[i][1] = sum - p[i][0] - p[i][2];
	}
	for (int i = 0; i < n; i++) {
		if (er[i]==0) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					if (p[i][0] == p[j][0] && p[i][1] == p[j][1] && p[i][2] == p[j][2]) {
						er[j] = 1;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (er[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3116
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

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=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s; cin >> s;
    // RRLRL -> 0 1 2 1 1
    // RRLLLLRLRRLL -> 0 3 3 0 0 0 1 1 0 2 2 0
    // RRRLLRLLRRRLLLLL -> 0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0

    // 初期値がRかLかで分岐
    // Rであれば右にRLが見つかるまで進み、Lであれば左にRLが見つかるまで進む
    // RLの中では偶奇で分岐する

    // RRLRLについて個別に考える
    // 0: より右で最初のRLの始まりは1。1->2->1->2->...->2に落ち着く
    // 1: より右で最初のRLの始まりは1。2->1->2->1->...->1に落ち着く
    // 2: より左で最初のRLの始まりは1。1->...->1
    // 3: より右で最初のは3。3->4->3...->4に落ち着く

    // RLの開始位置を確認
    bool rl[100001];
    REP(i, s.size()-1) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            rl[i] = true;
        }
    }

    // より右のrl始点、より左のrl始点を確認
    ll right[100001];
    ll left[100001];
    ll tmp = -1;
    FORD(i, s.size()-1, 0) {
        if (i <= s.size()-2 && s[i] == 'R' && s[i+1] == 'L') {
            tmp = i;
        }
        right[i] = tmp;
    }
    FOR(i, 0, s.size()-1) {
        if (i <= s.size()-2 && s[i] == 'R' && s[i+1] == 'L') {
            tmp = i;
        }
        left[i] = tmp;
    }

    // それぞれの個数確認
    ll res[100001]; INITA(res, 0, 100000, 0);
    REP(i, s.size()) {
        // cout << i << " " << s[i] << " " << rl[i] << " " << right[i] << " " << left[i] << endl;
        if (s[i] == 'R') {
            if ((right[i] - i) % 2 == 0) {
                res[right[i]]++;
            } else {
                res[right[i]+1]++;
            }
        } else {
            if ((i-left[i]) % 2 == 0) {
                res[left[i]]++;
            } else {
                res[left[i]+1]++;
            }
        }
    }

    REP(i, s.size()) {
        if (i != 0) {
            cout << " ";
        }
        cout << res[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 6084
use std::ops::Sub;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Rem;
use std::ops::ShrAssign;
use std::ops::BitAnd;

const MOD: i64 = 1000000007;

fn main() {
    let n: i64 = read();
    let mut cn: Vec<i64> = read_vec();
    cn.sort();
    cn.reverse();
    let mut ans = 0;
    for (i, &c) in cn.iter().enumerate() {
        ans += c * (i as i64 + 2) % MOD;
        ans %= MOD;
    }
    ans *= modpow(4, n-1, MOD);
    ans %= MOD;

    println!("{:?}", ans);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

/// calculate $a^n % m$
/// a > 0, n >= 0, m > 0
pub fn modpow<T>(mut a: T, mut n: T, m: T) -> T
    where T: Sub<Output=T> + Div<Output=T> + Mul<Output=T> + Rem<Output=T> + ShrAssign + PartialOrd + BitAnd<Output=T> + Copy + From<u8>
{
    let zero = T::from(0);
    let one = T::from(1);
    let mut res = one;

    while n > zero {
        if (n & one) == one {
            res = res * a % m;
        }
        a = a * a % m;
        n >>= one;
    }

    res
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int main(){
    for(int i=0;i<1000000000;i++){
        int a,b;
        char s;
        cin >> a >> s >> b;
        if(s == '?'){
            return 0;
        }
        else if(s == '+')cout << a+b << endl;
        else if(s == '-')cout << a-b << endl;
        else if (s == '*')cout << a*b << endl;
        else cout << a/b << endl;
    }
}



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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	int T = a + b;
	REP(t, 1000) {
		ll t0 = 60 * t + c;
		ll k = t0 / T;
		ll l = k * T, r = k * T + a;
		if (l <= t0 && t0 <= r) {
			cout << t0 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 2e5 + 10, MOD = 998244353, INF = 1e9 * 1e9;

ll dp[SIZE], lst[SIZE], tree[SIZE * 4];

void upd(int v, int l, int r, int pos) {
	if (l == r - 1) {
		tree[v] = lst[l];
	}
	else {
		int mid = (l + r) / 2;
		if (pos < mid) {
			upd(v * 2 + 1, l, mid, pos);
		}
		else {
			upd(v * 2 + 2, mid, r, pos);
		}
		tree[v] = min(tree[v * 2 + 1], tree[v * 2 + 2]);
	}
}

ll ask(int v, int l, int r, int askl, int askr) {
	if (l >= askr || r <= askl) return INF;

	if (l >= askl && r <= askr) return tree[v];

	int mid = (l + r) / 2;
	return min(ask(v * 2 + 1, l, mid, askl, askr), ask(v * 2 + 2, mid, r, askl, askr));
}

int main() {
	fastInp;

	ll n;
	cin >> n;
	vector<pair<ll, ll>> vec;
	for (int i = 0; i < n; i++) {
		ll x, d;
		cin >> x >> d;
		vec.push_back({ x, d });
	}

	sort(vec.rbegin(), vec.rend());

	vec.insert(vec.begin(), { INF, 0 });
	ll pr = INF, sz = 0, ans = 1;
	dp[0] = 1;
	lst[0] = 0;
	for (int i = 1; i <= n; i++) {
		int l = 0, r = vec.size();
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (vec[mid].first >= vec[i].first + vec[i].second) {
				l = mid;
			}
			else {
				r = mid;
			}
		}
		
		lst[i] = i;
		lst[i] = min(lst[i], ask(0, 0, n + 2, l + 1, i));
		upd(0, 0, n + 2, i);

		dp[i] = (dp[lst[i] - 1] + dp[i - 1]) % MOD;
	}

	cout << dp[n];
	return 0;
}

Measured memory_bytes: 13840
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
using namespace std ;

int d[500], opt[500] ;
ll n ;

int main() {
	scanf("%lld", &n) ;
	int k = 0 ; ll tmp = n + 1 ;
	for ( ; tmp ; ++ k) if (tmp & 1LL) -- tmp, d[k] = 0 ; else tmp /= 2, d[k] = 1 ;
	int he = k, ta = he - 1 ;
	int top = 0 ;
	for (int i = k - 2 ; i >= 0; -- i) if (d[i]) opt[++ ta] = ++ top ; else opt[-- he] = ++ top ;
	printf("%d\n", k * 2 - 2) ;
	rep(i, he, ta) printf("%d ", opt[i]) ;
	rep(i, 1, k - 1) printf("%d ", i) ;

	return 0 ; 
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    string S;
    cin>>S;
    int N=S.size();
    for(int i:range(N)){
        for(int j:range(i,N+1)){
            string ret="";
            for(int k:range(N)){
                if(!(i<=k&&k<j))ret.push_back(S[k]);
            }
            if(ret=="keyence"){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;

    return 0;
}

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

using namespace std;

long long a,b,c,d;
string s,q;

int main() 
{
    long long a;
    cin>>a;
    long long x = 100;
    while (x<a){
        x=x+0.01*x;
        b++;
    }
    cout<<b;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		long R = 0;
		if(A + B >= K){
			R = Math.min(K, A);
		}else{ // A + B < K
			R = A;
			K -= A + B;
			R -= K;
		}
		System.out.println(R);
	}	
}


Measured memory_bytes: 27084
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    string a;
    set<string> s;
    f(i,n){
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    

    


    return 0;
}



Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
n,m = map(int,input().split())
xlist = list(map(int,input().split()))

xlist.sort()
ylist=[]

for i in range(1,m):
    ylist.append(xlist[i]-xlist[i-1])

ylist.sort()
a=0
for i in range(0,m-n):
    a+=ylist[i]
print(a)



Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<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 ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    ll n,k;
    cin >> n>> k;
    vint p(n);
    cin >> p;
    vll c(n);
    cin >> c;
    vector<vint> G(n);
    REP(i, n) {
        --p[i];
        G[i].push_back(p[i]);
    }
    vector<bool> memo(n, false);
    ll ans = LLONG_MIN;
    REP(i,n) {
        if (memo[i] == false) {
            vll scores;
            int now = i;
            ll tot = 0;
            while (memo[now] == false) {
                memo[now] = true;
                scores.push_back(c[now]);
                tot += c[now];
                now = G[now][0];
            }
            ll sz = scores.size();
            if (tot <= 0) {
                if (k / sz > 0 && tot == 0) ans = max(ans, 0LL);
                FOR(j, 1, min(k, sz)+1) {
                    ll tmp = 0;
                    REP(l, j) {
                        tmp += scores[l];
                    }
                    ans = max(ans, tmp);
                    REP(l, sz) {
                        tmp -= scores[l];
                        tmp += scores[(l + j) % sz];
                        ans = max(ans, tmp);
                    }
                }
            } else {
                ll rem = k % sz, numm = k / sz;
                if (numm >= 1) {
                    rem += sz;
                    numm -= 1;
                }
                ll tmp2 = numm*tot;
                if (tmp2 > 0) ans = max(ans, tmp2);
                FOR(j, 1, rem+1) {
                    ll tmp = tmp2;
                    REP(l, j) {
                        tmp += scores[l % sz];
                    }
                    ans = max(ans, tmp);
                    REP(l, sz) {
                        tmp -= scores[l % sz];
                        tmp += scores[(l + j) % sz];
                        ans = max(ans, tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



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

// 2つの整数の場合
long long GetLeastCommonMultiple(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return a / n * b;
}

int main() {

	ll n; cin >> n;
	vector<ll> t(n);
	for (ll i = 0; i < n; i++) {
		cin >> t[i];
	}
	//sort(t.begin(), t.end());
	long long lcm = t[0];
	for (int i = 1; i < n; i++) {
		lcm = GetLeastCommonMultiple(lcm, t[i]);
	}
	cout << lcm << endl;
	return 0;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

c.append(0)

ans = 0
ans += sum(b)

for i in range(n-1):
    if a[i+1] == a[i] + 1:
        ans += c[a[i]-1]

print(ans)





 

 


                                        




    




        


    







        



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

const int mod = 1000000007;
int h, w, k, dp[101][8];

int main() {
    cin >> h >> w >> k;
    dp[0][0] = 1;
    rep(i, h) rep(j, w) {
        rep(k, 1 << w - 1) {
            // Check if two horizontal lines are connecting
            bool ng = false;
            rep(l, w - 2) {
                if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
                    ng = true;
                }
            }
            if (ng) continue;
            if (j >= 1 && (k >> (j - 1)) & 1) {
                // The case which goes left
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= mod;
            } else if (j <= w - 2 && (k >> j) & 1) {
                // The case which goes right
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= mod;
            } else {
                // The case which goes straight
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }
        }
    }
    cout << dp[h][k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n, d;
	cin >> n >> d;
	int ans = 0;
	int r = 0;
	while(r < n){
		ans++;
		r += 2 * d + 1;
	}
	cout << ans << endl;
}

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

int main(void)
{
	int N, A, B;
	
	std::cin >> N;
	std::cin >> A;
	std::cin >> B;

	// 電車の料金
	int train = A * N;

	// タクシーの料金
	int taxi = B;
	
	std::cout << ((train < taxi) ? train: taxi) << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
 int h,w,n,count,mins;cin >> h>>w>>n;

count=0;
int ans=0;
while(count<h*w){
        mins = max(h,w);
        count =count+ mins;
        ans++;
        if(n<=count){cout <<ans <<endl;return 0;}
        
}
    
    return 0;
}





Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	a := sc.nextInt()
	s := sc.next()
	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
'''A - Buttons
https://atcoder.jp/contests/abc124/tasks/abc124_a

>>> main(5,3)
9
>>> main(3,4)
7
>>> main(6,6)
12'''


def main(a, b):
    _max = max(a, b)
    _min = min(a, b)
    amount = 0

    amount += _max
    _max -= 1

    if _max > _min:
        amount += _max
    else:
        amount += _min

    print(amount)


if __name__ == "__main__":
    a, b = map(int, input().split(' '))

    main(a, b)


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

int main(void)
{
    int N;
    int A[N];
    int i,j;
    int ans = 0;
    int diff;
    scanf("%d", &N);
    for (i=0;i<N;i++) {
        scanf("%d", &A[i]);
    }
    for (i=0;i<N-1;i++) {
        for (j=i+1;j<N;j++) {
            diff = abs(A[i]-A[j]);
            if(diff > ans) ans = diff;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
H,W=[int(i) for i in input().split()]

l_n=[input() for i in range(H)]

for i in range(W+1):
    print('#',end='')
print('#')

for i in range(H):
    print('#{}#'.format(l_n[i]))

for i in range(W+2):
    print('#',end='')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, W;
    cin >> N >> W;
    vec w(N), v(N);
    loop(i, N) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(N * 1001, 1e18));
    dp[0][0] = 0;
    loop(i, N)
    {
        loop(j, N * 1001)
        {
            if (j >= v[i])
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    ll ans = 0;
    loop(j, N * 1001)
    {
        if (dp[N][j] <= W)
            ans = max(ans, j);
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;
int main() {
	ll N;
	cin >> N;
	ll i;
	i = 0;
	while (true) {
		if (((i*(i + 1)) / 2) >= N) {
			break;
		}
		i++;
	}

	cout << i << endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;

ll mpow(ll x, ll n){ //x^n(mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll inv_mod(ll a){return mpow(a,mod-2);}
template<ll mod> class modll {
 private:
  ll _num;
  modll set(ll num){ _num = num % mod; return *this; }
 public:
  modll(){ _num = 0; }
  modll(ll num){ _num = num % mod; }

  modll operator= (ll x){ return set(x % mod); }
  modll operator+ (ll x){ return modll<mod>(_num + (x % mod)); }
  modll operator- (ll x){ return modll<mod>(_num - (x % mod)); }
  modll operator* (ll x){ return modll<mod>(_num * (x % mod)); }
  modll operator+=(ll x){ return set(_num + (x % mod)); }
  modll operator-=(ll x){ return set(_num - (x % mod)); }
  modll operator*=(ll x){ return set(_num * (x % mod)); }

  explicit operator ll() { return _num; }
  friend ostream& operator<<(ostream &os, const modll<mod> &x){ os << x._num; return os; }
};

class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

class Factorial{//階乗とその逆元を求めて計算に利用するクラス
 private:
    vector<ll> fac;
 public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
int main(){
    ll N;
    cin>>N;
    vector<ll> A(3),B(3);
    REP(i,3)cin>>A[i];
    REP(i,3)cin>>B[i];
    vector<vector<ll>> dp0(4,vector<ll>(N+1,0));
    REP(i,3) REP(j,N+1){
        if(j<A[i]) dp0[i+1][j]=dp0[i][j];
        else dp0[i+1][j]=max(dp0[i][j],dp0[i+1][j-A[i]]+B[i]-A[i]);
    }
    ll M=dp0[3][N]+N;
    vector<vector<ll>> dp1(4,vector<ll>(M+1,0));
    REP(i,3) REP(j,M+1){
        if(j<B[i]) dp1[i+1][j]=dp1[i][j];
        else dp1[i+1][j]=max(dp1[i][j],dp1[i+1][j-B[i]]+A[i]-B[i]);
    }
    cout<<dp1[3][M]+M<<endl;
}

Measured memory_bytes: 977024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 


void print_vect(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	   if (i == (int)v.size() - 1) cout << v[i];
	   else cout << v[i] << " "; 
	 }
  cout << endl;	
}

int BubbleSort(vector<int> &v){
    int ret = 0;
    int n = (int)v.size();
    for(int i = 0; i < n; i++){
	   for(int j = n - 1; j > i; j--){
		    if (v[j - 1] > v[j]){
			  swap(v[j - 1], v[j]), ret++;	
			 } 
		 }	
	 }
  return ret;	
}

void solve(){
  	int n;
  	cin >> n;
  	vector<int> v;
  	for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);	
	}
  int ret = BubbleSort(v);
  print_vect(v);
  cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3132
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	vt n;
	cin >> n;
	cout << (n - 1) * n / 2;
	return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int k, l, r;
    cin >> k >> l >> r;
    bool ans = 0;
    for(int i = l; i <= r; i++) {
        ans |= (i % k == 0);
    }
    
    if(ans) {
        cout << "OK";
    }
    else cout << "NG";

    return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);
    
    int n; cin >> n;


    cout << n*n << '\n';
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#define long long

using namespace std;

int main() {
	int n;
	cin>>n;
	float a[n],sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	float avg,ans=0;
	avg=round(sum/n);
	for(int i=0;i<n;i++){
		ans+=pow((avg-a[i]),2);
	}
	cout<<ans;
}



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

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::string T; std::cin >> N >> T;
  int L = 1; for(int i = 0; i < N; ++i) L *= 3;
  std::vector<int> W(T.size(), 0), WU(T.size()+1), D(L), P(L, 0);

  int l = 1;
  for(int n = 0; n < N; ++n) {
    std::fill_n(D.begin(), l, 0);
    std::fill_n(D.begin()+l, l, l);
    std::fill_n(D.begin()+l+l, l, l+l);
    int one = l, two = l+l, three = l*3;
    bool sOdd = false;
    WU[0] = two;
    for(int k = 0; k < T.size(); ++k) {
      if(T[k] == 'S') {
        sOdd ^= true;
        std::swap(one, two);
      } else {
        if(sOdd) {
          (D[W[k]    ] += l+l) %= (l*3);
          (D[W[k]+l  ] += l+l) %= (l*3);
          (D[W[k]+l+l] += l+l) %= (l*3);
        } else {
          (D[W[k]    ] += l) %= (l*3);
          (D[W[k]+l  ] += l) %= (l*3);
          (D[W[k]+l+l] += l) %= (l*3);
        }
      }
      // update W
      if(D[W[k+1]] == two) WU[k+1] = 0;
      else if(D[W[k+1]+l] == two) WU[k+1] = l;
      else WU[k+1] = l+l;
    }
    for(int i = 0; i < W.size(); ++i) W[i] += WU[i];
    // update P
    for(int i = l*3-1; i >= 0; --i) {
      P[i] = P[i%l] + (sOdd?(three-D[i])%three: D[i]);
    }
    l *= 3;
  }
  for(int i = 0; i < L-1; ++i) std::cout << P[i] << " ";
  std::cout << P[L-1] << std::endl;
  return 0;
}


Measured memory_bytes: 10036
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S = input()
print('yes' if len(set(list(S))) == len(S) else 'no')


Measured memory_bytes: 38384