akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.PriorityQueue;
import java.util.Scanner;

class Stuff implements Comparable<Stuff> {
    int v;
    int w;
    double performance;

    Stuff(int v, int w) {
        this.v = v;
        this.w = w;
        performance = 1.0 * v / w;
    }

    public int compareTo(Stuff s) {
        if(performance < s.performance) return 1;
        if(performance > s.performance) return -1;
        return 0;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int w = sc.nextInt();
        PriorityQueue<Stuff> que = new PriorityQueue<>();
        for(int i = 0; i < n; i++) {
            int vi = sc.nextInt();
            int wi = sc.nextInt();
            que.add(new Stuff(vi, wi));
        }

        double res = 0;
        while(w > 0 && !que.isEmpty()) {
            Stuff s = que.poll();
            if(w >= s.w) {
                res += s.v;
                w -= s.w;
            }else {
                res += s.performance * w;
                w = 0;
            }
        }

        System.out.println(BigDecimal.valueOf(res).toPlainString());
 
        sc.close();
    }
}



Measured memory_bytes: 105468
import heapq
def prim_heap():
    used = [True] * n
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res
n, *t = map(int, open(0).read().split())
x = sorted((x, i) for i, (x, y) in enumerate(zip(t[::2], t[1::2])))
y = sorted((y, i) for i, (x, y) in enumerate(zip(t[::2], t[1::2])))
edge = [[] for _ in range(n)]
for i, j in zip(x, x[1:]):
    a, b, c = i[1], j[1], j[0] - i[0]
    edge[a].append((c, b))
    edge[b].append((c, a))
for i, j in zip(y, y[1:]):
    a, b, c = i[1], j[1], j[0] - i[0]
    edge[a].append((c, b))
    edge[b].append((c, a))
print(prim_heap())

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	int re = 1;
	while(b){
		if(b&1)re= mul(re, a);
		a = mul(a, a);
		b>>=1;
	}
	return re;
}
int const N = 200 * 1010;

/********************i**********************************/
vector<vector<int>> match(25, vector<int>(25, 0));
int n1;
int dp[25][(1<<22)];

int go(int n, int mask){
	if(n == n1 && mask == (1<<n)-1)return 1;
	if(dp[n][mask] != -1)return dp[n][mask];

	if(n == n1){
		return 0;
	}
	auto &ans = dp[n][mask];
	ans = 0;
	for(int x = 0; x<n1; x++){
		if(!(mask & (1<<x)) && match[n][x] == 1){
			// cout << n << "  x  " << x << " ans " << ans << endl;
			ans = add(ans,  go(n+1, (mask ^ (1<<x))));
		}
	}
	// cout << n << " " << mask << " --  " << ans << endl;; 
	return ans;
}

void solve(){
	int n; cin >> n;
	n1 = n;
	for(int x =0; x<n; x++){
		for(int y = 0; y<n; y++){
			cin >> match[x][y];
		}
	}
	for(int x =0; x<n; x++)
		for(int y =0; y<(1<<n); y++)
			dp[x][y] = -1;
	// dp[n][(1<<n)-1] = 1;
	int a =  go(0, 0);
	cout << dp[0][0];
	// for(int x =0; x<n; x++){
	// 	for(int y =0; y<(1<<n); y++)
	// 		cout << dp[x][y] << " ";
	// 	cout << endl;
	// }
}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 215296
#include<iostream>
    #include<algorithm>
    #include<string>
     
    int main(){
      long long x, d, k;
      std::cin >> x >> k >> d;
      x=std::abs(x);
      long long ps = x%d;
      long long ms = d-ps;
      long long reach = (x-ps)/d;
      if(ps!=0){
      if(k > (reach+1)){
        if((k-reach)%2==0){
            std::cout << ps;
          }else{
            std::cout << ms;
          }
      }else if(k == (reach+1)){
          std::cout << ms;
      }else{
        std::cout << x-k*d;
      }
      }else{
        if(k >= reach){
          if((k-reach)%2==0){
            std::cout << 0;
          }else{
            std::cout << d;
          }
        }else{
          std::cout << x-k*d;
        }
      }
      std::cout << "\n";
      return 0;
    }

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

using i64 = int64_t;

constexpr int INF = 1e9;

