akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

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

using namespace std;
const long long INF = 1LL << 61;
const int MOD = 2019;

int main() {
	int N; cin >> N;
	vector<int> d(N);
	rep(i, N)cin >> d[i];
	sort(d.begin(), d.end());
	int num = d[N / 2] - d[N / 2 - 1];
	cout << num;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n],b[n],c[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  rep(i,n) R c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans=0;
  rep(i,n) {
    ll x=lower_bound(a,a+n,b[i])-a;
    ll y=upper_bound(c,c+n,b[i])-c;
    ans+=x*(n-y);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2560
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    vector<pair<int, int> > red(n);
    vector<pair<int, int> > blue(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        red[i] = make_pair(x, y);
    }

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        blue[i] = make_pair(x, y);
    }

    bool goodPair[n];
    fill(goodPair, goodPair + n, false);
    sort(blue.begin(), blue.end());
    for (int i = 0; i < n; i++) {
        int pairId = -1;
        int pairY = -1;
        for (int j = 0; j < n; j++) {
            if (blue[i].first > red[j].first && blue[i].second > red[j].second && !goodPair[j]) {
                if (pairY < red[j].second) {
                    pairY = red[j].second;
                    pairId = j;
                }
            }
        }
        if (pairId != -1) goodPair[pairId] = true;
    }

    int res = 0;
    for (int i = 0; i < n; i++) if (goodPair[i]) ++res;

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	int n,k,a=-1,highest=0;
	cin>>n>>k; 
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		if(n==1&&b==k){
			cout<<"POSSIBLE";
			return 0;
		}
		if(n==1){
			cout<<"IMPOSSIBLE";
			return 0;
		}
		if(i)a=gcd(max(a,b),min(a,b));
		else
			a=b;
		highest=max(highest,b);
	}
	if(k%a||k>highest)
		cout<<"IMPOSSIBLE";
	else
		cout<<"POSSIBLE";
}

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

