akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, A, B; cin >> N >> A >> B;

    int MA = min(A, B), MI = max(0LL, A + B - N);
    cout << MA << " " << MI << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	string s;
	bool flag = true;
	cin >> s;


	REP(i, SZ(s))
	{
		if (!(i & 1))
		{
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
				continue;
			else
				flag = false;
		}
		else
		{
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
				continue;
			else
				flag = false;
		}

		if (!flag)
			break;
	}


	if (flag)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		if (s.size() % 2 == 1) {
			cnt++;
		}
	}
	dump(cnt);
	return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,k,q;
  scanf("%d%d%d",&n,&k,&q);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int min=1000000000;
  for(i=0;i<n;i++){
    int local=a[i];
    int b[2000];
    int c[2000];
    int clen=0;
    int j;
    for(j=0;j<n;j++){
      if(a[j]<local) continue;
      int blen=0;
      while(j+blen<n && a[j+blen]>=local){
	b[blen]=a[j+blen];
	blen++;
      }
      if(blen>=k){
	qsort(b,blen,sizeof(int),cmp);
	int l;
	for(l=0;l<blen-k+1;l++) c[clen++]=b[l];
      }
      j+=blen;
    }
    if(clen>=q){
      qsort(c,clen,sizeof(int),cmp);
      min=MIN(min,c[q-1]-local);
    }
  }
  printf("%d\n",min);
}

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

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3612
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

x, n = map(int, input().split())
if n!=0: nums = set(map(int, stdin.readline().split()))

if n == 0:
    print(x)
    exit()

ans = 10**9
for i in range(10000):
    t1 = x + i if x+i not in nums else 10**4
    t2 = x - i if x-i not in nums else 10**4
    if t1!=10**4 or t2!=10**4:
        ans = min(t1, t2)
        print(ans)
        exit()

Measured memory_bytes: 77348
a = [1,2,3,4,5,6,7,8,9]
b = [1,2,3,4,5,6,7,8,9]

if __name__ == "__main__":
    for x in a:
        for y in b:
            print(x,end="")
            print("x",end="")
            print(y,end="")
            print("=",end="")
            print(x*y)
else:
    pass



Measured memory_bytes: 5576
import java.util.*

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    var N = reader.nextInt()
    var valuesMap = mutableMapOf<Int, Int>()
    var currentSum = 0L

    repeat(N){
        val readValue = reader.nextInt()
        var count = valuesMap.getOrDefault(readValue, 0)
        valuesMap.put(readValue, count + 1)
        currentSum += readValue
    }
    var Q = reader.nextInt()
    repeat(Q){
        val b = reader.nextInt()
        val q = reader.nextInt()
        if(valuesMap.containsKey(b)){
            val bNum = valuesMap.getOrDefault(b, 0)
            val qNum = valuesMap.getOrDefault(q, 0)
            
            valuesMap.put(q, qNum + bNum)
            currentSum += (q - b)*bNum
            valuesMap.remove(b)
        }
        println(currentSum)
    }
}

Measured memory_bytes: 67032
function sum_array(arr){
  var sum=0;
  var i=0
  while(i<arr.length){
    sum = sum + arr[i];
    i=i+1
  }
  return sum;
}

