akhauriyash/Code-Regression huggingface dataset:
<?php
  list($a, $b, $k) = explode(" ", trim(fgets(STDIN)));
  //$a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $ans = [];
  for($i=0; $i<$k; $i++){
    if($a+$i <= $b){
      $ans[$a+$i] = true;
    }
  }

  for($i=0; $i<$k; $i++){
    if($b-$k+$i+1 >= $a){
      $ans[$b-$k+$i+1] = true;
    }
  }

  $key = array_keys($ans);
  for($i=0; $i<count($key); $i++){
    echo $key[$i].PHP_EOL;
  }

Measured memory_bytes: 16236
#include <bits/stdc++.h>
int main() {
    std::vector<int> V(3);
    for(int i=0; i<3; i++) scanf("%d", &V[i]);
    std::sort(V.rbegin(), V.rend());
    int ans = V[0] * 10 + V[1] + V[2];
    printf("%d\n", ans);
}


Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
  int n,m,i,j,k,l,frag=1,s=0,t=0;
  char a[51][51],b[51][51];
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
    {
      scanf("%s",a[i]);
    }
  for(i=0;i<m;i++)
    {
      scanf("%s",b[i]);
    }
  for(i=0;i<=n-m;i++)
    {
      for(j=0;j<=n-m;j++)
	{
	  s=0;
	  for(k=i;k<m+i;k++)
	    {
	      frag = 1; t=0;
	      for(l=j;l<m+j;l++)
		{
		  if(b[s][t] != a[k][l])
		    {
		      frag = 0;
		      break;
		    }
		  t++;
		}
	      if(frag == 0)
		{
		  break;
		}
	      s++;
	    }
	  if(frag == 1)
	    {
	      printf("Yes\n");
	      return 0;
	    }
	}
    }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 4;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n+1);
    for(int i=0; i<=n; ++i)
        cin >> a[i];

    vector<long long> maxAddNode(n+1, 1);
    for(int i=1; i<=n; ++i){
        maxAddNode[i] = min(INF, maxAddNode[i-1] * 2 - a[i]);
        if(maxAddNode[i] < 0){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=n; i>0; --i)
        a[i-1] += min(maxAddNode[i-1], a[i]);

    if(a[0] != 1)
        cout << -1 << endl;
    else
        cout << accumulate(a.begin(), a.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 4792
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;
int search(int x,int y) {
	if (x == 0 || y == 0 || x == seat.size() - 1 || y == seat.size() - 1) {
		return 0;
	}

}
int main() {
	string t;
	cin >> t;
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == '?') {
			cout << "D";
		}
		else {
			cout << t[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 3372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] a = br.readLine().toCharArray();
		char[] b = br.readLine().toCharArray();
		char[] c = br.readLine().toCharArray();
		br.close();

		List<Integer> ab = matchIdx(a, b);
		List<Integer> ac = matchIdx(a, c);
		List<Integer> ba = matchIdx(b, a);
		List<Integer> bc = matchIdx(b, c);
		List<Integer> ca = matchIdx(c, a);
		List<Integer> cb = matchIdx(c, b);
		int ans = 10000;
		ans = Math.min(ans, calc(a, b, c, ab, ac, bc));
		ans = Math.min(ans, calc(a, c, b, ac, ab, cb));
		ans = Math.min(ans, calc(b, a, c, ba, bc, ac));
		ans = Math.min(ans, calc(b, c, a, bc, ba, ca));
		ans = Math.min(ans, calc(c, a, b, ca, cb, ab));
		ans = Math.min(ans, calc(c, b, a, cb, ca, ba));
		System.out.println(ans);
	}

	static int calc(char[] a, char[] b, char[] c,
			List<Integer> ab, List<Integer> ac, List<Integer> bc) {
		int ans = 10000;
		for (int i : ab) {
			int maxab = Math.max(a.length, i + b.length);
			int val = maxab + c.length;
			ans = Math.min(ans, val);
			for (int j : bc) {
				if (i + j >= a.length || ac.contains(i + j)) {
					val = Math.max(maxab, i + j + c.length);
					ans = Math.min(ans, val);
				}
			}
			int idx = Collections.binarySearch(ac, i + b.length);
			if (idx < 0) idx = ~idx;
			if (idx < ac.size()) {
				val = Math.max(a.length, ac.get(idx) + c.length);
				ans = Math.min(ans, val);
			}
		}
		return ans;
	}

	static List<Integer> matchIdx(char[] a, char[] b) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < a.length; i++) {
			boolean flg = true;
			for (int j = 0; j < b.length && i + j < a.length; j++) {
				if (a[i + j] != b[j] && b[j] != '?' && a[i + j] != '?') {
					flg = false;
					break;
				}
			}
			if (flg) list.add(i);
		}
		list.add(a.length);
		return list;
	}
}