int main() {
    int n, ans;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d.at(i);
    sort(d.begin(), d.end());
    ans = d.at(n / 2) - d.at(n / 2 - 1);
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
int main(void){
	char S[3],T[3];
    int i, cnt=0;
    scanf("%s", S);
    scanf("%s", T);
    for(i-0;i<3;i++){
    	if(S[i]==T[i])cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;


int main() {
	string S;
	cin >> S;
	int t;

	if (S[0] != 'A') {
		cout << "WA" << endl;
		exit(0);
	}

	int cnt = 0;

	for (int i = 2; i <= S.size() - 2; i++) {
		if (S[i] == 'C') {
			cnt++;
			t = i;
		}
	}

	if (cnt != 1) {
		cout << "WA" << endl;
		exit(0);
	}

	for (int i = 1; i < S.size(); i++) {
		if (i != t) {
			if (!(S[i] >= 'a' && S[i] <= 'z')) {
				cout << "WA" << endl;
				exit(0);
			}
		}
	}

	cout << "AC" << endl;
}

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

A = []

nums = input().split()

for i in range(N):
    A.append(int(nums[i]))

l = [str(i) for i in A]
print(" ".join(l))
    
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    l = [str(i) for i in A]
    print(" ".join(l))



Measured memory_bytes: 5604
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();

        boolean foundC = false;
        if (S[0] == 'A') {
            if (S[1] >= 'A' && S[1] <= 'Z') {
                System.out.println("WA");
                return;
            }

            for (int i = 2; i <= S.length - 2; i++) {
                if (S[i] == 'C') {
                    if (foundC) {
                        System.out.println("WA");
                        return;
                    }
                    else foundC = true;
                } else if (S[i] >= 'A' && S[i] <= 'Z') {
                    System.out.println("WA");
                    return;
                }
            }

            char lastch = S[S.length - 1];
            if (lastch >= 'A' && lastch <= 'Z') {
                System.out.println("WA");
                return;
            }
        }

        if (foundC) System.out.println("AC");
        else System.out.println("WA");

        return;
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define N 7105
int p[25],a[25];
int main() {
	int n,ans = 0;
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=2; i<n; i++) {
		if(a[i] > a[i-1] && a[i] < a[i+1]) ans ++;
		if(a[i] < a[i-1] && a[i] > a[i+1]) ans ++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
 
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;
int main() {
	int n;
	cin>>n;
	vector<int64>v(n);
	for(int i =0;i<n;i++){
		cin>>v[i];
		if(v[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	int64 ans=1;
	int64 g=1e18;
	for(int i=0;i<n;i++){
		if(v[i]<=g/ans)
		ans*=v[i];
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3964
def main():
    data = input().split()
    N = int(data[0])
    X = int(data[1])
    L = input().split()
    num = 1
    D = 0
    for i in range(N):
        D += int(L[i])
        if D <= X:
            num += 1
        else:
            break
    print(num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int a = in.nextInt();
        final int b = in.nextInt();
        final int c = in.nextInt();
        in.nextLine();
        final int k = Integer.parseInt(in.nextLine());
        System.out.println(dfs(a, b, c, k) ? "Yes" : "No");
    }

    private static boolean dfs(int a, int b, int c, int k) {
        if (k == 0) {
            return c > b && b > a;
        }
        return dfs(a * 2, b, c, k - 1) || dfs(a, b * 2, c, k - 1) || dfs(a, b, c * 2, k - 1);
    }
}


Measured memory_bytes: 35724
#include <iostream>

int main () {
    std::string s;
    std::cin >> s;
    int c = 1;
    for(int i = 0; i < s.size(); ++i) {
        if(i % 2 == 0) {
            if(s[i] == 'L'){
                c = 0;
                break;
            }
        }
        else {
            if(s[i] == 'R') {
                c = 0;
                break;
            }
        }
    }
    if(c) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
#define debug(a) cout<<#a<<": "<<a<<'\n'
int t1[27],t2[27];
vector<int> p[27];
vector<int> :: iterator it;
ll t[maxn];

int main() {
	ios::sync_with_stdio(false);
	string a,b;
	ll ans = 0;
	cin >> a >> b;
	for(int i = 0;i < a.length();++i)t1[a[i]-'a'] = 1,p[a[i]-'a'].push_back(i);
	for(int i = 0;i< b.length();++i)t2[b[i]-'a'] = 1;
	for(int i = 0;i<26;++i){
		if(t2[i]&&!t1[i]){
			cout << -1;
			return 0;
		}
	}
	int tem = -1;
	for(int i =  0;i<b.length();++i){
		int x = b[i]-'a';
		it = upper_bound(p[x].begin(),p[x].end(),tem);
		if(it!=p[x].end())tem = *it,t[i] = *it;
		else {
			if(p[x].size()==0){
				cout << -1;
				return 0;
			}
			else tem  = *p[x].begin(),t[i] = *p[x].begin();
		}
	}
	tem = -1;
	int len = a.length();
	for(int i = 0;i<b.length();++i){
		if(t[i]<=tem)ans += len,tem = t[i];
		else tem = t[i];
	}
	ans += tem + 1;
	cout << ans << endl;
	return 0;
}


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



int main(){

    int n;
    string al("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    
    while(cin>>n,n){

        vector<int> p(26,0);        
        string vote;
        int f=0;
        
        for(int i=0;i<n;i++){
            cin>>vote[i];
        }
        
        for(int i=0;i<n;i++){

            for(int j=0;j<26;j++){
                if(vote[i]==al[j]){
                    p.at(j)++;
                    break;
                }
            }
            
            vector<int> pp(26);
            for(int k=0;k<26;k++){
                pp.at(k)=p.at(k);
            }
            sort(pp.rbegin(),pp.rend());
            if(pp.at(0)>pp.at(1)+n-i-1){
            int m=0;
                for(int j=0;j<26;j++){
                    if(p.at(m)<p.at(j)){
                        m=j;
                    }
                }
                cout<<al[m]<<" "<<i+1<<endl;
                f=1;
                break;
                
            }
            
        }
        
        if(f!=1){
            cout<<"TIE"<<endl;
        }
   
   }
   
}


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

int main(void) {
    string S;
    cin >> S;
    map<char,int> m;
    for(int i=0;i<4;i++) {
        m[S[i]]++;
    }

    if((m.size() == 2) && (m.begin()->second == 2)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    while(1){
        int i,j,k,H,W;
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(j%2==1){
                    if(i%2==1){
                    printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                else{
                    if(i%2==1){
                    printf(".");
                    }
                    else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0

x, y = a.zip(b).map { |i, j| j - i }.partition { |e| e > 0 }

count += x.size
(puts 0; exit) if count == 0

sum = x.inject(:+)

y.sort.each do |i|
  sum += i
  count += 1

  (puts count; exit) if sum <= 0
end

puts -1

Measured memory_bytes: 22436
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, K;
	cin >> N >> K;
	vector<lint> data(100000, 0);

	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		data[a - 1] += b;
	}
	lint count = 0;
	for (int i = 0; i < 100000; i++)
	{
		count += data[i];
		if (K <= count)
		{
			cout << i + 1 << endl;
			return;
		}
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

double dist(pii xy1, pii xy2) {
    pii diff = xy1 - xy2;
    return sqrt(diff.first * diff.first + diff.second * diff.second);
}

signed main() {
    fio();
    int n;
    cin >> n;
    vector<pii> a(n);
    rep (i, n) cin >> a[i].first >> a[i].second;

    vi perm(n);
    rep (i, n) perm[i] = i;

    double ans = 0;
    do {
        vector<pii> xy(n);
        rep (i, n) {
            xy[i] = a[perm[i]];
        }
        double add = 0;
        rep (i, n - 1) {
            add += dist(xy[i], xy[i + 1]);
        }
        ans += add;
    } while (next_permutation(all(perm)));
    rep1 (i, n) {
        ans /= i;
    }
    Sp(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int N=1e5+10;
long a[N];
int main(){
    int k,x=10;
    cin>>k;
    for(int i=1;i<10;i++){
        a[i]=i;
    }
    if(k<10) cout<<k;
    else{
        for(int j=1,x=10;x<=k;j++){
            int t=a[j]%10;
            if(t!=0&&t!=9){
                a[x++]=a[j]*10+t-1;
                a[x++]=a[j]*10+t;
                a[x++]=a[j]*10+t+1;
            }
            else if(t==0){
                a[x++]=a[j]*10+t;
                a[x++]=a[j]*10+t+1;
            }
            else if(t==9){
                a[x++]=a[j]*10+t-1;
                a[x++]=a[j]*10+t;
            }
        }
        
        cout<<a[k];
    }
    
    return 0;
}

Measured memory_bytes: 1024
if __name__ == "__main__":
    """
    X is ルンルン数 ⇔ Xを10進数表記したとき、隣り合うどの2つの桁の値についても、差の絶対値が1以下
    """
    K = int(input())
    
    # table[0] = [0]
    # table[1] = [1,...,9]
    #            0, 1, 1, 1, 1, 1, 1, 1, 1, 1
    # table[2]   1, 2, 3, 3, 3, 3, 3, 3, 3, 2
    # table[3]   3, 6, 8, 9, 9, 9, 9, 9, 8, 5
    table = [list(range(1, 10))]
    table_size_prev = 0
    table_size = len(table[-1])
    while table_size < K:
        table.append([])
        # 以前の数字に末尾を追加していく
        for num in table[-2]:
            base_num = num * 10
            digit1 = num % 10
            if digit1 == 0:
                table[-1] += [base_num, base_num+1]
            elif digit1 == 9:
                table[-1] += [base_num+8, base_num+9]
            else:
                table[-1] += [base_num+digit1-1, base_num+digit1, base_num+digit1+1]
        
        table_size_prev = table_size
        table_size += len(table[-1])
    
    print(table[-1][K-table_size_prev-1])

Measured memory_bytes: 18196
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main (){
 
  double x1,y1,x2,y2,d;
 
  cin >>x1>>y1>>x2>>y2;
 
  d=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
 
  printf("%0.8f\n",sqrt(d));
 
  return 0;
 
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
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; }
// Welcome to my source code!

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i <= w + 1; i++) cout << '#';
    cout << '\n';
    for (int i = 0; i < h; i++) {
        cout << '#' << s[i] << "#\n";
    }
    for (int i = 0; i <= w + 1; i++) cout << '#';
    cout << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			long w = sc.nextInt();
			long h = sc.nextInt();
			long x = sc.nextInt();
			long y = sc.nextInt();
			
			long multi = (x * 2 == w && y * 2 == h) ? 1 : 0;
			
			double midx = (double) w / 2;
			double midy = (double) h / 2;
			
			if(Math.abs(midx - x) < EPS) {
				System.out.printf("%.9f %d\n", (double)w * h / 2, multi);
				continue;
			}
			
			double a = (midy - y) / (midx - x);
			double b = y - a * x;
			if(Math.abs(a) < EPS){
				System.out.printf("%.9f %d\n", (double)w * b, multi);
				continue;
			}
			
			double lowx = -1.0 * b / a;
			double hix = (h- b) / a;
			
			double res = (lowx + hix) * h / 2;
			
			System.out.printf("%.9f %d\n",res, multi);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23252
/*input
7 1 2
24 35 40 68 72 99 103
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int n,a,b;
int x[100001];

void solve(){
	 cin >> n >> a >> b;
	 REP(i,n)cin >> x[i];
	 int last = 0;
	 int dist = 0;
	 int cur = 1;
	 int ans = 0;
	 while(cur < n){
	 	if( (x[cur]-x[cur-1])*a >= b){
           ans += b;
           //last = cur;
	 	}
	 	else ans += (x[cur]-x[cur-1])*a;
	 	cur++;
	 }
	 cout << ans << endl;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int minNum = sc.nextInt();
        sc.nextInt();
        sc.nextInt();
        sc.nextInt();
        int maxNum = sc.nextInt();
        int limit = sc.nextInt();

        String ans;
        if(maxNum - minNum > limit){
            ans = ":(";
        }else{
            ans = "Yay!";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI R;
	cin >> R;
	cout << pow(R, 2) * 3 << endl;
}

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


int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int a = ri(), b = ri();
	std::cout << std::max(a + std::abs(b), a * b) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    int n;
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    vector<int> N(n);
    rep(i,n) {
        cin >> P[i];
    }
    rep(i,n) {
        cin >>  Q[i];
    }
    for(int i=1; i<=n; ++i) {
        N[i-1] = i;
    }
    int a=0,b=0;
    int cnt = 1;
    do {
        bool ja = true;
        bool jb = true;
        rep(i,n) {
            if (N[i] != P[i]) ja = false;
            if (N[i] != Q[i]) jb = false;
        }
        if (ja) a = cnt;
        if (jb) b = cnt;
        cnt++;
    } while(next_permutation(all(N)));
    cout << abs(a-b) << "\n";
}


Measured memory_bytes: 764
R, G, B, N = map(int, input().split())

ans = 0
r = 0
while r * R <= N:
    n = N - r * R
    g = 0
    while g * G <= n:
        if (n-g*G) % B == 0:
            ans += 1
        g += 1
    r += 1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define pb(x) push_back(x)
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define eps 1e-8 
#define ll long long
#define ull unsigned long long
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f,maxn=1e5+100;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
ll a[maxn],n,sum=0;
int main()
{
	fast;cin>>n;
	FOR(i,1,n) {cin>>a[i];sum+=a[i];}
	ll num=0; 
	for(int i=2;i<=n;i+=2) num+=a[i];
	ll x=sum-2*num;
	cout<<x<<" ";
	x=x/2;
	FOR(i,1,n-1)
	{
		ll qw=a[i]-x;
		cout<<qw*2<<" ";
		x=qw;
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0, sum = 0;
  ll itr = n / (a+b);
  if (itr == 0) {
    if (a >= n) ans = n;
    else ans = a;
  } else {
    ans += itr * a;
    ll tmp = n - (a+b)*itr;
    if (a >= tmp) ans += tmp;
    else ans += a;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}


int main(){
 ll d ; cin>> d ;
 ll c[26] ; rep(i,26) cin>>c[i] ;
 ll s[d][26] ;
 vector<ll> bns(d) ;
 rep(i,d){
     rep(j,26){
        cin>> s[i][j] ;
        if(s[i][bns[i]] <s[i][j]) bns[i]= j ;
     }
 }
 ll t[d] ; 
 rep(i,d){
   cin >> t[i] ;
   t[i]-- ;
 }
ll m ;cin>>m ;
 ll p[m] ;ll q[m] ;
 rep(i,m){
   cin>> p[i]>>q[i] ;
   p[i]-- ; q[i]-- ;
 }
 ll ans=0 ;
ll last[26] ; rep(i,26) last[i]=0 ;
rep(i,d){
  ans+= s[i][t[i]] ;
  rep(i,26) last[i] ++ ;
  last[t[i]]=0 ;
  ll sum=0 ;
  rep(i,26) sum+= c[i]*last[i] ;
  ans-= sum ;
  }
  
  
  
  rep(i,m){
   ll memo = t[p[i]] ;
   t[p[i]]= q[i] ;
   ll maex=p[i]+1, atox= d-p[i] ;
   ll maey=p[i]+1 ,atoy= d-p[i] ;
    rep(j,d){
     if(t[j]==memo&&j<p[i]) maex=p[i]-j ;
     if(t[j]==memo&&j>p[i]){
       atox= j-p[i] ;
       break ;
     }
    }
    rep(j,d){
     if(t[j]==q[i]&&j<p[i]) maey=p[i]-j ;
     if(t[j]==q[i]&&j>p[i]){
       atoy= j-p[i] ;
       break ;
     }
    }
    ans -= c[memo]*atox*maex ;
    ans += c[q[i]]*atoy*maey ;
    ans = ans- s[p[i]][memo] + s[p[i]][q[i]] ;
    cout<< ans<<endl ;
  }

  // rep(i,d) cout<< bns[i]+1<<endl ;
 return 0 ;
}


Measured memory_bytes: 5268
#include <stdio.h>
int main(void){
    
    int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


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

bool solve() {
    ll N, M;
    cin >> N >> M;
    int a, b;
    unordered_map<int, int> m;
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b;
        if ( a == 1 ) m[b]++;
        if ( b == N ) m[a]++;
    }
    for ( auto x : m ) {
        if ( x.second >= 2 ) return true;
    }
    return false;
}

int main() {
    string ans = solve() ? "POSSIBLE" : "IMPOSSIBLE";
    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;
typedef tuple<ll, int, int> tlii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<pair<int, int>, ll> ppiil;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define btoe(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
#define mkt make_tuple
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

template<typename T>
void print(T out) {
    cout << out << '\n';
}

template<typename T1, typename T2>
void print(pair<T1, T2> out) {
    cout << out.first << ' ' << out.second << '\n';
}

template<typename T>
void print(vector<T> A) {
    rep(i, 0, A.size()) {
        cout << A[i];
        cout << (i == A.size()-1 ? '\n' : ' ');
    }
}

ll sum(vector<ll> A) {
    ll res = 0;
    for (ll a: A) res += a;
    return res;
}

ll max(vector<ll> A) {
    ll res = -INF;
    for (ll a: A) chmax(res, a);
    return res;
}

ll min(vector<ll> A) {
    ll res = INF;
    for (ll a: A) chmin(res, a);
    return res;
}

ll sum(ll A[], int len) {
    ll res = 0;
    rep(i, 0, len) res += A[i];
    return res;
}

ll max(ll A[], int len) {
    ll res = -INF;
    rep(i, 0, len) chmax(res, A[i]);
    return res;
}

ll min(ll A[], int len) {
    ll res = INF;
    rep(i, 0, len) chmin(res, A[i]);
    return res;
}

int N;
string S;
bool dp[30007][4][10][10][10];

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

    cin >> N;
    cin >> S;

    dp[0][0][0][0][0] = 1;
    rep(i, 0, N) {
        int a = S[i] - '0';
        rep(j, 0, 4) {
            rep(k, 0, 10) {
                rep(l, 0, 10) {
                    rep(m, 0, 10) {
                        dp[i+1][j][k][l][m] |= dp[i][j][k][l][m];
                        if (j == 0) dp[i+1][j+1][k][l][a] |= dp[i][j][k][l][m];
                        if (j == 1) dp[i+1][j+1][k][a][m] |= dp[i][j][k][l][m];
                        if (j == 2) dp[i+1][j+1][a][l][m] |= dp[i][j][k][l][m];
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(k, 0, 10) {
        rep(l, 0, 10) {
            rep(m, 0, 10) {
                ans += dp[N][3][k][l][m];
            }
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 117504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int L,R,d;
	cin>>L>>R>>d;
	int count=0;
	for(int i=L;i<=R;i++)
	{
		if(i%d==0)
		{
			count++;
		}
	}
	cout<<count<<'\n';
	
}


Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
    int n,x,l[100];

    scanf("%d %d",&n,&x);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&l[i]);
    }
    
    int d = 0,i;
    
    for (i = 0; i < n; i++)
    {
        d = d + l[i];
        if (x < d)
        {
            break;
        }
    }
    printf("%d\n",i + 1);
}

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

const int INF = 1<<28;

struct E {
  int to, cost, cap, rev;
  E(int to, int cost, int cap, int rev)
    : to(to), cost(cost), cap(cap), rev(rev) {}
  E() {}
};

typedef vector<vector<E> > G;

void addEdgeF(int from, int to, int cost, int cap, G &g) {
  g[from].push_back(E(to,cost,cap,g[to].size()));
  g[to].push_back(E(from,cost,0,(int)g[from].size()-1));
}

int dfsF(int v, int t, int f, bool *used, G &g) {
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < g[v].size(); ++i) {
    E &e = g[v][i];
    if(!used[e.to] && e.cap > 0) {
      int d = dfsF(e.to, t, min(f, e.cap), used, g);
      if(d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int maxFlow(int s, int t, G g) {
  int flow = 0;
  bool *used = new bool[g.size()];
  while(1) {
    fill(used, used + g.size(), false);
    int f = dfsF(s, t, INF, used, g);
    if(f == 0) break;
    flow += f;
  }
  delete [] used;
  return flow;
}

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a%b);
}

int main() {
  int m, n, tmp;
  vector<int> b, r;
  G g;
  while(cin >> m >> n && (m|n)) {
    b.resize(m);
    r.resize(n);
    for(int i = 0; i < m; ++i) {
      cin >> b[i];
    }
    for(int i = 0; i < n; ++i) {
      cin >> r[i];
    }

    g = G(m+n+2);
    for(int i = 0; i < m; ++i) {
      addEdgeF(m+n, i, 0, 1, g);
    }
    for(int i = 0; i < m; ++i) {
      for(int j = 0; j < n; ++j) {
        if(gcd(b[i], r[j]) != 1) {
          addEdgeF(i, m+j, 0, 1, g);
        }
      }
    }
    for(int i = 0; i < n; ++i) {
      addEdgeF(m+i, m+n+1, 0, 1, g);
    }
    cout << maxFlow(m+n, m+n+1, g) << endl;
  }
  return 0;
}

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

int main() {
	int x, a, b, yen = 0;
	cin >> x >> a >> b;
	yen = x - a;
	for (;;) {
		if (yen >= b) {
			yen -= b;
		}
		else {
			break;
		}
	}
	cout << yen << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] z = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            z[i] = x[i];
        }
        Arrays.sort(x);
//        int[] y = new int[n];
//        for(int i = 0; i < n; i++){
//            y[i] = x[n - 1 - i];
//        }
        int medA = x[n / 2];
        int medB = x[(n - 1) / 2];
        for(int i = 0; i < n; i++){
            if(z[i] < medA){
                System.out.println(medA);
            } else {
                System.out.println(medB);
            }
        }
    }
}


Measured memory_bytes: 110732
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int l = sc.nextInt();
    int r = sc.nextInt();
    int d = sc.nextInt();
    
    int cnt = 0;
    
    for(int i=l; i <= r; i++){
      if(i%d == 0)
        cnt++;
    }
    
    System.out.println(cnt);
  }
}

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

using namespace std;

int main() {
    int n;
    int tmp_x = 0;
    int tmp_y = 0;
    int result;

    cin >> n;

    vector <int> v(n);
    vector <int> c(n);

    int tmp = 0;
    int i = 0;
    while(cin >> tmp) {
        v[i] = tmp;
        i ++;
        if(i >= n){
            break;
        }
    }

    i = 0;

    while(cin >> tmp) {
        c[i] = tmp;
        i ++;
        if(i >= n){
            break;
        }
    }

    for(int i = 0; i < n; i++) {
        if(v[i] > c[i]) {
            tmp_x += v[i];
            tmp_y += c[i];
        }
    }

    cout << tmp_x - tmp_y << endl;


}

Measured memory_bytes: 256
#ナップザック問題
N,W = list(map(int,input().split()))
VW = [list(map(int,input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if VW[i][1] <= w:
            # i番目までの品物の中から重さがwを超えないように選んだときの、価値の総和の最大値
            dp[i+1][w] = max(dp[i][w-VW[i][1]]+VW[i][0],dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42472
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String s = "";
		ArrayList<String> Array = new ArrayList<>();
		Scanner scan = new Scanner(System.in);

		s = scan.next();
		for (int i = 0; i < s.length(); i++) {
			Array.add(s.substring(i, i + 1));
			if ((Array.get(Array.size() - 1).equals("B"))) {
				Array.remove(Array.size() - 1);
				if(Array.size() == 0) {
					Array.add("");
				}
				Array.remove(Array.size() - 1);
				if(Array.size() == 0) {
					Array.add("");
				}
			}
		}
		for (int j = 0; j < Array.size(); j++) {
			System.out.print(Array.get(j));
		}
	}
}

Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s;
  cin >> s;
  string a = "keyence";

  for (int i = 0; i + a.size() < s.size(); i++) {
    if (s.substr(i, a.size()) == a) {
      cout << "YES" << endl;
      return 0;
    }
  }

  for (int i = 0; i < s.size(); i++) {
    for (int j = i; j < s.size(); j++) {
      string tmp = s;
      tmp.erase(tmp.begin() + i, tmp.begin() + j);
      if (tmp == a) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }

  cout << "NO" << endl;
  return 0;
}


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

num=0
for i in range(1,10**3):
    if i*(i-1)//2==n:
        num=i
        break

if num==0:print("No");exit()
length=num-1
A,cnt=[],1
for i in range(1,num):
    B=[]
    cnt +=i-1
    for j in range(i):B.append(cnt+j)
    for j in range(i,length):B.append(B[-1]+j)
    A.append(B)
A.append([i*(i+1)//2 for i in range(1,length+1)])

print("Yes")
print(length+1)
for i in A:
    print(length,*i)

Measured memory_bytes: 75548
#include<iostream>

using namespace std;

int main()
{
	int max,i,j,ans[10000],g[7];
	
	for(i=0;i<5001;i++)
	{
		ans[i]=10000000;
	}
	
	g[0]=200;g[1]=300;g[2]=500;g[3]=1000;g[4]=1200;g[5]=1500;
	ans[200]=380;ans[300]=550;ans[500]=850;ans[1000]=380*5*0.8;ans[1200]=550*4*0.85;ans[1500]=850*3*0.88;
	
	
	for(i=0;i<5001;i+=100)
	{
		if(ans[i]!=10000000)
		{
			for(j=0;j<6;j++)
			{
				if(i+g[j]>5001)
					break;
				if(ans[i+g[j]]>ans[i]+ans[g[j]])
				ans[i+g[j]]=ans[i]+ans[g[j]];
			}
		}
	}
	
	for(;;)
	{
		cin >> max;
		if(max==0)
			break;
		
		cout << ans[max] << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long  int
#define all(x) (x).begin(), (x).end()
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
// #define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
// getting string line
// getline(cin,word);
// -> priority_queue < int > pq; // max_heap
// -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap


ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}

template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}

struct Triplet{
    ll x,y,z;
};

ll modularexpo(ll x,ll n,ll mod){
    ll res = 1;
    while(n>0){
        if(n%2==1){
            res = (res*x)%mod;
        }
        x = (x*x);
        n = n/2;
    }
    return res;
}

ll s;
ll dp[2005];

ll func(ll rem){
    if(rem==0){
        return 1;
    }
    if(dp[rem]!=-1){
        return dp[rem];
    }

    ll ans = 0;
    for(int i=3;i<2005;i++){
        if(rem-i>=0){
            ans = (ans+func(rem-i))%mod;
        }
        else{
            break;
        }
    }
    return dp[rem] = ans;
}

int main(){
    cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<func(s)<<endl;
    
    return 0;
}

Measured memory_bytes: 3676