function main(input) {
  const inputs = input.split('\n');
  const counts = inputs[0].split(' ').map( x => parseInt(x, 10) );

  const n = counts[0];
  const k = counts[1];

  const input_numbers = inputs[1].split('').map( x => parseInt(x, 10) );

if(n==1){
  console.log(1);
  return;
}

  var compressed_numbers = [];
  if(input_numbers[0]==0){compressed_numbers=[0];}

  var pre_count = 1;
  var pre_number=input_numbers[0];

  pre_numbers = [input_numbers[0]];
  for(var  i=1 ; i<n ; i=i+1){
    if(pre_number!=input_numbers[i]){
      compressed_numbers.push(pre_count);
      pre_count = 1;
      pre_number = input_numbers[i]
    }else{
      pre_count = pre_count+1;
    }
  }
  compressed_numbers.push(pre_count);

  var accumulation_sum_array = [0];
  for(var i=0;i<compressed_numbers.length;i++){
    accumulation_sum_array[i+1] = accumulation_sum_array[i] + compressed_numbers[i]
  }

//console.log(compressed_numbers);
//console.log(accumulation_sum_array);

  var answer=0;
  var sub_array=[];
  const a_a_length = accumulation_sum_array.length;
  const fetch_count = k*2+1;
  for(var  i=0 ; i<compressed_numbers.length ; i+=2){
    // k * 2 + 1 要素をとってくる
    if( i+fetch_count > a_a_length-1 ){
      answer = Math.max(accumulation_sum_array[a_a_length-1] - accumulation_sum_array[i], answer)
    } else {
      answer = Math.max(accumulation_sum_array[i+fetch_count] - accumulation_sum_array[i], answer)
    }
  }

  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15156
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#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)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;

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

  n %= 10;
  string res = "hon";
  if(n == 3) res = "bon";
  else if(n == 0 || n == 1 || n == 6 || n == 8) res = "pon";

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextInt();
        var B = sc.nextInt();
        var C = sc.nextInt();
        var D = sc.nextInt();
        WriteLine(Max(A * B, C * D));
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int64_t L = static_cast<int64_t>(S.length());
  auto result = (S[L - 1] == 's') ? (S + string("es")) : (S + string("s"));
  cout << result << endl;
  return 0;
}


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

bool solve(){
    string s;
    int q;
    cin >> s >> q;
    deque<char> que;
    for(auto c:s){
        que.push_back(c);
    }
    int rev = 0;
    for(int i=0;i<q;i++){
        int t;
        cin >> t;
        if(t == 1) rev ^= 1;
        else{
            int f;
            char c;
            cin >> f >> c;
            f--;
            if(f^rev) que.push_back(c);
            else que.push_front(c);
        }
    }
    if(rev){
        reverse(que.begin(), que.end());
    }
    for(auto c : que){
        cout << c;
    }
    cout << endl;
    return false;
}

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

Measured memory_bytes: 896
N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int A[3005];
vector<int> pathes[3005];
int state[3005];

void search(int from) {
    if(state[from] != 0) return;
    state[from] = -1;
    for(int i = 0; i < pathes[from].size(); i++) {
        int to = pathes[from][i];
        cerr << "FROM " << from << " TO " << to << endl;
        search(to);
        if(state[to] == -1) state[from] = 1;
    }
    return;
}

