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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }

// 4近傍（右, 下, 左, 上）
const std::vector<int> dy = { 0, -1, 0, 1 };
const std::vector<int> dx = { 1, 0, -1, 0 };

using namespace std;



int main() {
    int N;
    cin >> N;
    vector<pair<LL, LL>> l_r;

    LL max_ball = 0;
    LL min_ball = INT_MAX;
    FOR(i, 0, N) {
        LL l, r;
        cin >> l >> r;
        if (l > r) { swap(l, r); }

        max_ball = max(max_ball, r);
        min_ball = min(min_ball, l);
        l_r.emplace_back(make_pair(l, r));
    }
    sort(ALL(l_r));

    LL ans = LONG_LONG_MAX;
    // r_max = max_ball and r_min = min_ball
    {
        LL r_max = max_ball;
        LL r_min = min_ball;

        set<pair<LL, int>> blue_set;   // (value, index)    indexがINT_MAXなら入れ替えられない
        blue_set.insert({l_r[0].second, INT_MAX});
        // 仮に大きい方をblueとする(r_maxもはいっちゃうけど答えにはならないので無視できる)
        FOR(i, 1, N) {
            blue_set.insert({l_r[i].second, i});
        }
        while (true) {
            auto b_max = *blue_set.rbegin();
            LL diff = b_max.first - blue_set.begin()->first;
            ans = min(ans ,(r_max - r_min) * diff);

            // 入れ替え
            blue_set.erase(*blue_set.rbegin());
            if(b_max.second >= INT_MAX) {
                break;
            }
            blue_set.insert({l_r[b_max.second].first, INT_MAX});
        }
    }
    // r_max = max_ball and b_min = min_ball
    {
        LL r_max = max_ball;
        LL r_min = LONG_LONG_MAX;
        LL b_max = -1;
        LL b_min = min_ball;
        FOR(i, 0, N) {
            b_max = max(b_max, l_r[i].first);   // なるべく小さい方がいいのでfirstから探す
            r_min = min(r_min, l_r[i].second);  // なるべく大きい方がいいのでsecondから探す
        }
        ans = min(ans, (r_max - r_min) * (b_max - b_min));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16748
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

struct tree {
    int first, second;
    int length;

    tree(int a, int b, int c) {
        first = a;
        second = b;
        length = c;
    }
};

bool cmp(const tree &a, const tree &b) {
    if (a.first < b.first) return true;
    if ((a.first == b.first) && (a.second < b.second)) return true;
    
    return false;
}

signed main() {
    int N;
    cin >> N;
    vector<tree> S;
    for (int i = 0 ; i < N - 1; i++) {
        int temp1, temp2, temp3;
        cin >> temp1 >> temp2 >> temp3;
        S.push_back(tree(temp1, temp2, temp3));
    }
    // sort(S.begin(), S.end(), cmp);
    queue<tree> check;
    for (int i = 0; i < N - 1; i++) {
        check.push(S[i]);
    }

    vector<int> ans(N + 5, -1);
    tree temp = check.front();
    if (temp.length % 2 != 0) {
        ans[temp.first] = 0;
        ans[temp.second] = 1;
    } else {
        ans[temp.first] = 0;
        ans[temp.second] = 0;
    }
    check.pop();
    while(!check.empty()) {
        temp = check.front();
        check.pop();
        if (ans[temp.first] == -1 && ans[temp.second] == -1) {
            check.push(temp);
            continue;
        }
        if (ans[temp.first] == -1) {
            if (temp.length % 2 == 0) ans[temp.first] = ans[temp.second];
            else ans[temp.first] = (ans[temp.second] == 0);
        } else if (ans[temp.second] == -1) {
            if (temp.length % 2 == 0) ans[temp.second] = ans[temp.first];
            else ans[temp.second] = (ans[temp.first] == 0);
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 305
using namespace std;

int n, m, ans = N, a[N][N], h[N], var[N], ind[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d",&a[i][j]);
	for(int i = 1; i <= m; i++)
		var[i] = 1;
	var[0] = 1;
	for(int i = 1; i <= n; i++)
		ind[i] = 1;
	for(int k = 1; k <= m; k++){
		for(int i = 1; i <= m; i++)
			h[i] = 0;
		int mxx = 0;
		for(int i = 1; i <= n; i++){
			h[a[i][ind[i]]]++;
			mxx = max(mxx, h[a[i][ind[i]]]);
		}
		ans = min(ans, mxx);
		pair < int , int > mx = mp(0, 0);
		for(int i = 1; i <= m; i++)
			if(var[i])
				mx = max(mx, mp(h[i], i));
		var[mx.nd] = 0;
		for(int i = 1; i <= n; i++){
			while(!var[a[i][ind[i]]])
				ind[i]++;
			if(ind[i] > m){
				printf("%d\n", ans);
				return 0;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())


#n,*a = [int(i) for i in read().split()]

    
n = int(input())
    
print((n+1)//2)    
    
    
    
    
    
    
    


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();

		int c[] = new int[N];
		int t[] = new int[N];
		int cnt = 0;

		for (int i = 0; i < N; i++) {
			c[cnt] = sc.nextInt();
			t[cnt] = sc.nextInt();
			if (t[cnt] <= T) {
				cnt++;
			}
		}
		int minC = 1001;
		// 指定時間内無
		if (cnt == 0) {
			System.out.println("TLE");
		} else {
			
			for (int i = 0; i < cnt; i++) {
				if (minC > c[i]) {
					minC = c[i];
				}
			}
			if (minC == 1001) {
				System.out.println("TLE");
			}else {
				System.out.println(minC);
			}

		}

	}

}

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



int main()
{
    ios::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;
    vector<double> a(n);
    for(auto &c:a) cin >>c;
    sort(a.rbegin(),a.rend());
    double tmp = accumulate(a.begin(),a.end(),(double)0)/(4*m);
    for(int i=0;i<m;++i){
        if (a[i]<tmp){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes" ;
    return 0;
}


Measured memory_bytes: 3776
if __name__ == '__main__':
    n, k = map(int, input().split())
    ans = input()

    if n ==1:
        ans = ans.lower()
    elif n==2:
        if k == 1:
            ans = ans[0].lower() + ans[1]
        else:
            ans = ans[0]+ ans[1].lower()

    else:
        if k == 1:
            ans = ans[0].lower() + ans[1:n]
        elif k == n:
            ans = ans[0:n-1] + ans[n-1].lower()
        else:
            ans = ans[0:k - 1] + ans[k - 1].lower() + ans[k:n]

    print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A,B) << endl;
  if(A+B - N > 0){
    cout << A + B - N << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
	int a,b,c,i,cnt;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;
	i=0;
	while(cnt<c)	{
		i++;
		cnt+=a;
		if(i%7==0)	cnt+=b;
	}
	printf("%d\n",i);
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll,ll>> P(N+1);
    REP(i,1,N+1) {
        cin >> P[i].first;
        P[i].second = i;
    }
    ASC(P);

    multiset<ll> S;
    S.insert(0); S.insert(0);
    S.insert(N+1); S.insert(N+1);

    // wi < xi < i < yi < zi
    ll wi, xi, yi, zi;
    ll sum = 0;
    for(ll j=N; j>=1; --j) {
        ll i = P[j].second;
        auto itr = S.lower_bound(i); 
        --itr; --itr; wi = *itr;
        ++itr; xi = *itr;
        ++itr; yi = *itr;
        ++itr; zi = *itr;
        S.insert(i);
        sum += P[j].first * ((xi-wi)*(yi-i) + (i-xi)*(zi-yi));
    }

    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 9504
n, m = map(int, input().split()) 
dict = {}
ans = 0

for i in range(m):
    dict[i+1] = 0

for _ in range(n):
    res = list(map(int, input().split()))
    for j in res[1:]:
        dict[j] = dict[j]+1

for k in dict:
    if dict[k] == n:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
  double r;
  cin >>r;

  cout << fixed<< setprecision(9) << r*r*M_PI;
  cout << " ";
  cout << fixed<< setprecision(9) << 2*r*M_PI;
  cout << endl;
}



Measured memory_bytes: 3276
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(0, A+1):
	for j in range(0, B+1):
		for k in range(0, C+1):
			if 500*i+100*j+50*k == X:
				cnt += 1
print(cnt)

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

const int N = 1e5 + 5;
int cnt[N], n, m;

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

	std::cin >> n >> m;
	while (m --) {
		int a, b; std::cin >> a >> b;
		++ cnt[a]; ++ cnt[b];
	}

	bool jieti = false;
	for (int i = 1; i <= n; ++ i)
		if (cnt[i] % 2) jieti = true;

	if (jieti) std::cout << "NO" << std::endl;
	else std::cout << "YES" << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

ll D, G;
ll ans = 1<<30;

int main() {
    cin >> D >> G;
    vector<ll> p(D), c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];

    ll ans = 1<<30;
    for(int i = 0; i < 1<<D; i++) {
        ll sn = 0, ss = 0;
        int r = -1;
        for(int j = 0; j < D; j++) {
            if((i>>j) & 1) {
                sn += p[j];
                ss += 100 * (j+1) * p[j] + c[j];
            } else {
                r = max(r, j);
            }
        }
        if((G-ss) > 0 && r >= 0) {
            ll val = 100 * (r+1);
            if(((G-ss) + val - 1) / val > p[r]) continue;
            sn += ((G-ss) + val - 1) / val;
        }
        ans = min(ans, sn);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
int main() {

    ll N;
    cin >> N;
    ll ans = 1, T;

    rep(i, N) {
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans;

    return 0;
}

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

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    char board[h][w];
    REP(i,h) REP(j,w) cin >> board[i][j];

    int hold=0,mincount=1000000,mincount2=1000000;

    REP(i,h){
        int count=0;
        REP(j,w){
            if(board[i][j]=='.'){
                count++;
            }
        }
        if(count<mincount)  mincount=count;
        if(count==w){
            REP(j,w){
                board[i][j]='A';
            }
            hold++;
        }
    }

    cout << endl;

    REP(j,w){
        int count=0;
        REP(i,h){
            if(board[i][j]=='.'){
                count++;
            }
        }
        if(count<mincount2) mincount2=count;
        if(count==h-hold){
            REP(i,h){
                board[i][j]='A';
            }
        }
    }

    REP(i,h){
        int count2=0;
        REP(j,w){
            if(board[i][j]!='A'){
                cout << board[i][j];
                count2++;
            }
        }
        //cout << count2 << endl;
        cout << endl;
    }
    return 0;
}

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

const int INF = 1LL << 60;

void warshallFloyd(const int V, vector<vector<pair<int, int>>> & G, int L) {
    for (int v = 0; v < V; v++) {
        G[v][v] = {0, 0};
    }
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                if(G[i][k].first >= INF || G[k][j].first >= INF)
                    continue;
                G[i][j].first = min(G[i][j].first, G[i][k].first + G[k][j].first);
            }
        }
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j ++) {
            G[i][j].second = min(G[i][j].second, G[i][j].first <= L ? 1 : INF);
        }
    }
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                if(G[i][k].second >= INF || G[k][j].second >= INF)
                    continue;
                G[i][j].second = min(G[i][j].second, G[i][k].second + G[k][j].second);
            }
        }
    }
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<pair<int, int>>> G(N, vector<pair<int, int>>(N, {INF, INF}));
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        G[a][b] = {c, (c <= L ? 1 :INF)};
        G[b][a] = {c, (c <= L ? 1 :INF)};
    }
    warshallFloyd(N, G, L);
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        cout << (G[s][t].second >= INF - 1 ? -1 : G[s][t].second - 1) << endl;
    }
    return 0;
}


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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

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

    int counter = 0;
    while (1)
    {
        bool flag = false;
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 1)
            {
                flag = true;
                break;
            }
            a[i] /= 2;
        }

        if (flag)
        {
            break;
        }
        counter++;
    }

    cout << counter << 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);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println( (a <= c && c <= b) ? "Yes" : "No" );
    }

}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
int n,k;
char s[10001];
int main()
{
	cin>>n>>k;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)if(i==k)printf("%c",s[i]+32);else printf("%c",s[i]);
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VP A(N + 1);
	A[0].first = 0;
	REP(i, N)cin >> A[i+1].first >> A[i+1].second;

	SORT(A);
	int ans = 0;
	int cnt = LLINF;
	FOR(i,1, N+1) {
		ans += min(cnt - A[i].second, A[i].first - A[i - 1].first);
		cnt = A[i].second;
	}

	cout << ans+cnt << endl;

	return 0;
}