Measured memory_bytes: 38560
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S;
	cin >> S;
	ll ch = 0;
	if (S.at(0) != 'A') {
		ch += 1000;
	}

	
	for (ll i = 1; i < S.size(); i++) {
		if (S.at(i) == 'C'&&i>1&&i<S.size()-1) {
			ch += 100;
		}
		else if(S.at(i) == 'C' && (i == 1||i==S.size()-1)) {
			ch += 1000;
		}
		else if (S.at(i) < 'a') {
			ch++;
		}
	}
	if (ch == 100) {
		cout << "AC" << endl;
		return 0;
	}
	cout << "WA" << endl; return 0;
}

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

using namespace std;

int main(){
	
	int n,k;
	
	cin >> n >> k;
	
	int a[n];
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	int b=n-1,ans=0;
	
	for(;b>0;){
		ans++;
		b-= (k-1);
	}
	
	cout << ans << endl;
	
	return 0;
	
}

Measured memory_bytes: 640
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	f = 0
	b = zeros(Int,n)
	for i in 0:n-1
		t = 0
		for j in 2*(n-i):n-i:n
			t += b[j]
		end
		if t%2 == a[n-i]
			b[n-i] = 0
		else
			b[n-i] = 1
		end
	end
	if f == 1
		println(-1)
	else
		c = Int[]
		for i in 1:n
			if b[i] == 1
				push!(c,i)
			end
		end
		l = length(c)
		println(l)
		if l >0
			for i in 1:l-1
				print(c[i], " ")
			end
			println(c[l])
		end
	end
end

main()

Measured memory_bytes: 139484
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,length=0;
            boolean first=true;
            int[] card=null;
            
            while ((line = br.readLine()) != null) {
	            if(first){
	            	length=Integer.parseInt(line)*2;
	            	card=new int[length+1];
	            	for(int k=1;k<card.length;k++){
	            		card[k]=k;
	            	}
	            	i=Integer.parseInt(br.readLine());
	            	first=false;
	            }else{
	            	int move=Integer.parseInt(line);
	            	if(move==0){
	            		int[] n=new int[length+1];
	            		for(int k=1;k<length+1;k++){
	            			if(k%2==1){
	            				n[k]=card[k/2+1];
	            			}else{
	            				n[k]=card[length/2+k/2];
	            			}
	            		}
	            		card=n.clone();
	            	}else{
	            		int[] n=new int[length+1];
	            		for(int k=move+1;k<length+1;k++){
	            			n[k-move]=card[k];
	            		}
	            		for(int k=1;k<move+1;k++){
	            			n[k+length-move]=card[k];
	            		}
	            		card=n.clone();
	            	}
	            	i--;
	            	if(i==0){
	            		for(int k=1;k<card.length;k++){
	            			System.out.println(card[k]);
	            		}
	            		break;
	            	}
	            }
            }
        }
    }
}