int main() {
    //cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if(A[a] > A[b]) pathes[a].push_back(b);
        if(A[b] > A[a]) pathes[b].push_back(a);
    }
    vector<int> ans;
    for(int i = 1; i <= N; i++) {
        search(i);
        if(state[i] == 1) ans.push_back(i);
        //cerr << i << " " << state[i] << endl;
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if(i + 1 < ans.size()) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
w = input()
d = {}
for i in range(len(w)):
    if w[i] in d.keys():
        d[w[i]] += 1
    else:
        d[w[i]] = 1
flg = True
for v in d.values():
    if v % 2 != 0:
        flg = False
        break
print('Yes' if flg else 'No')

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

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

  vector<int> A(K);
  for (int i = 0; i < K; i++) cin >> A.at(i);

  int cnt = N;

  while (1) {
    bool flag = true;
    while (cnt > 0) {
      int num = cnt % 10;
      for (int i = 0; i < K; i++) {
        if (num == A.at(i)) {
          flag = false;
          break;
        }
      }
      cnt /= 10;
    }
    if (flag) break;
    N++;
    cnt = N;
  }

  cout << N << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

int	diff(int a, int b)
{
	if (a < b)
		return (b - a);
	else
		return (a - b);
}

void ft_sort(int *a, int n)
{
	int i = 0;
	int j;
	int tmp;
	while (i < n)
	{
		j = i + 1;
		while (j < n)
		{
			if (a[i] < a[j])
			{
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
			j++;
		}
		i++;
	}
}

int main(void)
{
	int alice = 0;
	int bob = 0;
	int n;
	scanf("%d", &n);
	int a[n + 1];
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	ft_sort(a, n);
	i = 0;
	while (i < n)
	{
		// printf("%d ", a[i]);
		if (i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];
		i++;
	}
	printf("%d", diff(alice, bob));
	return (0);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n;
signed main() {
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "E869120") ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3208
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B,C,D,E,F;
	scan(A);scan(B);scan(C);scan(D);scan(E);scan(F);
	A*=100; B*=100;
	int waternum[900]={0};
	vint watermass;
	rep(i,F/A+1){
		rep(j,F/B+1){
			if(i+j==0) continue;
			if(i*A+j*B<F){
				waternum[i*(A/100)+j*(B/100)]++;
				if(waternum[i*(A/100)+j*(B/100)]==1) watermass.push_back(i*A+j*B);
			}
		}
	}
	double noudomax=-1;
	int maxwater,maxsuger;
	rep(i,watermass.size()){
		int sugerlimit=min(F-watermass[i],watermass[i]/100*E);
		rep(j,F/C+1){
			rep(k,F/D+1){
				if(j*C+k*D<=sugerlimit&&((double)(j*C+k*D)/watermass[i]>noudomax)){
					noudomax=(double)(j*C+k*D)/watermass[i];
					maxwater=watermass[i];
					maxsuger=j*C+k*D;
				}
			}
		}
	}
	printf("%d %d\n",maxwater+maxsuger,maxsuger);
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: i64,
        xy: [(i64, i64); n]
    }

    println!(
        "{}",
        xy.into_iter()
            .filter(|&(x, y)| {x * x + y * y <= d * d})
            .count()
    )
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll sm[500005], a[500005], ans;
int i;
int main() {
	cin >> n;
	ans = 1e18;
	for(i = 1; i <= n; ++i) cin >> a[i];
	for(i = 1; i <= n; ++i) sm[i] = sm[i - 1] + a[i];
	for(i = 0; i <= n; ++i) {
		ans = min(ans, abs(sm[i] - (sm[n] - sm[i])));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	int a = 0;
	double ms = (double)w * h / 2;
	if (w == x + x and h == y + y) a = 1;
	cout << fixed << setprecision(9) << ms;
	cout << " " << a;
}

Measured memory_bytes: 3760
import numpy as np
from functools import reduce

S = input()
S =  [int(i) for i in list(str(S))]
t = []
for i in range(int(len(S)-2)):
    t = np.append(t, abs(int(reduce(lambda x, y: x+y, [str(x) for x in S[i:i+3]])) - 753))
print(str(int(np.min(t))))	

Measured memory_bytes: 12496
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<iostream>
using namespace std;


int main(){
    int n,a,b;
    scanf("%d",&n);
    if(n==1) printf("Hello World\n");
    else{
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  string s;
  cin >> s;
  for (int i = 0; i < 4; ++i)
    cout << s[i];
  cout << ' ';
  for (int i = 4; i < 12; ++i)
    cout << s[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
loop do
  n, x = gets.split.map(&:to_i)
  break if n.zero? && x.zero?

  count = 0
  (1..(n - 2)).each do |i|
    ((i + 1)..(n - 1)).each do |j|
      ((j + 1)..n).each do |k|
        count += 1 if i + j + k == x
      end
    end
  end
  puts count
end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)

void f(ll n, char c){
  rep(i, n){
    cout << c;
  }
}

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

    // input
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    f(tx-sx, 'R');
    f(ty-sy, 'U');
    f(tx-sx, 'L');
    f(ty-sy, 'D');

    cout << 'D';
    f(tx-sx+1, 'R');
    f(ty-sy+1, 'U');
    cout << 'L';
    cout << 'U';
    f(tx-sx+1, 'L');
    f(ty-sy+1, 'D');
    cout << 'R';
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  vector<P> A(N);
  vector<P> C(M);
  rep(i, N) cin >> A[i].first >> A[i].second;
  rep(i, M) cin >> C[i].first >> C[i].second;

  rep(i, N) {
    ll min = INF;
    ll ans = 0;
    rep(j, M) {
      ll d = abs(A[i].first - C[j].first) + abs(A[i].second - C[j].second);
      if (min > d) {
        min = d;
        ans = j;
      }
    }
    COUT(ans + 1);
  }
  return 0;
}

Measured memory_bytes: 3608
using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long MOD = 1000000007;

            long result = 1;
            var colorCount = new int[3];
            for (int i = 0; i < N; i++)
            {
                if (A[i] == colorCount[0] && A[i] == colorCount[1] && A[i] == colorCount[2])
                {
                    result *= 3;
                    result %= MOD;
                    colorCount[0]++;
                }
                else if (A[i] == colorCount[0] && A[i] == colorCount[1])
                {
                    result *= 2;
                    result %= MOD;
                    colorCount[0]++;
                }
                else if (A[i] == colorCount[1] && A[i] == colorCount[2])
                {
                    result *= 2;
                    result %= MOD;
                    colorCount[1]++;
                }
                else if (A[i] == colorCount[0])
                {
                    colorCount[0]++;
                }
                else if (A[i] == colorCount[1])
                {
                    colorCount[1]++;
                }
                else if (A[i] == colorCount[2])
                {
                    colorCount[2]++;
                }
                else result = 0;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
	int first,second;
}pp[1000005];
bool cmp(node a,node b){
	if(a.second==b.second) return a.first>b.first;
	return a.second<b.second;
}
int main(){
	int n,ans=1;
	cin>>n;
	ll a,b;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		pp[i].first=a-b;
		pp[i].second=a+b;
	}
	sort(pp+1,pp+n+1,cmp);
	ll now=pp[1].second;
	for(int i=2;i<=n;i++){
		if(pp[i].first>=now){
			ans++;
			now=pp[i].second;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
        int n, m;
        scanf("%d %d", &n, &m);
        int li = 1;
        for(int i=0; i<n; i++) li *= 10;

        int sc[m][2];
        for(int i=0; i<m; i++) scanf("%d %d", &sc[i][0], &sc[i][1]);

        for(int i=0; i<li; i++){
                std::string s = std::to_string(i);
                if(s.size()!=n) continue;
                int ok = 1;
                for(int j=0; j<m; j++){
                        if(s[sc[j][0]-1]!=sc[j][1]+'0') ok = 0;
                }
                if(ok){
                        printf("%d\n", i);
                        return 0;
                }
        }
        puts("-1");
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    bool ok=1;
    rep(i,n-1){
        if(a[i]==a[i+1]) ok=0;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

idx = 0
for b, c in BC:
  for j in range(idx, min(N, idx + b)):
    if A[j] < c:
      A[j] = c
  idx += b
print(sum(A))


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


sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)


Measured memory_bytes: 2940
#include <iostream>
#include<vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void)
{
	int N,D;
	cin >> N>>D;
	int min = 2019;
	//vector<vector<int>> X(N, vector<int>(D));
	for (int i = N; i < D; i++)
	{
		for (int j = N + 1; j <= D; j++)
		{
			if (min > (i%2019) * (j%2019) % 2019)
			{
				min = (i % 2019) * (j % 2019) % 2019;
			}
			if (min == 0)
			{
				cout << min << endl;
				return 0;
			}
		}
	}
	
	cout << min<< endl;
}

Measured memory_bytes: 256
In = input().split()

def inv_porland_math(In):
    stack = []
    for m in In:
        if(m == "+"):
            stack.append(stack.pop(-2) + stack.pop(-1))
        elif(m == "-"):
            stack.append(stack.pop(-2) - stack.pop(-1))
        elif(m == "*"):
            stack.append(stack.pop(-1) * stack.pop(-1))
        else:
            stack.append(int(m))
    return stack[0]

ans = inv_porland_math(In)
print(ans)


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

int func(int x){
  vector<int> vec(5);
  int mem;
  mem =x;
  for(int i =0;i<5;i++){
    x=mem;
    
    for(int j=0;j<i;j++){
      x /= 10;
    }
    
    x %= 10;
    vec.at(i) = x;
    
  }
  
  if(vec.at(0)==vec.at(4) && vec.at(1) == vec.at(3)){
    return 1;
  }
  else
    return 0;
}

int main(){
  int A,B;
  cin >> A >> B;
  
  int count=0;
  
  for(int i=A;i<=B;i++){
    if( func(i) == 1){
      count ++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int m,temp;
string S;

int main(){
	while(cin>>m&&m){
		int t=1,n=2,w=3,e=4,s=5,b=6;
		rep(i,m){
			cin>>S;
			if(S=="north"){temp=n;n=t;t=s;s=b;b=temp;}
			if(S=="east"){temp=e;e=t;t=w;w=b;b=temp;}
			if(S=="south"){temp=s;s=t;t=n;n=b;b=temp;}
			if(S=="west"){temp=w;w=t;t=e;e=b;b=temp;}
		}
		cout<<t<<endl;
	}
}

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

 
int main() {
  int cou=0;
  int ans=0;
  int N;
  cin>>N;
  vector<string> test1(N);
  for(int i=0;i<N;i++){
    cin>>test1.at(i);}
  int M;
  cin>>M;
  vector<string> test2(M);
  for(int i=0;i<M;i++){
    cin>>test2.at(i);}
  
  for(int i=0;i<N;i++){
    cou=0;
    for(int j=0;j<N;j++){
      if(test1.at(i)==test1.at(j)){
        cou++;}
    }
    for(int j=0;j<M;j++){
       if(test1.at(i)==test2.at(j)){
        cou--;}
    }
    if(ans<=cou){
    ans=cou;
    }
  }
  cout<<ans<<endl;}

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<map>
#include<queue>
#include<cmath>
using namespace std;

#define N 4
#define N2 16

const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

int MDT[N2][N2];

struct Puzzle
{
	int f[N2], space, MD;
	int cost;
	bool operator < (const Puzzle &p) const
	{
		for(int i = 0; i < N2; i++){
			if(f[i] == p.f[i]) continue;
			return f[i] > p.f[i];
		}
		return false;
	}
};

int getallMD(const Puzzle &p)
{
	int h = 0;
	for(int i = 0; i < N2; i++){
	if(i == p.space) continue;
		h += MDT[i][p.f[i] - 1];
	}
	return h;
}

struct State
{
	Puzzle pz;
	int estimated;
	bool operator < (const State &s) const
	{
		return estimated > s.estimated;
	}
};

int astar(Puzzle p)
{
	priority_queue<State> A;
	map<Puzzle, bool> USED;

	State initial;
	initial.pz = p;
	initial.estimated = p.MD;
	A.push(initial);
	USED[p] = true;

	Puzzle u, v;
	int sx, sy, tx, ty, r;

	while(!A.empty())
	{
		u = A.top().pz; A.pop();
		if(u.MD == 0) return u.cost;

		sx = u.space / N;
		sy = u.space % N;
		for(r = 0; r < 4; r++){
			tx = sx + dx[r];
			ty = sy + dy[r];
			if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
			v = u;
			v.MD -= MDT[tx * N + ty][u.f[tx * N + ty] - 1];
			v.MD += MDT[sx * N + sy][u.f[tx * N + ty] - 1];
			swap(v.f[sx * N + sy], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			
			if(!USED[v]){
				v.cost++;
				USED[v] = true;
				State new_s;
				new_s.pz = v;
				new_s.estimated = v.cost + v.MD;
				A.push(new_s);
			}
		}
	};
	return -1;
}

int main()
{
	
	for(int i = 0; i < N2; i++){
		for(int j = 0; j < N2; j++){
			MDT[i][j] = abs((i / N) - (j / N)) + abs((i % N) - (j % N));
		}
	}

	Puzzle in;

	for(int i = 0; i < N2; i++){
		scanf("%d", &in.f[i]);
		if(in.f[i] == 0) in.space = i;
	}
	in.cost = 0;
	in.MD = getallMD(in);

	cout << astar(in) << endl;

	return 0;
}

Measured memory_bytes: 172080
import java.util.Scanner;

public class Main {
    public static int[][] memo;
    public static char[][] grid;

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        memo = new int[h+1][w+1];
        grid = new char[h+1][w+1];
        for(int i = 1; i <= h; i++){
            String row = scanner.next();
            for(int j = 1; j <= w; j++){
                memo[i][j] = -1;
                grid[i][j] = row.charAt(j-1);
            }
        }
        memo[1][1] = 1;
        System.out.println(grid(h,w));
    }

    public static int grid(int h, int w){
//        return -1;
        if(h<1||w<1) return 0;
        if(grid[h][w]=='#') return 0;
        if(memo[h][w]!=-1) return memo[h][w];
        int res = 0;
        res += grid(h-1, w) % 1000000007;
        res += grid(h, w-1) % 1000000007;
        memo[h][w] = res % 1000000007;
        return res % 1000000007;
    }
}


Measured memory_bytes: 34952
#!/usr/bin/ruby
cx1,cy1,r1=gets.split.map(&:to_f)
cx2,cy2,r2=gets.split.map(&:to_f)
cxd=cx2-cx1
cyd=cy2-cy1
a=(cxd**2+cyd**2+r1**2-r2**2)/2
z=Math.sqrt((cxd**2+cyd**2)*r1**2-a**2)
w=cxd**2+cyd**2
f=(cyd*z).abs<1e-9 ? :to_a : :sort
puts [[(a*cxd+cyd*z)/w+cx1,(a*cyd-cxd*z)/w+cy1],[(a*cxd-cyd*z)/w+cx1,(a*cyd+cxd*z)/w+cy1]].send(f)*' '

Measured memory_bytes: 8792
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;

int main()
{
    long long int x,y,z,c,f,min;

    while(scanf("%lld",&x)==1){
        min=x;
        for(long long int i=1;i<=sqrt(x);i++){
            if(x%i==0){
                 y=x/i;
                 c=abs(y-i);
                 if(c<min){
                    min=c;
                    z=i;
                    f=y;
                 }
                 //printf("%lld\n",z+f-2);

            }
        }
        printf("%lld\n",z+f-2);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	cout << A * B;

	return 0;
}

Measured memory_bytes: 3644
N=int(input())
a=[]
for i in range(N):
	a.append(str(input()))
a=sorted(a)
a.append('A')
M=0
temp=0
ans=[]
for i in range(N):
	if a[i]==a[i+1]:
		temp+=1
	else:
		if M<temp:
			ans=[a[i]]
			M=temp
			temp=0
		elif M==temp:
			ans.append(a[i])
			temp=0
		else:
			temp=0
for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 20140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


#include<bits/stdc++.h>

using namespace std;

#include <iostream>


#define ll   long long
#define pb          push_back

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}

void _print() { cout << "]\n"; }

template<typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cout << ", ";
    _print(v...);
}


#ifdef LOCAL
#else
#define dbg(x...)
#endif

ll m;

class ESequenceSum {
public:

    void solve2(std::istream &cin, std::ostream &cout) {
        ll n, x;
        cin >> n >> x >> m;
        map<ll, ll> prv;
        vector<ll> v;
        ll ans = 0, last, s = 0;
        for (ll i = 0;; i++) {
            last = i;
            if (prv.count(x)) break;
            prv[x] = i;
            v.pb(x);
            x = x * x % m;
        }
        n -= prv[x];

        for (ll i = 0; i < prv[x]; i++)
            ans += v[i];
        for (ll j = prv[x]; j < v.size(); j++)
            s += v[j];
        ans += (n / (last - prv[x])) * s;
        n %= (last - prv[x]);
        for (ll j = prv[x]; n > 0; n--, j++) {
            ans += v[j];
        }
        cout << ans;

    }

    void solve(std::istream &cin, std::ostream &cout) {
        ll t = 1;
//            cin >> t;
        while (t--) {
            solve2(cin, cout);
        }
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ESequenceSum solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6760
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int E = in.nextInt();
		int F = in.nextInt();
		double maxP = 0;
		int maxW = 100 * A, maxS = 0;
		
		for(int i = 0; 100 * A * i <= F; i++){
			for(int j = 0; 100 * B * j <= F; j++){
				if(i == 0 && j == 0) continue;
				
				int wA = 100 * A * i;
				int wB = 100 * B * j;
				if(wA + wB > F) break;
				int e = (wA + wB) * E / 100;
				
				for(int k = 0; k * C <= e; k++){
					for(int m = 0; m * D <= e; m++){
						int sC = k * C;
						int sD = m * D;
						if(sC + sD > e) break;
						if(wA + wB + sC + sD > F) break;
						
						if(1.0 * (sC + sD) / (wA + wB + sC + sD) > maxP){
							maxP = 1.0 * (sC + sD) / (wA + wB + sC + sD);
							maxW = wA + wB;
							maxS = sC + sD;
						}
					}
				}
			}
		}
		
		System.out.println((maxW + maxS) + " " + maxS);
	}
}


Measured memory_bytes: 21972
N, M = map(int, input().split())
A = list(map(int, input().split()))
INF = 10 ** 9


def matchnum(n):
    table = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    return table[n - 1]


# dp[n] : n本使った時の桁数
dp = [0] + [-INF for _ in range(N)]
for i in range(N + 1):
    for j, a_j in enumerate(A):
        if i - matchnum(a_j) >= 0:
            dp[i] = max(dp[i], dp[i - matchnum(a_j)] + 1)

l = dp[N]
m = N
ans = []
A = sorted(A, reverse=True)
while m > 0:
    for i, a_i in enumerate(A):
        if m - matchnum(a_i) >= 0 and dp[m - matchnum(a_i)] == l - 1:
            ans.append(str(a_i))
            m -= matchnum(a_i)
            l -= 1
            break
print(''.join(ans))

Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int main()
{
    int n;
    long long a[100] = {2,1};
    cin>>n;
    for(int i=2;i<=n;i++)
        {
            a[i] = a[i-1]+a[i-2];

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

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k;
    char st[8];
    cin >> st;
    if (st[2] == st[3] && st[4] == st[5])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

N = int(input())

SP = [input().split() for i in range(N)]

for k, v in enumerate(SP):
    v.insert(0, str(k + 1))
    v[2] = int(v[2])

# 降順
SP.sort(key=itemgetter(2), reverse=True)

# 昇順
SP.sort(key=itemgetter(1))

for sp in SP:
    print(sp[0])


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#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 pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	ll int k;
	cin >> s >> k;
	ll int pos = 0;
	ll int data[50];
	for(int i = 'a'; i <= 'z'; i++){
		int m = i - 'a';
		data[m] = 'z' + 1 - i;
		// cout << data[m] << " ";
	}
	data[0] = 0;

	string ans = "";
	while(1){
		if(pos >= s.size()) break;
		int dis = data[s[pos]-'a'];
		if(k >= 0 && k >= dis){
			k -= dis;
			ans += 'a';
		}else{
			ans += s[pos];
		}
		pos++;
	}
	// cout << k << endl;
	if(k != 0){
		k %= 26;
		char t = ans[ans.size()-1];
		t = t + k;
		if(t > 'z') t-=('z'+1-'a');
		ans[ans.size()-1] = t;
	}
	// cout << k << endl;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false)

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int N, K, A[200000];
vector<INTV> Graph;
vector<bool> visit;

void dfs(int pos){
  if(visit[pos]) return;
  visit[pos] = 1;
  for(auto nx : Graph[pos]){
    dfs(nx);
  }
}

signed main(void){
  Accepted_MAGIC;
  
  cin >> N >> K;
  set<int> st;
  REP(i, N) cin >> A[i];

  Graph.resize(N-K+1);
  visit.resize(N-K+1, 0);

  REP(i, K) st.insert(A[i]);
  for(int i = K; i < N; i++){
    int mn = *st.begin();
    st.erase(A[i-K]);
    st.insert(A[i]);
    int mx = *st.rbegin();
    if(A[i-K] == mn and A[i] == mx){
      Graph[i-K].eb(i-K+1);
      Graph[i-K+1].eb(i-K);
    }
  }

  int greater[200000] = {};
  REP(i, N-1) greater[i] = (A[i+1] > A[i]);
  int sum = 0;
  REP(i, K-1) sum += greater[i];
  INTV conGreat;
  if(sum == K-1) conGreat.eb(0);
  for(int i = K-1; i < N-1; i++){
    sum -= greater[i-K+1];
    sum += greater[i];
    if(sum == K-1) conGreat.eb(i-K+2);
  }
  REP(i, (int)conGreat.size()-1){
    Graph[conGreat[i]].eb(conGreat[i+1]);
    Graph[conGreat[i+1]].eb(conGreat[i]);
  }

  int ans = 0;
  REP(i, N-K+1){
    if(!visit[i]){
      ans++;
      dfs(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 25332
#include<cstdio>
long long n,c,a[405],b[405],invs[405];
long long rankal[405][405],f[405][405];
const long long mod=1e9+7;
long long mmod(long long val,long long k){
	long long ans=1;
	for(;k;k>>=1){
		if(k&1) ans=ans*val%mod;
		val=val*val%mod;
	}
	return ans%mod;
}
long long inv(long long v){return mmod(v,mod-2);}
int main(){
	f[0][0]=1;
	long long pss=1,ans=0;
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=400;i++)
		for(int j=0;j<=c;j++)
			rankal[i][j]=rankal[i-1][j]+mmod(i,j);
	//for(int i=0;i<=400;i++) f[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=j;k>=0;k--)
				f[i][j]=(f[i-1][j-k]*((rankal[b[i]][k]-rankal[a[i]-1][k]+mod)%mod)+f[i][j])%mod;
	printf("%lld\n",f[n][c]);
	return 0;
}

Measured memory_bytes: 2688
from math import ceil


def readIntLine(n: int):
  return [int(input()) for _ in range(n)]


n, k = [int(i) for i in input().split()]
ws = readIntLine(n)

def check(p):
    cnt = 0
    for _ in range(k):
        s = 0
        while s + ws[cnt] <= p:
            s += ws[cnt]
            cnt += 1
            if cnt == n:
                return cnt
    return cnt



left = 0
right = 100000 * 10000

while right - left > 1:
    mid = (left + right) // 2

    if check(mid) >= n:
        right = mid
    else:
        left = mid


print(right)



Measured memory_bytes: 9580
ABC = list(map(int,input().split()))
red = ABC[0]
green = ABC[1]
blue = ABC[2]
K = int(input())

for i in range(K):
  if green <= red:
    green *= 2
    continue
  elif blue <= green:
    blue *= 2

if green > red and blue > green:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
#include<stdio.h>
int main(){
  int money,gohyaku,go;
  gohyaku = go = 0;
  
  scanf("%d",&money);
  gohyaku = money / 500 * 1000;
  go = money - (gohyaku / 2);
  go = go - (go % 5);
  printf("%d",gohyaku + go);
  
  return 0;
}


Measured memory_bytes: 128
R, G, B, N = gets.split.map(&:to_f)

r_max = (N / R).floor
cnt = 0
for r in 0..r_max do
    now = N - (R * r)
    g_max = (now / G).floor
    for g in 0..g_max do
        now_g = now - (G * g)
        if now_g % B == 0 then
            cnt += 1
        end
    end
end

puts cnt


Measured memory_bytes: 1788