Measured memory_bytes: 1792
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var s int
	fmt.Scan(&s)
	dp := make([]int, s+1)
	for i := 0; i <= s; i++ {
		if i < 3 {
			dp[i] = 0
			continue
		}
		for j := 3; j <= i; j++ {
			if i-j == 0 {
				dp[i] += 1
			} else {
				dp[i] += dp[i-j]
			}
		}
		dp[i] %= mod
	}
	ans := dp[s]
	ans %= mod
	fmt.Println(ans)
}


Measured memory_bytes: 1784
import java.util.Scanner;

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

    for(int i = 0; i<4; i++){
      if(S.charAt(i) == '+'){
        n++; //入力された文字列の先頭からi番目の文字が'+'ならnの値を1増やす(先頭は0番目と見做すことに注意)
      }else{
        n--; //'+'でなければnの値を1減らす
      }
    }
    System.out.println(n);
  }
}


Measured memory_bytes: 20692
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
vector<int>T[100001];
int b;
long long w;
void dfs(int x,int la,int t){
	int r=0;
	for(int i=0;i<T[x].size();i++){
		int y=T[x][i];
		if(y==la)continue;
		w=(w*(b-t-r))%M,r++,dfs(y,x,t==2?2:t+1);
	}
}
int main() {
	int a,i,x,y;
	cin>>a>>b;
	for(i=1;i<a;i++)scanf("%d%d",&x,&y),T[x].push_back(y),T[y].push_back(x);
	w=b,dfs(1,0,1),cout<<w;
}

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