int main(){
    int n;
    cin >> n;
    int mini = INF, ans = 0;
    for(int i=0;i<n;++i){
        int p;
        cin >> p;
        if(p <= mini){
            mini = p;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys


def check(num, s, b):
    sum_keta = 0
    while num > 0:
        sum_keta += num % b
        num //= b
    if sum_keta == s:
        return 1
    else:
        return 0


def main():
    num = int(input())
    s = int(input())

    if num < s:
        print(-1)
        sys.exit()

    if num == s:
        print(num + 1)
        sys.exit()

    if num == 1:
        print(-1)
        sys.exit()

    for b in range(2, int(num ** 0.5) + 2):
        if check(num, s, b):
            print(b)
            sys.exit()

    for p in range(1, int(num ** 0.5) + 2)[::-1]:
        b = (num - s) // p + 1
        if b <= 1:
            continue
        if check(num, s, b):
            print(b)
            sys.exit()

    print(-1)






if __name__ == '__main__':
    main()

Measured memory_bytes: 40796
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var N = _[0];
        var R = _[1];
        var result = 0;
        if (N >= 10)
        {
            result = R;
        }
        else
        {
            result = R + 100 * (10 - N);
        }
        print(result);
    }

    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}



Measured memory_bytes: 11220
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  rep(i, s.size()){
    char t;
    cin >> t;
    if(t != s[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  char t;
  cin >> t;
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define pb push_back
#define fo(i,a,b) for(int i=a;i<b;i++)
#define foe(i,a,b) for (int i=a;i<=b;i++)
ll dp[3001][3001];
ll fundp(int i,int j, ll *a){
    //cout<<i<<" "<<j<<endl;
    if (dp[i][j]!=1000000000000001) return dp[i][j];
    if (i==j)
    dp[i][j]=a[i];
    else
    {
        dp[i][j]=max(a[i]-fundp(i+1,j,a),a[j]-fundp(i,j-1,a));
    }
    return dp[i][j];
    
}
void solve()
{
    int n;
    cin>>n;
    ll a[n];
    fo(i,0,n) cin>>a[i];
    fo(i,0,n){
        fo(j,0,n) dp[i][j]=1000000000000001;
    }
    cout<<fundp(0,n-1,a)<<endl;
 
}
signed main()
{
   faster;
   // int t;cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;

    x3=x2-(y2-y1);
    y3=y2+(x2-x1);

    x4=x3-(y3-y2);
    y4=y3+(x3-x2);

    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

    return 0;
}

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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N,M;
    cin >> N >> M;
    long long ans;
    vector<long long> res = enum_divisors(M);
    for(auto x: res) {
        if(x <= M/N)
            ans = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
line = input().split(" ")
a = []
alice = 0
bob = 0

for i in line:
    a.append(int(i))

a.sort(reverse = True)

for i in range(n):
    if(i % 2 == 0):
        alice += a[i]
    else:
        bob += a[i]

print(alice - bob)


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int su(ll n) {
  int res = 0;
  while(n) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int k; cin >> k;
  vector<ll> v;
  ll base = 1;
  REP(i, 15) {
    FOR(j, 1, 150) {
      v.push_back(base * (j+1) - 1);
    }
    base *= 10;
  }
  sort(ALL(v));
  v.erase(unique(ALL(v)), v.end());


  REP(i, SZ(v)) {
    FOR(j, i+1, SZ(v)) {
      int sui = su(v[i]), suj = su(v[j]);
      if(v[i] * suj > v[j] * sui) {
        v.erase(v.begin() + i--);
        break;
      }
    }
  }

  REP(i, k) {
    cout << v[i] << endl;
  }

}
























Measured memory_bytes: 384
// D - Powerful Discount Tickets
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

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

	// vi A(N);
	vector<ll> A(N);
	vector<pair<ll,int>> B;
	rp(i,N){
		int a; cin>>a;
		A[i] = a;
		while(a>0){
			B.push_back(make_pair(a - (a>>1), i));
			a>>=1;
		}
	}

	sort(allr(B));

	// for(auto e:A)cout<<e<<",";puts("\n");
	// for(auto e:B)cout<<"("<<e.first<<","<<e.second<<")\n";

	map<int,ll> counting;
	rp(i,N) counting[i] = 0;

	// ote("");
	// for(auto e:counting)cout<<"("<<e.first<<","<<e.second<<")\n";

	int e = min(M, (int)B.size());
	rp(i, e){
		counting[B[i].second]++;
	}

	// ote("");
	// for(auto e:counting)cout<<"("<<e.first<<","<<e.second<<")\n";

	ll ans = 0;
	rp(i,N){
		ans += (ll)A[i]/(1<<counting[i]);
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 68576
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)


int llist[10000];
int main(void){
    int n,m,cou = 0,l;

    scanf("%d",&n);
    REP(i,n){
        scanf("%d",&llist[i]);
    }

    REP(i,n){
        if(llist[i] > 2){
            m = sqrt(llist[i]);

            l = 1;
            REP(j,m - 1)
                if(llist[i] % (j + 2) == 0){
                    l = 0;
                    break;
                }
            cou += l;
        }else
            cou += (llist[i] == 2);
    }
    printf("%d\n",cou);
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    int maxv = 0;
    map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        m[s]++;
        chmax(maxv, m[s]);
    }

    vector<string> v;
    for(auto p: m){
        if(maxv == p.second) v.push_back(p.first);
    }
    sort(all(v));

    for(auto x: v) cout << x << endl;
}

Measured memory_bytes: 28788
S=input()
data=[-1 for i in range(len(S)+1)]
if S[0]=="<":data[0]=0
if S[-1]==">":data[-1]=0


for i in range(len(S)-1):
    if S[i]+S[i+1]=="><":
        data[i+1]=0
for i in range(len(S)):
    if data[i]>=0 and S[i]=="<":
        data[i+1]=data[i]+1
for i in range(len(S)-1,-1,-1):
    if data[i+1]>=0 and S[i]==">":
        if S[i-1]+S[i]=="<>" and i>=1:
            data[i]=max(data[i],data[i+1]+1)
        else:
            data[i]=data[i+1]+1
print(sum(data))


Measured memory_bytes: 24100
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    float r;
    cin >> r;
    float ans=6.28318530717958623200*r;
    cout << ans;
    
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll ans=-1;
        ll n,m;
        cin>>n>>m;
        ll sum=0;
        rep(i,0,m)
        {
            ll x;
            cin>>x;
            sum+=x;
        }
        cout<<max(ans,n-sum)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
#define MOD2 998244353
#define INF 1000000000000000000ll
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

void solve()
{
    ll n;
    cin >> n;
    vi A(n);
    rep(i,0,n)
    {
        cin >> A[i];
    }
    vi P(n+1, 0);
    rep(i,0,n)
    {
        P[i+1] = (P[i] + A[i]) % MOD;
    }
    ll ans = 0;
    //cout << smod(4,6) << endl;
    rep(i,0,n)
    {
        ans = (ans + ((A[i]*(P[n] - P[i+1])) % MOD) ) % MOD;
        ans = (ans + MOD) % MOD;
    }
    cout << ans % MOD << endl;
}

int main()
{
    cin.sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	/*ll t;
	cin >> t;
	while(t--)*/
		solve();
}


Measured memory_bytes: 6372
/*
  AtCoder Beginner Contest 085
  C - Otoshidama
*/

#include<iostream>
using namespace std;

int N, Y;

int main() {
  scanf("%d%d", &N, &Y);

  // 最小枚数
  int x, y, z;
  x = Y / 10000;
  Y -= 10000 * max(x, 0);
  y = Y / 5000;
  Y -= 5000 * max(y, 0);
  z = Y / 1000;

  while (x + y + z < N) {
    if (N - (x + y + z) >= 4 && y > 0) {
      y -= 1;
      z += 5;
    }
    else if (N - (x + y + z) >= 1 && x > 0) {
      x -= 1;
      y += 2;
    }
    else break;
  }

  if (x + y + z == N) printf("%d %d %d\n", x, y, z);
  else printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;
int x[1000001];
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans=0;
    rep(i, n){
        cin >> a[i];
        if(i>=1){
            if(a[i]<a[i-1]){
                ans+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 X;
    cin >> X;
    cout << YN("Yes", "No", X >= 30) << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
const int N = 1e5+10;
int n,k;
ll h[N];
ll dp[N];
int main(){
 	int n,k;
  	scanf("%d%d",&n,&k);
  	for(int i=1;i<=n;++i){
      cin>>h[i];
      dp[i] = inf;
    }
  	dp[1] = 0;
  	for(int i=1;i<=n;++i){
      for(int j=i+1;j<=min(i+k,n);++j){
        dp[j] = min(dp[j],dp[i]+1LL*abs(h[j]-h[i]));
      }
    }
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



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

	ll N = S.size();

	ll ans = 0;

	rep(i, N - 1) {
		if (S[i] != S[i + 1]) { ans++; }
	}

	cout << ans;

	system("PAUSE");
}

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

int main()
{
    int a[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;

    if(a[x-1]==a[y-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <numeric>
using namespace std;



//Trick or Treat
int main() {
	int n, k,d,a,cnt=0;
	vector<int> okasi;
	bool find = false;
	cin >> n >> k;
	for (int i = 0; i < k;i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> a;
			okasi.push_back(a);
		}
	}
	for (int i = 1; i <= n; i++) {
		find = false;
		for (int j = 0; j < okasi.size(); j++) {
			if (okasi[j] == i) {
				find = true;
				break;
			}
		}
		if (find == false) {
			cnt++;
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

constexpr int mod = 1e9 + 7;

struct modint {
  int n;
  modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= mod ? a.n - mod : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + mod : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % mod); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

modint dp[60][3][3];

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

  string a[2];
  cin >> a[0] >> a[1];

  if (a[0][0] == a[1][0]) {
    for (int i = 0; i < 3; i++) {
      dp[0][i][i] = 1;
    }
  } else {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        dp[0][i][j] = i != j;
      }
    }
  }

  for (int i = 1; i < n; i++) {
    if (a[0][i] == a[1][i]) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          for (int l = 0; l < 3; l++) {
            if (l == j || l == k) continue;
            dp[i][l][l] += dp[i - 1][j][k];
          }
        }
      }
    } else if (a[0][i] == a[0][i - 1]) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          dp[i][j][k] += dp[i - 1][j][k];
        }
      }
    } else {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          for (int l = 0; l < 3; l++) {
            for (int m = 0; m < 3; m++) {
              if (j == l || k == m || l == m) continue;
              dp[i][l][m] += dp[i - 1][j][k];
            }
          }
        }
      }
    }
  }

  modint ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      ans += dp[n - 1][i][j];
    }
  }
  cout << ans.n << endl;
}

Measured memory_bytes: 256
import numpy as np
N= int(raw_input())
edge_list = [[] for i in range(N+1)]
for i in range(N-1):
	x,y = list(map(int, raw_input().split()))
	edge_list[x].append(y)
	edge_list[y].append(x)

dist_1 = [0] * (N+1)
dist_7 = [0] * (N+1)
point_1 = []
point_1 = []
point_7 = []
used_edge_1 = []
used_edge_7 = []
for point in edge_list[1]:
	dist_1[point] = 1
	point_1.append(point)

for point in edge_list[N]:
	dist_7[point] = 1
	point_7.append(point)


while len(point_1) != 0:
	v = point_1.pop()
	for u in edge_list[v]:
		if dist_1[u] == 0:
			point_1.append(u)
			dist_1[u] = dist_1[v] + 1


while len(point_7) != 0:
	v = point_7.pop()
	for u in edge_list[v]:
		if dist_7[u] == 0:
			point_7.append(u)
			dist_7[u] = dist_7[v] + 1


total_point = 0
for point in range(2,N):
	if dist_1[point] <= dist_7[point]:
		total_point += 1

if total_point > (N-2 - total_point):
	print "Fennec"
else:
	print "Snuke"


Measured memory_bytes: 36940
int main(void){
  int i;
  char x[1001];

  scanf("%s",x);
  for(i=0;x[i]!='\0';i++){
    if(x[i]-3 < 'A'){
      putchar('Z'-'A'+x[i]-3+1);
    }
    else{
      putchar(x[i]-3);
    }
  }
  putchar('\n');

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000009
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int dp[105][100005];
int wt[101],val[101];
int n,w;

int solve(int i, int x){
	if(i==n && x==0) return 0;
	if(i==n || x<0) return INT_MAX;
	if(dp[i][x]!=-1) return dp[i][x]; 
	return dp[i][x]=min(solve(i+1,x-val[i])+wt[i],solve(i+1,x));
}

signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n >> w;

	int sum = 0;
	for0(i,n){
		cin >> wt[i] >> val[i];
		sum += val[i];
	}

	memset(dp,-1,sizeof(dp));

	for(int i=sum;i>=0;i--){
		if(solve(0,i) <= w){
			cout << i;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 85624
def main():
    n = int(input())
    start_word = input()

    used_words = [start_word]
    result = 'Yes'
    for _ in range(n-1):
        word = input()
        if used_words[-1][-1] == word[0] and word not in used_words:
            used_words.append(word)
        else:
            result = 'No'
            break

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
#define hsh 821
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,c[505][4],hs[505][4],req[4];
LL res,cur;
int HS(int A,int B,int C,int D){
	return ((((A*hsh)+B)*hsh)+C)*hsh+D;
}
map < int , int > cnt;
int coincide(int X,int A,int B,int C,int D){
	int R=0;
	if(c[X][0]==A && c[X][1]==B && c[X][2]==C && c[X][3]==D) ++R;
	if(c[X][1]==A && c[X][2]==B && c[X][3]==C && c[X][0]==D) ++R;
	if(c[X][2]==A && c[X][3]==B && c[X][0]==C && c[X][1]==D) ++R;
	if(c[X][3]==A && c[X][0]==B && c[X][1]==C && c[X][2]==D) ++R;
	return R;
}
int coincide(int X,int Y,int Z,int W,int A,int B,int C,int D){
	int R=0;
	if(X==A && Y==B && Z==C && W==D) ++R;
	if(Y==A && Z==B && W==C && X==D) ++R;
	if(Z==A && W==B && X==C && Y==D) ++R;
	if(W==A && X==B && Y==C && Z==D) ++R;
	return R;
}
int coincideX(int X,int Y,int I,int D1,int D2){
	return
	coincide(c[X][D1],c[X][(D1+1)&3],c[Y][(D1+1+I)&3],c[Y][(D1+I)&3],
			 c[X][D2],c[X][(D2+1)&3],c[Y][(D2+1+I)&3],c[Y][(D2+I)&3]);
}
int coincideY(int P,int X,int Y,int I,int D){
	return
	coincide(P,c[X][D],c[X][(D+1)&3],c[Y][(D+1+I)&3],c[Y][(D+I)&3]);
}
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k,l,h;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		for(j=0;j<4;++j){
			scanf("%d",&c[i][j]);
			++c[i][j];
		}
		hs[i][0]=HS(c[i][0],c[i][1],c[i][2],c[i][3]);
		hs[i][1]=HS(c[i][1],c[i][2],c[i][3],c[i][0]);
		hs[i][2]=HS(c[i][2],c[i][3],c[i][0],c[i][1]);
		hs[i][3]=HS(c[i][3],c[i][0],c[i][1],c[i][2]);
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    for(i=n-1;i>=0;--i){
		reverse(c[i],c[i]+4);
		for(j=i+1;j<n;++j){
			for(k=0;k<4;++k){
				req[0]=HS(c[i][0],c[i][1],c[j][(k+1)&3],c[j][k]);
				req[1]=HS(c[i][1],c[i][2],c[j][(k+2)&3],c[j][(k+1)&3]);
				req[2]=HS(c[i][2],c[i][3],c[j][(k+3)&3],c[j][(k+2)&3]);
				req[3]=HS(c[i][3],c[i][0],c[j][k],c[j][(k+3)&3]);
				cur=1ll;
				for(l=0;l<4;++l){
					if(!cnt[req[l]]){
						cur=0ll;
						break;
					}
					int num=cnt[req[l]]-coincideY(j,i,j,k,l);
					for(h=0;h<l;++h){
						num-=coincideX(i,j,k,h,l);
					}
					cur*=(LL)num;
				}
				res+=cur;
			}
		}
		reverse(c[i],c[i]+4);
		for(j=0;j<4;++j) ++cnt[hs[i][j]];
	}
	printf("%lld\n",res);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	double ans = 0;
	for (int i = 1; i <= a; i++) {
		double tmp = 1.0/a;
		int now = i;
		while (now < b) {
			now *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	printf("%.12f\n", ans);
	return 0;
}

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

int main(){
	long n, a;
	char c;
	
	scanf(" %ld", &n);
	
	while(1){	
		scanf(" %c", &c);
		if(c=='=') break;
		else{
			long a;
			scanf(" %ld", &a);
			
			if(c=='+') n+=a;
			else if(c=='-') n-=a;
			else if(c=='*') n*=a;
			else if(c=='/') n/=a;
		}
	}	
	
	printf("%ld\n", n);

	return 0;
}

Measured memory_bytes: 1188
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int sum=0;

    if(n<k){
        sum+=n*x;
        cout<<sum<<endl;

    }
    else{
        sum+=(k)*x+(n-k)*y;
        cout<<sum<<endl;
    }
}



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

int main() {
    int n,sum = 0;
    bool do_div = true;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%2 != 0){
            do_div = false;
        }
    }
    while(do_div == true){
        for(int i = 0; i < n; i++){
            a[i] /= 2;   
            if(a[i]%2 != 0){
                do_div = false;
                break;
            }
        }
        sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

answer_list = [0]*N

for _ in range(M):
  A, B = map(int, input().split())
  if H[A-1] > H[B-1]:
    answer_list[(B-1)] += 1
  elif H[B-1] > H[A-1]:
    answer_list[(A-1)] += 1
  else:
    answer_list[(A-1)] += 1
    answer_list[(B-1)] += 1
    
print(answer_list.count(0))

Measured memory_bytes: 20116
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll K,t,ans=0;
    cin >>K;
    K++;
    repd(a,1,K)repd(b,1,K){
        t=gcd(a,b);
        repd(c,1,K){
            ans+=std::gcd(t,c);
        }

    }


    cout << ans <<endl;


    return (0);
}

Measured memory_bytes: 3648
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  string s,t; cin>>s>>t;
  int a,b; cin>>a>>b;
  string u; cin>>u;
  if(u==s) cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
  return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,c,k,cnt=0,time,j,p_cnt;
  cin >> n >> c >> k;
  int t[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  sort(t,t+n);
  for(int i=0;i<n;i++){
    cnt++;
    time=t[i]+k;
    j=i;
    p_cnt=0;
    while(j<n&&t[j]<=time&&p_cnt<c){
      j++;
      p_cnt++;
    }
    i=j-1;
    
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<bool>>;
const int MOD = 1e9 + 7;

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

    int N, K;
    cin >> N >> K;
    vector<pii> xy(N);
    for (int i = 0; i < N; ++i)
        cin >> xy[i].first >> xy[i].second;
    sort(xy.begin(), xy.end());

    ll ans = LLONG_MAX;
    for (int t = 0; t < N; ++t) {
        for (int b = 0; b < N; ++b) {
            int cnt = 0;
            for (int l = 0, r = 0; l < N; ++l) {
                while (r < N && cnt < K) {
                    if (xy[r].second >= xy[b].second && xy[r].second <= xy[t].second)
                        cnt++;
                    r++;
                }
                if (cnt < K)
                    break;
                ans = min(ans, (ll)(xy[r - 1].first - xy[l].first) * (xy[t].second - xy[b].second));
                if (xy[l].second >= xy[b].second && xy[l].second <= xy[t].second)
                    cnt--;
            }
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL a;
    LL b;
    LL c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String str2 = str.toUpperCase();
        String str3 = str.toLowerCase();
        String ans ="";

        for(int i=0;i<str.length();i++) {
        	if(str.charAt(i)==str2.charAt(i)) {//str.charAt(i)はchar一文字
        		ans =ans +  String.valueOf(str3.charAt(i));//Stringに変換
        	}else {
        		ans = ans + String.valueOf(str2.charAt(i));
        	}
        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 31256
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
#include<cmath>
#include<iterator>
typedef long long ll;
using namespace std;
#define rep(x, y)   for (ll i = x; i <= y; i ++)
#define repi(x, y)  for (ll i = x; i >= y; i --)
priority_queue< ll > cancel;
ll arr[200005];
ll brr[200005];
ll dp[200005];
int main()
{
    ll test=1;
    // cin>>test;
    for(ll z=0;z<test;z++)
    {
        ll n,k;
        cin>>n>>k;
        for(ll i=1;i<=n;i++)
        {
            cin>>arr[i];
        }
        dp[0]=0;        
        dp[1]=0;
        dp[2]=abs(arr[2]-arr[1]);
        for(ll i=3;i<=n;i++)
        {
            dp[i]=9999999999999;
            for(ll j=1;j<=min(i-1,k);j++)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        // for(ll i=0;i<=n;i++)
        // {
        //     cout<<dp[i]<<" ";
        // }
        // cout<<endl;
        cout<<dp[n]<<endl;
    }
}

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

using namespace std;

int main(void) {
  string T; cin >> T;

  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }

  cout << T << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    int x;
    cin >> x;
    int a = 0, b = 0;
    a = x/500;
    b = x%500/5;

    cout << 1000 * a + 5 * b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int q = Integer.parseInt(sc.next());

        boolean isReverse = false;
        StringBuffer head = new StringBuffer();
        StringBuffer foot = new StringBuffer();
        for (int i = 0; i < q; i++) {
            String query = sc.next();
            if ("2".equals(query)) {
                String func = sc.next();
                if (("1".equals(func) && !isReverse) || ("2".equals(func) && isReverse)) {
                    head.insert(0, sc.next());
                } else {
                    foot.append(sc.next());
                }
            } else {
                isReverse = !isReverse;
            }
        }

        StringBuffer result = new StringBuffer(head + s + foot);

        if (isReverse) {
            result.reverse();
        }

        // 出力
        System.out.println(result.toString());
        sc.close();
    }
}

Measured memory_bytes: 81160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[vec[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<endl;
  }
}

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

int main() {
	long long n, x, p = -1, ans = 0;
	cin >> n;
	for (long long i = 1; i <= n; i++) {
		cin >> x;
		if (p > x) {
			ans += p - x;
			x = p;
		}
		p = x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3556
#include<iostream>

using namespace std;

const int MAX_N = 100000;

int N;
int H[MAX_N+1];

int main() {
    cin >> N;
    for (int i = 1; i < N+1; i++) {
        cin >> H[i];
    }
    int ans = 0;;
    int tmp_ans = 0;
    for (int i = N; i > 0; i--) {
        if (i < N) {
            if(H[i] >= H[i+1]) {
                tmp_ans += 1;
            } else {
                tmp_ans = 0;
            }
        }
        ans = max(ans, tmp_ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    //現在, 文字列のうち,　先頭から何番目に位置するかを示す
  map<char, int> pages;
  
  map<char, string> cards;
  
  cin >> cards['a'] >> cards['b'] >> cards['c'];
  
  char turn = 'a'; //現在が誰のターンであるかを示す
  
  //ターンの人がカードをすべて使い切ったか否かを確認する.
  while (pages[turn] != cards[turn].size()) {
      
    turn = cards[turn][pages[turn]++];
    
  }
  
  cout << (char)toupper(turn) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections

def solve(N: int):
    ans = []
    for x in range(1, 101):
        x2 = x **2
        for y in range(1, 101):
            y2 = y **2
            for z in range(1, 101):
                z2 = z**2
                f = x2 + y2 + z2 + x*y + y*z + z*x

                if f > 10**4:
                    pass
                else:
                    ans.append(f)
    freq = collections.Counter(ans)

    for i in range(1, N+1):
        if i in freq.keys():
            print(freq[i])
        else:
            print(0)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19720
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long q = sc.nextLong();
    long h = sc.nextLong();
    long s = sc.nextLong();
    long d = sc.nextLong();
    long n = sc.nextLong();

    long onel = Math.min(Math.min(4 * q, 2 * h), s);
    long twol = Math.min(onel * 2, d);
    if ((onel * 2) >= d) {
      System.out.println((twol * (n / 2)) + (onel * (n % 2)));
    } else {
      System.out.println(onel * n);
    }

  }
}

Measured memory_bytes: 35552
N,M=(int(i) for i in input().split())
gate=[]
for i in range(M):
    gate.append([int(i) for i in input().split()])
    
maxl=max(gate,key=lambda x:x[0])[0]
minr=min(gate,key=lambda x:x[1])[1]
if maxl<=minr:
    print(minr-maxl+1)
else:
    print(0)

Measured memory_bytes: 59736
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m);
	for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
	sort(l.rbegin(), l.rend());
	sort(r.begin(), r.end());
	int x = r[0] - l[0] + 1;
	if (x > 0) {
		cout << x << endl;
	}
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1024