Measured memory_bytes: 26604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
int main(){
ll n;
cin>>n;
ll a;
ll tmp[n];
ll array[n];
ll sum=0;
for(int i=0;i<n;i++){
    cin>>a;
    tmp[i]=a;
    array[i]=a-i-1;
}
sort(array,array+n);
ll center;
if(n%2==0){
    center=round((double)(array[n/2-1]+array[n/2])/2);
}
else{
    center=array[n/2];
}
ll b=center;
ll ans=0;
for(int i=0;i<n;i++){
    ans+=abs(tmp[i]-(b+i+1));
}
cout<<ans<<endl;
}






Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<ll> divisor(ll n) {
    vector<ll> 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(begin(ret), end(ret));
    return (ret);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    auto v1 = divisor(n);
    auto v2 = divisor(n - 1);
    vector<ll> v;
    for(auto i : v1) {
        v.push_back(i);
    }
    for(auto i : v2) {
        v.push_back(i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());
    ll ans = 0;
    for(auto k : v) {
        if(k <= 1 || k > n) {
            continue;
        }
        ll now = n;
        while(now >= k) {
            if(now % k == 0) {
                now /= k;
            } else {
                break;
            }
        }
        now %= k;
        if(now == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
<?php
  list($n, $x) = explode(" ", trim(fgets(STDIN)));

  $a = [];  // 総数
  $p = [];  // パティ枚数
  $a[0] = 1;
  $p[0] = 1;
  for ($i=1; $i<=$n; $i++) {
	$a[$i] = $a[$i-1]*2+3;
    $p[$i] = $p[$i-1]*2+1;
  }

  echo getp($n, $x, $a, $p);

  function getp($n, $x, $a, $p){
    // 一番下のパン
    if($x == 1){
      if($n == 0) return 1;
      else return 0;
    }
    // 一番下のパンと真ん中のパティの間
    else if($x > 1 && $x < ($a[$n]+1) / 2){
//      echo $n." ".$x.PHP_EOL;
      return getp($n-1, $x-1, $a, $p);
    }
    // 真ん中のパティ
    else if($x == ($a[$n]+1) / 2){
      return ($p[$n]+1) / 2;
    }
    // 真ん中のパティと一番上のパンの間
    else if($x > ($a[$n]+1) / 2 && $x < $a[$n]){
      return $p[$n-1] + 1 + getp($n-1, $x-$a[$n-1]-2, $a, $p);
    }
    // 一番上のパティ
    else if($x == $a[$n]){
      return $p[$n];
    }
  }

Measured memory_bytes: 16184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, i, l[100] = {0}, r[100] = {0};
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++)
		scanf("%d%d", &l[i], &r[i]);
	int ret[40];
	memset(ret, -1, sizeof(ret));
	int flag = 1;
	for(int i = 0; i < m; i++)
	{
		if(ret[l[i]] < 0 || ret[l[i]] == r[i]) ret[l[i]] = r[i];
		else{
			flag = 0;break;
		}
	}
	if(flag)
	{
		if(n == 1){
			if(ret[1] == -1) ret[1] = 0;
			printf("%d\n", ret[1]);
		}else if(n == 2){
			if(ret[1] > 0){
				if(ret[2] == -1) ret[2] = 0;
				printf("%d%d\n", ret[1], ret[2]);
			}
			else if(ret[1] == -1){
				ret[1] = 1;
				if(ret[2] == -1) ret[2] = 0;
				printf("%d%d\n", ret[1], ret[2]);
			}
			else printf("-1\n");
		}else{
			if(ret[1] > 0){
				if(ret[2] == -1) ret[2] = 0;
				if(ret[3] == -1) ret[3] = 0;
				printf("%d%d%d\n", ret[1], ret[2], ret[3]);
			}else if(ret[1] == -1)
			{
				ret[1] = 1;
				if(ret[2] == -1) ret[2] = 0;
				if(ret[3] == -1) ret[3] = 0;
				printf("%d%d%d\n", ret[1], ret[2], ret[3]);
			}else printf("-1\n");
		}
	}else printf("-1\n");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
}

Measured memory_bytes: 3620
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //__FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n>>k;
    map<ll,ll> mp,mp2;
    for(i=0;i<n;i++){
    	ll x;
    	cin>>x;
    	mp[i+1] = x;

    }
    bool vis[n+3] = {0};
    ll cur = 1;
    vector<ll> v;
    ll x = 0;
    i = 0;
    mp2[1] = i++;
    v.PB(1);
    while(vis[cur]==0){
    	vis[cur] = 1;
    	x = mp[cur];
    	if(vis[x]) break;
    	v.PB(x);
    	cur = x;
    	mp2[x] = i++;
    }
    if(k<v.size()){
    	cout<<v[k]<<NL;
    }
    else{
    	k = k-mp2[x];
    	ll c = v.size()-mp2[x];
    	k = k%c;
    	k = k+mp2[x];
    	//cout<<c<<NL;
    	cout<<v[k]<<NL;
    }



    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 29712
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

llong f(llong x){
	return x*x*x*x*x;
}

int main(){
	llong x;
	cin>>x;
	
	for(int i=-200;i<=200;++i){
		for(int j=-200;j<=200;++j){
			if(f((llong)i)-f((llong)j)==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3628
N,C=map(int,input().split())

Dmat=[]
for i in range(C):
  array=list(map(int,input().split()))
  Dmat.append(array)
#print(Dmat)

grid_list=[{},{},{}]
for i in range(N):
  array=list(map(int,input().split()))
  for j in range(N):
    c=array[j]-1    
    mod=(i+j)%3
    if c in grid_list[mod]:
      grid_list[mod][c]+=1
    else:
      grid_list[mod][c]=1
#print(grid_list)

min_cost=10**9
for i in range(C):
  for j in range(C):
    if i==j:
      continue
      
    for k in range(C):
      if i==k or j==k:
        continue
          
      cost=0 
      for c,num in grid_list[0].items():
        cost+=Dmat[c][i]*num
      for c,num in grid_list[1].items():
        cost+=Dmat[c][j]*num
      for c,num in grid_list[2].items():
        cost+=Dmat[c][k]*num
          
      if cost<min_cost:
        #print(i,j,k,cost)
        min_cost=cost
          
print(min_cost)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

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

    }
    sort( a, a + n );
    cout << a[n / 2] - a[n / 2 - 1] << endl;
    return 0;
}



Measured memory_bytes: 640
#include<iostream>

using namespace std;

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

int main() {
  int q;
  cin >> q;
  rep (_, q) {
    int c, a, n;
    cin >> c >> a >> n;
    int ans = 0;
    rep (i, a + 1) rep (j, n + 1) {
      int nc = i * 2 + j;
      int na = i + j;
      int nn = j;
      if (nc > c) continue;
      if (na > a) continue;
      if (nn > n) continue;
      ans = max(ans, i + j + (c - nc) / 3);
    }
    cout << ans << endl;
  }
}

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

// MY TOOLS
#define let long long int
let mod = 1e9 + 7 ;
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);
#define i_upto( n ) for( int i = 0 ; i < n ; i++ )
#define ij_upto( n, m ) for( int i = 0 ; i < n ; i++ ) for( int j = 0 ; j < m ; j++ )
template<class T>
T ** array2D( let R , let C ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
	return t ;
}
template<class T>
T ** array2D( let R , let C, T value ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
    ij_upto( R, C ) t[i][j] = value ;
	return t ;
}
template<class T>
T * array1D( let N, T value ){
    T * t = new T[N] ;
    i_upto(N) t[i] = value ;
    return t ;
}
template<class T>
T * array1D( let N ){
    T * t = new T[N] ;
    return t ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M ){
	return vector<vector<T>>(N,vector<T>(M)) ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M, T Value ){
	return vector<vector<T>>(N,vector<T>(M,Value)) ;
}
#define then ;
#define vector2D( t ) vector<vector<t>>
//

void input( let arr[], let n ){
    arr[0] = 0 ;
    for( int i = 1 ; i <= n ; i++ ) cin >> arr[i] ;
}
let gcd( let a, let b ){
    if( b == 0 ) return a ;
    return gcd( b, a % b ) ;
}

class Graph{
    public:
        vector<let> * v ;
        let number_of_nodes ;
        let ans ;
        Graph( let n ){
            ans = 0 ;
            number_of_nodes = n ;
            v = new vector<let>[n+1] ;
        }
        void addEdge( let f, let t ){
            v[f].push_back(t) ;
            v[t].push_back(f) ;
        }
        vector<let> children( let f ){
            return v[f] ;
        }
        let childAt( let f, let i ){
            return v[f][i] ;
        }
        pair<let,let> DFSutil( let itr, bool * vis ){
            vis[itr] = true ;
            vector<let> childrens = this -> children( itr ) ;
            let len = childrens.size() ;
            pair<let,let> to_be_returned = {1,1} ;
            for( let i = 0 ; i < len ; i++ ){
                if( vis[this -> childAt( itr, i )] == false  ){
                    pair<let,let> temp = DFSutil( this -> childAt( itr, i ), vis ) ;
                    to_be_returned.first = (to_be_returned.first * (temp.first+temp.second)%mod)%mod ;
                    to_be_returned.second = (to_be_returned.second*temp.first)%mod ;
                }
            }
            return to_be_returned ;
        }
        let DFS(){
            auto visited = array1D<bool>( number_of_nodes+1, false ) ;
            pair<let,let> ans = DFSutil( 1, visited ) ;
            return (ans.first + ans.second)%mod ;
        }
};

// main
// write your code here
int main(){
	async ;
    let N then cin >> N ;
    Graph g(N) ;
    for( let test = 1 ; test <= N-1 ; test++ ){
        let x, y then cin >> x >> y then g.addEdge( x, y ) ;
    }
    cout << g.DFS() ;
    return 0 ;
}

Measured memory_bytes: 18888
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
double memo[305][305][305];
bool mf[305][305][305];

double DP(int a,int b,int c)
{
	if(mf[a][b][c])return memo[a][b][c];
	double res=1.0;
	if(a>0)res+=(double)a/N*DP(a-1,b,c);
	if(b>0)res+=(double)b/N*DP(a+1,b-1,c);
	if(c>0)res+=(double)c/N*DP(a,b+1,c-1);
	res/=((double)a+b+c)/N;
	mf[a][b][c]=true;
	memo[a][b][c]=res;
	return memo[a][b][c];
}

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

	int C[4]={0};
	int A;
	cin>>N;
	rep(i,0,N)
	{
		cin>>A;
		C[A]++;
	}

	mf[0][0][0]=true;
	cout<<fixed<<setprecision(12)<<DP(C[1],C[2],C[3])<<endl;
	
	return 0;
}

Measured memory_bytes: 246016
// ALDS1_7_C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Node {
	int parent;
	int children[2];
};

void pre_walk(vector<Node> Tree, int p) {
	cout << " " << p;
	
	for (int i = 0; i < 2; i++) 
		if (Tree[p].children[i] != -1)
			pre_walk(Tree, Tree[p].children[i]);
}

void in_walk(vector<Node> Tree, int p) {
	if (Tree[p].children[0] != -1)
		in_walk(Tree, Tree[p].children[0]);
	
	cout << " " << p;

	if (Tree[p].children[1] != -1)
		in_walk(Tree, Tree[p].children[1]);
}

void post_walk(vector<Node> Tree, int p) {
	for (int i = 0; i < 2; i++)
		if (Tree[p].children[i] != -1)
			post_walk(Tree, Tree[p].children[i]);

	cout << " " << p;
}

int main() {

	int n, id, left, right, root;
	cin >> n;

	vector<Node> Tree;

	for (int i = 0; i < n; i++) {
		Node node;
		node.parent = -1;
		Tree.push_back(node);
	}

	for (int i = 0; i < n; i++) {
		cin >> id >> left >> right;

		Tree[id].children[0] = left;
		Tree[id].children[1] = right;
		for (int j = 0; j < 2; j++)
			if (Tree[id].children[j] != -1) 
				Tree[Tree[id].children[j]].parent = id;
	}

	for (int i = 0; i < n; i++) {
		if (Tree[i].parent == -1)
			root = i;
	}

	cout << "Preorder" << endl;
	pre_walk(Tree, root);
	cout << endl;

	cout << "Inorder" << endl;
	in_walk(Tree, root);
	cout << endl;

	cout << "Postorder" << endl;
	post_walk(Tree, root);
	cout << endl;

	return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int W,n,v[1005],w[1005],dp[1005][1005];

int main() {
    int cnt=1;
    string tmp;
    while(cin >> W,W){
        cin >> n;
        REP(i,n){
            scanf("%d,%d",&v[i],&w[i]);
        }
        REP(i,n+1)fill(dp[i],dp[i]+1005,0);
        REP(i,n){
            REP(j,W+1){
                if(j>=w[i]) dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            }
        }
        int wmin = W;
        REPR(i,W){
            if(dp[n][i]!=dp[n][W])break;
            wmin = i;
        }
        cout << "Case " << cnt << ":" << endl;
        cout << dp[n][W] << endl;
        cout << wmin << endl;
        cnt++;
    }
    return 0;
}



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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = max(a, c), y = min(b, d);
  cout << max(0, y - x) << '\n'; 
  return 0;
}

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

int main() {

	/* ----- 変数宣言 ----- */

	int i;
	int ans;

	/* ----- 入力 ----- */
	
	cin >> i;
	
	/* ----- 計算 ----- */

	ans = 48 - i;

	/* ----- 出力 ----- */

	cout << ans << endl;
}


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

int main(){
 int n, l;
    cin >> n >> l;
    int sum = l;
    int min = l;
    for (int i = 1; i < n; i++) {
        sum += l + i;
        if (abs(min) > abs(l+i)) {
            min = l+i;
        }
    }
    cout << sum - min << endl;
  return 0;
}

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

class MainClass : Scanner
{
    static void Main()
    {
        var (k, s) = ReadTuple<int,int>();
        long ans = 0;
        for (int i = 0; i <= k; i++)
        {
            for (int j = 0; j <= k; j++)
            {
                if (i + j <= s && s <= i + j + k) ans++;
            }
        }
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define ll long long
#define u unsigned
#define me(a,x) memset(a,x,sizeof(a))
#define sf scanf
#define pf printf
const int mod=1e9+7;
using namespace std;
int main()
{
	int x;
	sf("%d",&x);
	if(x>=30){
		pf("Yes\n");
	}else{
		pf("No\n");
	}
	return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{	
  	int n;
  	cin >> n;
  	int x = INT_MAX,ans = 0;
  	for(int i = 0 ; i < n ; i++){
     	int ch;
      	cin >> ch;
      	if(ch < x)
        {
          x = ch;
          ans++;
        }
    }
  	cout << ans << endl;
 	return 0; 
}

Measured memory_bytes: 384
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 1000
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[MAX_N + 1][MAX_N + 1];
  int P[MAX_N + 1];
  queue<int> que;
  for (int i = 1; i <= N; i++) {
    rep(j, N - 1) { cin >> A[i][j]; }
    P[i] = 0;
    que.push(i);
  }
  que.push(-1);

  int Ans = N * (N - 1) / 2;
  vector<bool> seen(N + 1);
  int Num = 0;
  while (!que.empty()) {
    auto M = que.front();
    que.pop();
    if (M == -1) {
      if (Num == 0) {
        Ans = -1;
        break;
      }
      Ans -= (Num - 1);
      if (que.size() == 0) break;
      seen.assign(N + 1, false);
      Num = 0;
      que.push(-1);
      continue;
    }
    if (seen[M]) continue;
    int X = A[M][P[M]];
    if (seen[X]) continue;
    int Y = A[X][P[X]];
    if (Y == M) {
      seen[M] = true;
      seen[X] = true;
      P[M]++;
      if (P[M] < N - 1) que.push(M);
      P[X]++;
      if (P[X] < N - 1) que.push(X);
      Num++;
    }
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 4224
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

S = [i for i in range(N + 1)]

l = len(set(S[: X]) & set(A))
r = len(set(S[X + 1 : N + 1]) & set(A))

print(l if l <= r else r)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 200010
#define lg 19



int main() 
{ 

/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    

    lli n;
    cin>>n;

    string s;
    cin>>s;
    if(s[0] == 'W') 
    {
        cout<<0;
        return 0;
    }

    lli o = 1,ans=1;

    loopl(i,1,2*n)
    {
        if(s[i] == 'B')
        {
            if(o%2)
            {
                ans = (ans*o)%mod;
                o--;
            }

            else
                o++;
        }

        else
        {
            if(o%2)
                o++;

            else
            {
                ans = (ans*o)%mod ;
                o--;
            }
        }
    }
    if(o)
        cout<<0;

    else
    {
        loopl(i,1,n+1)
        {
            ans = (ans*i)%mod;
        }
        cout<<ans;
    }


}   




Measured memory_bytes: 720
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

//Turn Left
public class Main{

	double EPS = 1e-10;
	int INF = 1<<29, M = 1000;
	int[] x, y;
	boolean ok(int pre, int v, int next){
		int x1 = x[v]-x[pre], y1 = y[v]-y[pre], x2 = x[next]-x[pre], y2 = y[next]-y[pre];
		return x1*y2-x2*y1>=0;
	}
	
	int[][] pass;
	double[][] d;
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int m = sc.nextInt(), n = sc.nextInt();
			if((m|n)==0)break;
			Map<String, Integer> ref = new HashMap<String, Integer>();
			x = new int[m]; y = new int[m];
			for(int i=0;i<m;i++){
				ref.put(sc.next(), i);
				x[i] = sc.nextInt(); y[i] = sc.nextInt();
			}
			double[][] dist = new double[m][m];
			List<Integer>[] adj = new List[m];
			for(int i=0;i<m;i++)adj[i]=new ArrayList<Integer>();
			while(n--!=0){
				int s = ref.get(sc.next()), t = ref.get(sc.next());
				adj[s].add(t); adj[t].add(s);
				dist[s][t] = dist[t][s] = Math.sqrt((x[s]-x[t])*(x[s]-x[t])+(y[s]-y[t])*(y[s]-y[t]));
			}
			int s = ref.get(sc.next()), g = ref.get(sc.next());
			d = new double[m][m];
			for(double[]a:d)Arrays.fill(a, INF);
			pass = new int[m][m];
			for(int[]a:pass)Arrays.fill(a, INF);
			PriorityQueue<Integer> q = new PriorityQueue<Integer>(m, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					if(Math.abs(d[o1/M][o1%M]-d[o2/M][o2%M])<EPS)return pass[o1/M][o1%M]-pass[o2/M][o2%M];
					return (int)Math.signum(d[o1/M][o1%M]-d[o2/M][o2%M]);
				}
			});
			for(int v:adj[s]){
				d[v][s] = dist[s][v]; pass[v][s] = 2;
				q.add(v*M+s);
			}
			int res = INF;
			while(!q.isEmpty()){
				int a = q.poll();
				int v = a/M, pre = a%M;
				if(v==g){
					res = pass[v][pre];
					break;
				}
				for(int k:adj[v]){
					if(k==pre)continue;
					if(!ok(pre, v, k))continue;
					double w = d[v][pre] + dist[v][k];
					int t = pass[v][pre]+1;
					if(Math.abs(w-d[k][v])<EPS&&t<pass[k][v]){
						pass[k][v] = t; q.add(k*M+v);
					}
					else 
						if(w<d[k][v]){
						d[k][v] = w; pass[k][v] = t; q.add(k*M+v);
					}
				}
			}
			System.out.println(res==INF?"impossible":res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= k;
  }

  function<long long(int,int)> dfs = [&](int l, int r) {
    if (l + 1 == r) {
      if (a[l] >= 0) return 1LL;
      else return 0LL;
    }
    int m = (l + r) / 2;
    vector<long long> sl, sr;
    for (long long i = m - 1, sum = 0; i >= l; i--) {
      sum += a[i];
      sl.push_back(sum);
    }
    for (long long i = m, sum = 0; i < r; i++) {
      sum += a[i];
      sr.push_back(sum);
    }
    sort(sl.begin(), sl.end());
    sort(sr.begin(), sr.end());
    long long res = 0;
    res += dfs(l, m);
    res += dfs(m, r);
    for (auto i : sl) {
      res += sr.size() - (lower_bound(sr.begin(), sr.end(), -i) - sr.begin());
    }
    return res;
  };
  
  cout << dfs(0, n) << '\n';
  return 0;
}


Measured memory_bytes: 4340
#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 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(){

  vi l, r;
  vi nn;
  bool data[100000];
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  REP(i, n) data[i] = false;
  REP(i, n) if(s[i] == '1') data[i] = true;

  int tmpl = 0;
  bool zeromode = false;
  REP(i, n){
    if(data[i]){
      tmpl++;
      zeromode = false;
    }else{
      if(zeromode) continue;
      zeromode = true;
      l.pb(tmpl);
      tmpl = 0;
    }
  }
  int tmpr = 0;
  zeromode = false;
  for(int i = n - 1; i >= 0; i--){
    if(data[i]){
      tmpr++;
      zeromode = false;
    } 
    else{
      if(zeromode) continue;
      zeromode = true;
      r.pb(tmpr);
      tmpr = 0;
    }
  }
  reverse(All(r));

  int tmpzero = 0;
  bool onemode = false;
  REP(i, n){
    if(not data[i]){
      tmpzero++;
      onemode = false;
    } 
    else{
      if(onemode) continue;
      if(tmpzero == 0) continue;
      onemode = true;
      nn.pb(tmpzero);
      tmpzero = 0;
    }
  }
  if(tmpzero != 0) nn.pb(tmpzero);


  // REP(i, l.size()) cout << l[i] << " ";
  // cout << endl;
  // REP(i, r.size()) cout << r[i] << " ";
  // cout << endl;
  // REP(i, nn.size()) cout << nn[i] << " ";
  // cout << endl;
  if(nn.size() == 0){
    cout << n << endl;
    return 0;
  }
  int tmpsum = 0;
  k = min((int)nn.size(), k);
  // cout << k << endl;
  REP(i, k){
    tmpsum += l[i];
    tmpsum += nn[i];
    if(i == k -1) tmpsum += r[i];
  }
  int ans = tmpsum;
  // cout << ans << endl;
  REP(i, (int)nn.size() - k){
    tmpsum -= l[i];
    tmpsum -= nn[i];
    tmpsum += r[i + k];
    tmpsum += nn[i + k];
    ans = max(ans, tmpsum);
    // cout << tmpsum << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ans += n / 500 * 1000;
  n %= 500;
  ans += n / 5 * 5;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <stdlib.h>
using namespace std;
int x,y;
int main(){
    cin>>x>>y;
    int ans=0;
    if(abs(x)==abs(y))ans=1;
    if(abs(x)<abs(y)){
        if(x<0)ans++;
        ans+=abs(y)-abs(x);
        if(y<0)ans++;
    }
    if(abs(x)>abs(y)){
        if(x>0)ans++;
        ans+=abs(x)-abs(y);
        if(y>0)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// 最大公約数 O(log(n))
// gcd(12,0)=gcd(0,12)=12
ll gcd(ll a, ll b)
{
    if(b==0) swap(a,b);
    if(a%b == 0){
        return(b);
    }
    else{
        return(gcd(b, a%b));
    }
}

// 最小公倍数
ll lcm(ll a, ll b)
{
    return a  / gcd(a, b) * b;
}

int main(void)
{
    ll K, i, j, k, ans=0, a, b;

    cin >> K;

    for(i=1; i<=K; i++){
        for(j=i; j<=K; j++){
            for(k=j; k<=K; k++){
                a = gcd(i,j);
                b = gcd(a,k);
                if(i==j && j==k){
                    ans += b;
                }
                else if(i!=j && j!=k && k!=i){
                    ans += b*6;
                }
                else{
                    ans += b*3;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    vector<int> box(n+1);  // box[i] : 箱iにボールが入っているかどうか

    vector<int> b;
    for(int i = n; i >= 1; i--) {
        int cnt = 0;
        for(int j = i; j <= n; j += i) {
            cnt += box[j];
            cnt %= 2;
        }
        if(cnt != a[i]) {
            b.push_back(i);
            box[i] = 1;
        }
    }

    reverse(b.begin(), b.end());
    int m = b.size();

    cout << m << "\n";
    rep(i, m) {
        cout << b[i];
        if(i != m-1) {
            cout << " ";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int mod = 1000000007;
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());

        long max = (a * c);
        max = Math.max(max, (b * c));
        max = Math.max(max, (a * d));
        max = Math.max(max, (b * d));
        System.out.println(max);
    }
}

Measured memory_bytes: 35468
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
int n;
cin >>n;
bool ans = true;
for(int i=1;i<10;i++){
  for(int j=1;j<10;j++){
    if(j*i==n&&ans){
      cout << "Yes"<<endl;
      ans = false;
      break;
    }
  }
}
if(ans){
  cout << "No"<<endl;
}
 }


Measured memory_bytes: 256