using namespace std;

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

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll l,r;

int main(){
    cin >> l >> r;
    ll ans = INF;
    ll b = l / 2019;
    if(r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }
    rep(i,2019){
        FOR(j,i+1,2019){
            if(l <= i + b*2019 && j + b*2019 <= r)ans = min(ans,(i*j%2019));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MODNUM 1000000007

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

	return result;
}

long long modinv(long long a, long long mod){
	return modpow(a, mod - 2, mod);
}


int main(){
	int n, a, b;
	long long ans = 0;
	int i;
	long long m, c;

	scanf("%d %d %d", &n ,&a, &b);

	ans = (modpow(2, n, MODNUM) - 1) % MODNUM;

	m = 1;
	c = n;
	for(i=2; i<=a; i++){
		m = m * i % MODNUM;
		c = c * (n-i+1) % MODNUM;
	}
	ans = (ans - c * modinv(m, MODNUM)) % MODNUM;
	for(; i<=b; i++){
		m = m * i % MODNUM;
		c = c * (n-i+1) % MODNUM;
	}
	ans = (ans - c * modinv(m, MODNUM)) % MODNUM;

	while(ans < 0){
		ans += MODNUM;
	}

	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 128
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(a[k - 1])


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		reader.close();
		
		final int[] coins = {25,10,5,1};
		int ans = 0;
		int remain = n;
		
		for (int coin : coins) {
			int tmp = remain / coin;
			ans += tmp;
			remain -= coin * tmp;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24316
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 998244353;

ll mod_pow(ll x, ll n, const ll &p) {
  ll ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i,N) {
        int di;
        cin >> di;
        if (i == 0 && di != 0) {
            cout << 0 << endl;
            return 0;
        }
        D[di]+=1;
    }
    if (D[0]!=1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    int done = 1;
    int precnt = 1;
    srep(i,1,N) {
        int cnt = D[i];

        //cout << "i: " << i << " cnt: " << cnt << endl;
        if (cnt==0 && done != N) {
            cout << 0 << endl;
            return 0;
        }
        else {
            //cout << "i: " << i << " cnt: " << cnt << endl;
            ll mul = mod_pow(precnt, cnt, mod);
            ans = ans * mul % mod;
            done += cnt;
        }
        precnt = cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 300000+10;

int32_t main(){
	fast_io;
	int n;
	cin >> n;
	if(n == 1){
		pret(0);
	}
	int ten = 1;
	int nine = 1;
	int eight = 1;
	while(n--){
		ten = (ten * 10ll) % MOD;
		nine = (nine * 9ll) % MOD;
		eight = (eight * 8ll) % MOD;
	}
	int ans = ten - (2ll * nine - eight);
	ans %= MOD;
	if(ans < 0) ans += MOD;
	show(ans);
	return 0;
}

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

using namespace std;
const int Max_Num=100010;

int main(){
	int N, u, v;
	cin >> N >> u >> v;
	u--; v--;
	vector<int> G[Max_Num];
	rep(i,N-1){
		int A, B;
		cin >> A >> B;
		A--; B--;
		G[A].emplace_back(B);
		G[B].emplace_back(A);
	}
	int dAoki[Max_Num], dTaka[Max_Num];
	rep(i,N){
		dAoki[i]=-1;
		dTaka[i]=-1;
	}
	dAoki[v]=0;
	dTaka[u]=0;
	queue<int> Aoki, Taka;
	Aoki.push(v);
	Taka.push(u);
	while(!Aoki.empty()){
		int pos=Aoki.front();
		Aoki.pop();
		rep(i,G[pos].size()){
			if(dAoki[G[pos][i]]!=-1) continue;
			Aoki.push(G[pos][i]);
			dAoki[G[pos][i]]=dAoki[pos]+1;
		}
	}
	while(!Taka.empty()){
		int pos=Taka.front();
		Taka.pop();
		rep(i,G[pos].size()){
			if(dTaka[G[pos][i]]!=-1) continue;
			Taka.push(G[pos][i]);
			dTaka[G[pos][i]]=dTaka[pos]+1;
		}
	}
	int dif=0;
	rep(i,N) if(dTaka[i]<dAoki[i]&&dif<dAoki[i]) dif=dAoki[i];
	cout << dif-1 << endl;

  return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

struct UnionFind {
    vector<int> parent; //parent[i]はiの親の番号
    vector<int> rank; // rank[i]は木の深さ
    vector<int> size; // size[i]はグループに含まれている頂点数
    vector<int> loop; // グループに含まれているloopの数

    UnionFind(int n) {
        //コンストラクタは全て自分が根
        parent = vector<int>(n);
        rank = vector<int>(n);
        size = vector<int>(n);
        loop = vector<int>(n);
        for (int i=0;i<n;i++) {
            parent[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    int root(int x) { //根を再帰で辿りつつ、探索したものを繋ぎなおし
    if (parent[x] == x) return x;
    return parent[x] = root(parent[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) {
            loop[rx]++;
            return;
        }
        if (rank[rx] < rank[ry]) {
            parent[rx] = ry;
            size[ry] += size[rx];
            loop[ry] += loop[rx];
        }
        else {
            parent[ry] = rx;
            size[rx] += size[ry];
            loop[rx] += loop[ry];
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[root(x)];
    }

    int getLoopNum(int x){
        return loop[root(x)];
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    for (int i=0;i<N;i++) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf = UnionFind(N);
    for (int i=0;i<M;i++){
        int x, y;
        cin >> x >> y;
        x--;y--;
        uf.unite(x,y);
    }
    int ans = 0;
    for (int i=0;i<N;i++){
        if (uf.same(i,p[i])) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[19];
    int i,j;
    scanf("%s",s);
    if(strlen(s)!=19) j=strlen(s)-1;
    else j=19;
    for(i=j;i>=0;i--){
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int n, k;
bool dp[5050][5050]; //dp[i][j]: i枚目まで使ったとき総和をjにできるか
vector<int> v;

bool check(int x) { //xが必要か不要か
	int n = (int)v.size();
	memset(dp, false, sizeof(dp));
	dp[0][0] = true;

	rep(i, n) {
		rep(j, k) {
			dp[i + 1][j] = dp[i + 1][j] || dp[i][j];
			if (j + v[i] < k && dp[i][j] && x != i) dp[i + 1][j + v[i]] = true;
		}
	}

	rep(j, k) {
		if (dp[n][j] && j + v[x] >= k) return true; //必要
	}
	return false; //不要
}

int main()
{
	cin >> n >> k;
	rep(i, n) {
		int a;
		cin >> a;
		if (a < k) v.push_back(a); //k未満のa
	}
	sort(v.begin(), v.end());
	
	int ok = (int)v.size(), ng = -1; //にぶたん(どこまでが不要か)
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (check(mid)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	cout << ng + 1 << endl;
	return  0;
}

Measured memory_bytes: 25216
#include <iostream>

using namespace std;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    int i, j, k;
    for (i = 0; i <= A; i++) {
        for (j = 0; j <= B; j++) {
            for (k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front

int main() {
    fastread;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll turn=0;
    while(a>0&&c>0){
        if(turn==0){
            c-=b;
        }
        else
            a-=d;
        turn=(turn+1)%2;
        if(a<=0){
            cout<<"No\n";
            return 0;
        }
        else if(c<=0){
            cout<<"Yes\n";
            return 0;
        }
        ///cout<<a<<" "<<c<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

ll a,b,n;
ll solve(){
   ll ans=0;
   
   if(n<b)ans=(a*n)/b;
   else ans=(a*(b-1))/b;
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>a>>b>>n;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int a,b;
	std::cin>>a>>b;
	if(a>=b)
		std::cout<<1;
	std::cout<<0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
int n;
typedef long long ll;
int read(){
	char ch=getchar();
	int f=1,x=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int lowbit(int x){
	return x&(-x);
}
int main(){
	int t,x;
	cin>>t>>x;
	double ans=1.0*t/x;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
const int N = 100000;
int par[N];
int rank[N];
 
void init(int n){
    for (int i = 0; i < n; ++i){
        par[i] = i;
        rank[i] = 0;
    }
}
 
int find(int x){
    if (par[x] == x)return x;
    return par[x] = find(par[x]);
}
 
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y)return;
    if (rank[x] < rank[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if (rank[x] == rank[y])rank[x]++;
    }
}
 
bool same(int x, int y){
    return find(x) == find(y);
}
 
struct edge {
    int u, v, cost;
};
 
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
 
edge es[1000000];
int V, E;
 
int kruskal(){
    std::sort(es, es + E, comp);
    init(V);
    int res = 0;
    for (int i = 0; i < E; ++i){
        edge e = es[i];
        if (!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}
 
int main(){
    while (1){
        scanf("%d", &V);
        if (V == 0)break;
        scanf("%d", &E);
        for (int i = 0; i < E; ++i){
            int a, b, c;
            scanf("%d,%d,%d", &a, &b, &c);
            es[i].u = a, es[i].v = b, es[i].cost = c;
        }
        int ans = kruskal();
        printf("%d\n", ans / 100 - V + 1);
    }
    return 0;
}

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

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

int		main(void)
{
	ll n;
	cin >> n;
	ll ans = 0;
	rep(i,n) {
		rep(k,n) {
			rep(j,n) {
				ans += gcd(gcd(i, k), j);
			}
		}
	}
	cout << ans << endl;
	return (0);
}


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

#define INF (INT32_MAX/4)

int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	X--;
	Y--;

	vector<vector<int>> m( N, vector<int>( N, INF ) );
	for( int i = 0; i < N; i++ ) m[i][i] = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( i == j ) continue;
			m[i][j] = abs( i - j );
		}
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			m[i][j] = min( m[i][j], min( m[i][X] + m[Y][j] + 1, m[i][Y] + m[X][j] + 1 ) );
		}
	}
	vector<int> ans( N - 1 );
	for( int i = 0; i < N; i++ ) {
		for( int j = i + 1; j < N; j++ ) {
			if( m[i][j] < 1 ) continue;
			ans[ m[i][j] - 1 ]++;
		}
	}
	for( int i = 0; i < N - 1; i++ ) {
		cout << ans[i] << endl;
	}
}


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

int main()
{
	int n;
	int ct[6] = {0};
	float h;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> h;
		
		if (h < 165.0){
			ct[0]++;
		}
		else if (h < 170.0){
			ct[1]++;
		}
		else if (h < 175.0){
			ct[2]++;
		}
		else if (h < 180.0){
			ct[3]++;
		}
		else if (h < 185.0){
			ct[4]++;
		}
		else {
			ct[5]++;
		}
	}
	
	for (int i = 0; i < 6; i++){
		cout << i + 1 << ":";
		for (int j = 0; j < ct[i]; j++){
			cout << "*";
		}
		cout << endl;
	}
	
	return (0);
}

Measured memory_bytes: 1232
fun main(args: Array<String>){
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }

    val x = n - (n / k) * k
    if(n % k == 0L){
        println(0)
    }else {
        if(k-x > n){
            println(n)
        }else{
            println(k-x)
        }
    }
}

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

int f(int x){
    int sum=0;
    while(x>0){
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main() {
    int n;
    scanf("%d",&n);
    int ans=1000000;
    for(int i=1;i<=n/2;i++){
        ans=min(ans,f(i)+f(n-i));
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int i,j,k,n,a,b,dice[7],
        side[5] = {2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
     
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
     
    scanf("%d", &n);
     
  //上面を合わせる
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
     
        for(j=1;dice[j]!=a;j++);
         
       //回転  
     
        for(k=0;order[j][k]!='\0';k++){
         
            dice[0] = dice[1];
         
            switch(order[j][k]){
                 
                case 'E':
                    dice[1] = dice[4];
                    dice[4] = dice[6];
                    dice[6] = dice[3];
                    dice[3] = dice[0]; 
                    break;
             
                case 'N':
                    dice[1] = dice[2];
                    dice[2] = dice[6];
                    dice[6] = dice[5];
                    dice[5] = dice[0]; 
                    break;
             
                case 'S':
                    dice[1] = dice[5];
                    dice[5] = dice[6];
                    dice[6] = dice[2];
                    dice[2] = dice[0]; 
                    break;
                 
                case 'W':
                    dice[1] = dice[3];
                    dice[3] = dice[6];
                    dice[6] = dice[4];
                    dice[4] = dice[0]; 
                    break;
 
            }
        }
         
        for(j=0;b!=dice[side[j]];j++);
         
        printf("%d\n",dice[side[j+1]]);
         
    }
     
    return 0;
}


Measured memory_bytes: 1984
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  int dp[n + 1][h + 10001];
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= h + 10000; ++j) {
      dp[i][j] = 1e9;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= h + 10000; ++j) {
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
    }
  }
  int ans = 1e9;
  for (int i = h; i <= h + 10000; ++i) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 78464
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int t = N;
		while(t>0) {
			sum += t%10;
			t=t/10;
		}
		if(N%sum == 0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * Summer Vacation
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            Work[] W = new Work[N];
            for (int i = 0; i < N; i++) {
                W[i] = new Work();
                W[i].A = sc.nextInt();
                W[i].B = sc.nextInt();
            }

            Arrays.sort(W, (o1, o2) -> {
                int comp = Integer.compare(o2.B, o1.B);
                if (comp == 0) {
                    comp = Integer.compare(o1.A, o2.A);
                }
                return comp;
            });

            List<Integer> schedule = new ArrayList<>();
            for (int i = 1; i <= M; i++) {
                schedule.add(i);
            }

            long sum = 0;
            for (int i = 0; i < N; i++) {
                Work w = W[i];

                int pos = Collections.binarySearch(schedule, w.A);
                if (pos < 0) {
                    pos = -(pos + 1);
                }

                if (pos == schedule.size()) {
                    continue;
                }

                sum += w.B;
                schedule.remove(pos);

                if (schedule.isEmpty()) {
                    break;
                }
            }

            System.out.println(sum);
        }
    }

    public static class Work {

        int A;

        int B;

    }

}


Measured memory_bytes: 86612
#include <cstdio>
#include <algorithm>
int main(){
    int a[5];
    for(int i=0; i<5; i++)
        scanf("%d", &a[i]);
    std::sort(a, a+5);
    for(int i=4; i>0; i--)
        printf("%d ", a[i]);
    printf("%d\n", a[0]);
    return 0;
}


Measured memory_bytes: 2756
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

int main() {
	int i = 0;
	int count;
	int x[10000];
	while (1) {
		std::cin >> x[i];
		if (x[i] == 0) {
			count = i;
			break;
		}
		i++;
	}
	for (i = 0; i < count; i++) {
		std::cout << "Case " << i + 1 << ": " << x[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

struct UnionFind {
        int n;
        vector<int> parent;
        vector<int> rank;
        vector<int> num;
        int find(int x) {
                if (parent[x] == x) return  x;
                return parent[x] = find(parent[x]);
        }
        UnionFind(int n_) {
                n = n_;
                parent.resize(n);
                for (int i = 0; i < n; i ++) parent[i] = i;
                rank.assign(n, 0);
                num.assign(n, 1);
        }
        void unite(int x, int y) {
                if ((x = find(x)) != (y = find(y))) {
                        if (rank[x] < rank[y]) {
                                parent[x] = y;
                                num[y] += num[x];
                        } else {
                                parent[y] = x;
                                if (rank[x] == rank[y]) rank[x] ++;
                                num[x] += num[y];
                        }
                        n --;
                }
        }
        bool same(int x, int y) { return find(x) == find(y); }
        int get() { return n; }
        int get(int x) { return num[find(x)]; }
};

int main() {
        int n, k, l;
        scanf("%d%d%d", &n, &k, &l);
        UnionFind uf1(n), uf2(n);
        for (int i = 0; i < k; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                uf1.unite(a, b);
        }
        for (int i = 0; i < l; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                uf2.unite(a, b);
        }
        vector<pair<int, int>> p(n);
        for (int i = 0; i < n; i ++) p[i] = make_pair(uf1.find(i), uf2.find(i));
        sort(p.begin(), p.end());
        for (int i = 0; i < n; i ++) {
                pair<int, int> q = make_pair(uf1.find(i), uf2.find(i));
                int ans = upper_bound(p.begin(), p.end(), q) - lower_bound(p.begin(), p.end(), q);
                printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
        }
        return 0;
}



Measured memory_bytes: 6912
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] TX = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            Console.WriteLine(TX[0]/TX[1]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define st string
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define gcd __gcd
using namespace std;
signed main() {
  int a,b,c;
  cin>>a>>b>>c;
  int d=max({a,b,c});
  int ans=0;
  if(a==b&&b==c) {
    cout<<"0"<<endl;
    return 0;
  }
  if(d==a) {
    if(b==d) {
      if(!((d-c)%2)) ans+=(d-c)/2;
      else ans+=(d-c)/2+2;
    }
    else if(c==d) {
      if(!((d-b)%2)) ans+=(d-b)/2;
      else ans+=(d-b)/2+2;
    }
    else {
      if(!(abs(b-c)%2)) {
        ans+=abs(b-c)/2+d-max(b,c);
      }
      else {
        ans+=(abs(b-c)-1)/2;
        ans+=d-max(b,c)+2;
      }
    }
  }
  else if(d==b) {
    b=a;
    if(b==d) {
      if(!((d-c)%2)) ans+=(d-c)/2;
      else ans+=(d-c)/2+2;
    }
    else if(c==d) {
      if(!((d-b)%2)) ans+=(d-b)/2;
      else ans+=(d-b)/2+2;
    }
    else {
      if(!(abs(b-c)%2)) {
        ans+=abs(b-c)/2+d-max(b,c);
      }
      else {
        ans+=(abs(b-c)-1)/2;
        ans+=d-max(b,c)+2;
      }
    }
  }
  else {
    c=a;
    if(b==d) {
      if(!((d-c)%2)) ans+=(d-c)/2;
      else ans+=(d-c)/2+2;
    }
    else if(c==d) {
      if(!((d-b)%2)) ans+=(d-b)/2;
      else ans+=(d-b)/2+2;
    }
    else {
      if(!(abs(b-c)%2)) {
        ans+=abs(b-c)/2+d-max(b,c);
      }
      else {
        ans+=(abs(b-c)-1)/2;
        ans+=d-max(b,c)+2;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256