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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] l = "11010: :11011:.:11100:,:11101:-:11110:':11111:?:00000:A:00001:B:00010:C:00011:D:00100:E:00101:F:00110:G:00111:H:01000:I:01001:J:01010:K:01011:L:01100:M:01101:N:01110:O:01111:P:10000:Q:10001:R:10010:S:10011:T:10100:U:10101:V:10110:W:10111:X:11000:Y:11001:Z".split(":");
        String[] l2 = "101:010001:000011:10010001:000000:000001:100101:10011010:0101:0001:110:01001:10011011:010000:0111:10011000:0110:00100:10011001:10011110:00101:111:10011111:1000:00110:00111:10011100:10011101:000010:10010010:10010011:10010000".split(":");
        String[] n2 = new String[l2.length];
        String[] n = new String[l.length / 2];
        char[] c = new char[l.length / 2];
        for (int i = 0; i < l.length / 2; i++) {
            n[i] = l[i * 2];
            n2[i] = l2[i];
            c[i] = l[i * 2 + 1].charAt(0);
        }
        while (sc.hasNext()) {
            String t = sc.nextLine();
            String a = "";
            for (char cc : t.toCharArray()) {
                for (int i = 0; i < c.length; i++) {
                    if (cc == c[i]) {
                        a += n[i];
                    }
                }
            }
            int start = 0;
            String r = "";
            boolean f=true;
            while (f) {
                for (int i = 0; i < l2.length; i++) {
                    if(start + l2[i].length()>a.length()) {
                        continue;
                    }
                    if (a.substring(start, start + l2[i].length()).equals(l2[i])) {
                        r += c[i];
                        start += l2[i].length();
                        f=false;
                        break;
                    }
                }
                if(f) {
                    break;
                }else {
                    f=true;
                }
            }
            System.out.println(r);
        }
    }
}




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

int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if (r<=x && r<=y && x+r<=w && y+r<=h) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}



Measured memory_bytes: 3064
/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first


int main()
{


  double d, t, s;
  cin >> d >> t >> s;

  double xx = d / s;
  if (xx <= t)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }



}







Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
using namespace std;
 
int main(void) {
	string s;
	int K;
	cin >> s;
	cin >> K;
 
	auto sss = vector<string>(K, "~");
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= s.size() - i; j++) {
            if(j>5)continue;
			auto ss = s.substr(i, j);
			for (int k = 0; k < K; k++) {
				if (ss < sss[k]) {
					for (int t = K-1; t > k; t--) {
						sss[t] = sss[t - 1];
					}
					sss[k] = ss;
					break;
				}
				else if (ss == sss[k]) {
					break;
				}
			}
 
		}
	}
 
	cout << sss[K-1] << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

#DIV = (10**9) + 7
DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    S = sRaw()
    T = sRaw()
    ans = 0
    for i in range(len(S)):
        if S[i]!=T[i]:
            ans+=1
    print(ans)




main()


Measured memory_bytes: 68704
import sys
input = sys.stdin.readline

n = int(input())
a_tuple = tuple(int(input()) for _ in range(n))
num = 0
count = 0

for i in range(n):
    num = a_tuple[num] - 1
    count += 1
    if num == 1:
        break

if num == 1:
    print(count)
else:
    print(-1)


Measured memory_bytes: 7196
N = gets.to_i
A = gets.split.map(&:to_i)

ans = 0

A.sort!

100000.times do
  N.times do |i|
    next if A[i] < N

    d = A[i] / N
    ans += d
    A[i] -= d * N

    N.times do |j|
      next if i == j

      A[j] += d
    end
  end
end

puts ans


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

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			String[] w_h = str.split(" ", 0);
			int h = Integer.parseInt(w_h[0]);
			int w = Integer.parseInt(w_h[1]);
			if (w == 0 && h == 0) {
				break;
			}
			for (int j = 0; j < h; j++) {
				if (j == 0 || j == (h - 1)) {
					for (int i = 0; i < w; i++) {
						System.out.print("#");
					}
				} else {
					for (int i = 0; i < w; i++) {
						if (i == 0 || i == (w - 1)) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 32196
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<functional>
#include<numeric>
#include<map>
//#include<>
using namespace std;

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REPS(i, n) for(int i=1;i<=(int)(n);i++)
#define RREP(i, n) for(int i=(int)n-1;i>=0;i--)
#define RREPS(i, n) for(int i=(int)n;i>0;i--)
#define FOR(it, a) for(auto it = a.begin();it!=a.end();++it)
#define RFOR(it, a) for(auto it = a.rbegin();it!=a.rend();++it)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T>
bool chmin(T& t, const T& s){
	if(s < t){
		t = s;
		return 1;
	}else return 0;
}

string vwl("aiueo");
bool isVowel(char c){
	return vwl.find(c) != string::npos;
}

string s;
string ms("ksthp");
bool isMS(int i){
	if(ms.find(s[i]) != string::npos) return true;
	if(s[i] == 'y' && ms.find(s[i-1]) != string::npos) return true;
	return false;	
}

int main(){
	ios::sync_with_stdio(false);
	while(cin >> s, s != "#"){
		int n = s.size();
		s = "#" + s + "kkkk";
		string t;
		int f = 0;
		REPS(i, n){
			if(s[i] == 'i' || s[i] == 'u'){
				if(!f && isMS(i-1) && isMS(i+1)){
					t = t + "(" + s[i] + ")";
					f = 1;
				}else{
					t.pb(s[i]);
					f = 0;
				}
			}else if(s[i] == 'a' || s[i] == 'o'){
				if(!f && isMS(i-1) && isMS(i+1) && (s[i+2] == s[i] || (s[i+2] == 'y' && s[i+3] == s[i]))){
					t = t + "(" + s[i] + ")";
					f = 1;
				}else{
					t.pb(s[i]);
					f = 0;
				}
			}else{
				if(s[i] == 'e') f = 0;
				t.pb(s[i]);
			}
		}
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
import math
K = int(input())
N = 0
 
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            g = math.gcd(a,b)
            g = math.gcd(g,c)
            if(a != b or a != c):
                if(a != b and a != c and b != c):
                    g *= 6
                else:
                    g *= 3
            N += g
 
print(N)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
全部がそれぞれ素pairwise
全部に共通して割れればnot coprime
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin >> N;
  vector<ll> used(1000010, 0);
  rep(i, N){
    ll A;
    cin >> A;
    for(ll i=2; i*i <= A; i++){
      if (A % i == 0) {
        used[i]++;
        while (A%i == 0)
          A /= i;
      }
    }
    if (A > 1)
      used[A]++;
  }
  bool is_pair = true;
  bool is_not = false;
  rep(i, 1000001){
    if (used[i] > 1)
      is_pair = false;
    if (used[i] == N)
      is_not = true;
  }
  if (is_pair)
    cout << "pairwise coprime" << endl;
  else if(is_not)
    cout << "not coprime" << endl;
  else
    cout << "setwise coprime" << endl;
//  rep(i, 20)
//    cout << "val:"<<used[i] << " i:"<<i<<endl;
}


Measured memory_bytes: 11104
import sys
sys.setrecursionlimit(1000000)
N,M=map(int,input().split())
par=[[] for _ in range(N)]
for _ in range(N-1+M):
  a,b=map(int,input().split())
  par[b-1].append(a)

dep=[-1]*N
def depth(n):
  if dep[n-1]!=-1:
    return dep[n-1]
  else:
    if len(par[n-1])==0:
      dep[n-1]=0
      return 0
    else:
      dep[n-1]=max([depth(i) for i in par[n-1]])+1
      return dep[n-1]

for i in range(N):
  if len(par[i])==0:
    print(0)
  elif len(par[i])==1:
    print(par[i][0])
  else:
    m=-1
    a=par[i][0]
    for j in par[i]:
      d=depth(j)
      if m<d:
        m=d
        a=j
    print(a)

Measured memory_bytes: 229204
ary = []
(0..3).each do |i|
  ary[i] = Array.new(3)
  (0..2).each do |j|
    ary[i][j] = Array.new(10, 0)
  end
end

n = STDIN.gets.chomp.to_i
(1..n).each do |i|
  b, f, r, v = STDIN.gets.chomp.split(' ').map(&:to_i)
  ary[b-1][f-1][r-1] += v
end

puts ary.map{|b| b.map{|f| ' ' << f.join(' ') }.join("\n") }.join("\n####################\n")

Measured memory_bytes: 8680
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e18;
const int MOD = 1e9+7;

int f(int x){
    if(x == 1){
        return 5;
    }
    return 2 * x + 1;
}

signed main(){
    int n, x;
    cin >> n >> x;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s(n+1);
    rep(i, n){
        s[i+1] += s[i] + a[i];
    }

    int ans = INF;
    for(int k = 1; k <= n; k++){
        int last = n;
        bool ng = false;
        int tmp = 0;
        int c = 1;
        while(last > 0){
            int nLast = max(0LL, last - k);
            tmp += (s[last] - s[nLast]) * f(c++);
            if(tmp >= ans){
                ng = true;
            }
            last = nLast;
        }

        if(ng){
            continue;
        }

        ans = min(ans, tmp + k * x);
    }
    cout << ans + n * x << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793

int main(){
	int n;
	scanf("%d", &n);
	char str[n];
	scanf("%s", str);
	int max=0, x=0;
	for(int i=0; i<n; i++){
		if(str[i] == 'I'){
			x++;
			if(x>max) max = x;
		}
		else x--;
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, m, x;
	cin >> n >> m >> x;

	vector<int> cost(n);
	vector<vector<int>> a(n, vector<int>(m));

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

	int ans = 2e9;

	for(int i = 1; i < (1 << n); i++){
		vector<int> skill(m);
		int cur = 0;
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				cur += cost[j];
				for(int k = 0; k < m; k++)
					skill[k] += a[j][k];
			}
		}

		bool ok = true;
		for(int j = 0; j < m; j++)
			if(skill[j] < x)
				ok = false;

		if(ok)
			ans = min(ans, cur);
	}

	if(ans == 2e9)
		ans = -1;

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

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

bool max_check(vector<int> v, int i){
  int a=v[i];
  sort(v.begin(), v.begin()+i);
  if (v[i-1]<=a) return true;
  else return false;
}

int main(){
  int N;
  cin >> N;
  if(N==1){
    cout << 1 <<endl;
    return 0;
  }
  vector<int> v(N);
  for(int i=0; i<N; i++) cin >> v[i];
  
  int ans=1;
  for(int i=1; i<N; i++){
    bool x=max_check(v, i);
    if(x) ans++;
  }
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	long long a, b;
	long long v, w;
	long long t;
	std::cin >> a >> v >> b >> w >> t;
	if((v - w) * t >= abs(a - b)) std::cout << "YES\n";
	else std::cout << "NO\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  for (int i=0;i<s.size();i++) {
    if (mp[s[i]]) {
      cout << "no" << endl;
      return 0;
    }
    mp[s[i]]++;
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

int main() {
	int K;
	string S;
	cin >> K >> S;
	int a=0, b=0, c=0, x, y, z;
	if (S.size() <= K) {
		std::cout << S << '\n';
	} else {
		std::cout << S.substr(0, K) << "..." << '\n';
	}
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int L, R;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int l, r;
        cin >> l >> r;
        if (i == 0){
            L = l; R = r;
            continue;
        }
        if (R < l || L > r){
            cout << 0;
            return 0;
        }
        L = max(L, l); R = min(R, r);
    }
    cout << min(R - L + 1, n);
	return 0;
}


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

int main() {
    int r,c,sheet[101][101]{0};
    cin >> r >> c;
    for(int y=0;y<r;y++){
        for(int x=0;x<c;x++){
            cin >> sheet[y][x];
            sheet[y][c] += sheet[y][x];
            sheet[r][x] += sheet[y][x];
            sheet[r][c] += sheet[y][x];
        }
    }
    
    
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j == 0) cout << sheet[i][j];
            else cout << " " << sheet[i][j];
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define REP(I,N) for(int I=0;I<N;I++)
#define FOR(I,A,B) for(int I=A;I<=B;I++)
#define FORD(I,A,B) for(int I=A;I>=B;I--)
#define c(A) cin >> A
#define c2(A,B) cin >> A >> B
#define c3(A,B,C) cin >> A >> B >> C
#define c4(A,B,C,D) cin >> A >> B >> C >> D
#define c5(A,B,C,D,E) cin >> A >> B >> C >> D >> E
#define IS ios_base::sync_with_stdio(false); cin.tie(0);
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define db if(1)cerr
template<typename C> void MA(C& a,C b){if(a<b)a=b;}
template<typename C> void MI(C& a,C b){if(a>b)a=b;}



int main () {
	IS;
	

	ll a,b,c;
	ll res = 1e18;
	cin >> a >> b >> c;
	
	res = min(res, abs(a/2*b*c - (a-a/2)*b*c));
	res = min(res, abs(b/2*a*c - (b-b/2)*a*c));
	res = min(res, abs(c/2*a*b - (c-c/2)*a*b));

	cout << res << endl;
}


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

int main(){
  int a,x;
  cin >> x >> a;
  if(x < a) cout << "0" << endl; 
  else cout << "10" << endl;
}

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

int main(){
  int c[3],N;
  cin>>c[0]>>c[1]>>c[2]>>N;
  int ans=0;
  for(int i=0;i<=(N/c[0])+1;i++){
    for(int j=0;j<=(N/c[1])+1;j++){
      if(c[0]*i+c[1]*j<=N&&(N-c[0]*i-c[1]*j)%c[2]==0) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def LCM(a, b):
    tmp = a * b
    while b != 0:
        a, b = b, a % b
    return tmp // a

N, M = map(int, input().split())
s = input()
t = input()
n = LCM(N, M)
a = n // N
b = n // M
for i in range(min((N - 1) // b, (M - 1) // a) + 1):
    if s[b * i] != t[a * i]:
        print("-1")
        break

else:
    print(n)

Measured memory_bytes: 3316
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  while(1){
    ll n;
    cin>>n;
    if(n==0) return 0;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    double ave=Svec(v)/n;
    sort(ALL(v));
    bool flag=true;
    rep(i,n){
      if(v[i]>ave){
        cout<<i<<endl;
        flag=false;
        break;
      }
    }
    if(flag) cout<<n<<endl;
  }
}


Measured memory_bytes: 3268
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val s = readLine()!!.split(" ").filter { it != "" }
    val n = s[0].toInt()
    val d = s[1].toInt()

    var c = 0
    for (i in 1..n) {
        val xy = readLine()!!.split(" ").filter { it != "" }
        val x = xy[0].toDouble()
        val y = xy[1].toDouble()
        val dis = sqrt(x * x + y * y)
        if (dis <= d) c++
    }
    println(c)
}

Measured memory_bytes: 60012
#include <iostream>

using namespace std;

int main(void) {
  int a, b;

  cin >> a >> b;
  if (a == b) cout << "Draw\n";
  else if (a > b && b != 1 || a == 1) cout << "Alice\n";
  else cout << "Bob\n";
  
  return 0;
}
              


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int a, b; rd(a, b);

  const int n=100;
  auto c=new char[][](n, n);
  a--; b--;
  foreach(i; 0..n)foreach(j; 0..n){
    if(i<n/2) c[i][j]='#';
    else c[i][j]='.';
  }
  loop1:for(int i=0; i<n/2; i+=2)for(int j=0; j<n; j+=2){
    if((a--)==0) break loop1;
    c[i][j]='.';
  }
  loop2:for(int i=n/2+1; i<n; i+=2)for(int j=0; j<n; j+=2){
    if((b--)==0) break loop2;
    c[i][j]='#';
  }

  writeln(n, " ", n);
  foreach(i; 0..n) writefln("%(%c%)", c[i]);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	ll X, Y;
	cin >> X >> Y;
	ll res = 1;
	ll i = X;
	while (2 * i <= Y) {
		i *= 2;
		res++;
	}
	cout << res << endl;
	return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long  int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e4+2;

//vector<ll>dp[N];
vector<ll>v;
int main()
{
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n;
       cin>>n;
       ll a[n];
       ll sum=0;
       for(i=0; i<n; i++)
       {
           cin>>a[i];
           sum+=a[i];
           sum%=mod;
       }
       ll ans=0;
       //cout<<sum<<"\n";
       for(i=0; i<n; i++)
       {
           ll val=a[i];
           ll val1=(sum-a[i]+mod)%mod;
           val*=val1;
           val%=mod;
           ans+=val;
           ans%=mod;
            //cout<<ans<<"\n";
           sum=(sum-a[i]+mod)%mod;
       }
       cout<<ans;
    }

    return 0;
}


Measured memory_bytes: 5208
#include<iostream>
#include<cstdio>
using namespace std ;
int main(){
  int n;
  cin>>n;  
  int day[n];
  for(int i=0;i<n;i++){
    cin>>day[i];
  }
 for(int i=n-1;i>=0;i--){
   printf("%d",day[i]);
  if(i)printf(" ");
  }
  cout<<endl;
 return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    string s;
    cin>>s;
    int ans=1;
    rep(i,2){
        if(s[i]=='R' && s[i+1]=='R') ans++;
    }
    if(s[0]=='S' && s[1]=='S' && s[2]=='S') ans=0;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        StringBuilder res = new StringBuilder("");
        for (int i = 0; i < ty - sy; i++) {
            res.append('U');
        }
        for (int i = 0; i < tx - sx; i++) {
            res.append('R');
        }
        for (int i = 0; i < ty - sy; i++) {
            res.append('D');
        }
        for (int i = 0; i < tx - sx; i++) {
            res.append('L');
        }
        res.append('D');
        for (int i = 0; i < tx - sx + 1; i++) {
            res.append('R');
        }
        for (int i = 0; i < ty - sy + 1; i++) {
            res.append('U');
        }
        res.append('L');
        res.append('U');
        for (int i = 0; i < tx - sx + 1; i++) {
            res.append('L');
        }
        for (int i = 0; i < ty - sy + 1; i++) {
            res.append('D');
        }
        res.append('R');
        System.out.println(res.toString());
    }
}


Measured memory_bytes: 21588
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from math import gcd
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    S=str(input())
    SS=Counter(S).most_common()
    if len(S)==1:
        print('YES')
    if len(S)==2:
        print('YES' if len(SS)==2 else 'NO')
    if len(S)>=3:
        print('YES' if len(SS)>=3 and SS[0][1]-SS[-1][1]<=1 else 'NO')


resolve()

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

typedef long long ll;
typedef tuple<int,int,int,int> tp;

int N,M,Q;
vector<int> A;
int ans = 0;
vector<tp> C;
void dfs(int i){
	if(i>N){
		int sum = 0;
		rep(k,Q){
			int a = get<3>(C[k]);
			int b = get<2>(C[k]);
			if(A[b] - A[a] == get<1>(C[k])) sum += get<0>(C[k]);
		}
		ans = max(ans,sum);
		return ;
	}
	for(int j=1; j<=M; j++){
		if(i!=0 && A[i-1] > j)continue;
		A[i] = j;
		dfs(i+1);
	}

}

int main(){
	cin >> N >> M >> Q;
	rep(i,Q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--; b--;
		C.push_back(make_tuple(d,c,b,a));
	}
	sort(C.begin(),C.end());
	reverse(C.begin(),C.end());
	 A.resize(N+1);

	dfs(0);

	cout << ans << endl;
	


	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
  int num() { // 異なる集合の数
    int res = 0;
    REP(i, data.size()) res += root(i) == i;
    return res;
  }
};

int main2() {
  int N, M; cin >> N >> M;
  vector<pair<int,int>> es;
  REP(i, M) {
    int a, b; cin >> a >> b;
    a--, b--;
    es.push_back({a, b});
  }
  UnionFind uf(N);

  vector<ll> ans(M);
  ll s = (ll)N * (N-1) / 2;
  for (int i = M - 1; i >= 0; i--) {
    ans[i] = s;
    int a = es[i].first;
    int b = es[i].second;
    if (!uf.same(a, b)) {
      s -= (ll)uf.size(a) * uf.size(b);
      uf.link(a, b);
    }
  }
  REP(i, M) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 3316
n = int(input())
s = [input() for _ in range(n)]
#print(s)

print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))


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

int c[3][3];

bool isOK(int x[3]) {
  if (x[0] == x[1] && x[1] == x[2] && x[2] == x[0]) {
    return true;
  } else {
    return false;
  }
}

bool solve() {
  int i;
  int x[3], y[3], z[3];
  bool check = true;

  for (i = 0; i < 3; i++) {
    x[i] = c[1][i] - c[0][i];
    y[i] = c[2][i] - c[1][i];
    z[i] = c[0][i] - c[2][i];
  }

  if (isOK(x) && isOK(y) && isOK(z)) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  if (solve()) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define up(r,l,h) for(int r=l;r<=h;r++)

using namespace std;

struct node 
{
	int ii,jj,ld,rd;
}map[105];
int n,m;
int numi[15],numj[15],d1,d2;

int main()
{
	n=3;
	up(i,1,n) up(j,1,n)
	{
	    register int tmp;
		cin>>tmp;
		map[tmp].ii=i;
		map[tmp].jj=j;
		if(i==j) map[tmp].ld++;
		if(i+j==n+1) map[tmp].rd++;	
	}
	cin>>m;
	up(i,1,m)
	{
		register int tmp;
		cin>>tmp;
		if(map[tmp].ii) numi[map[tmp].ii]++;
		if(numi[map[tmp].ii]==n)
		{
			cout<<"Yes";
			return 0;
		}
		if(map[tmp].jj) numj[map[tmp].jj]++;
		if(numj[map[tmp].jj]==n)
		{
			cout<<"Yes";
			return 0;
		}
		if(map[tmp].ld) d1++;
		if(d1==n)
		{
			cout<<"Yes";
			return 0;
		}
		if(map[tmp].rd) d2++;
		if(d2==n)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int n;
vi graph[200000];
int vis[200000];
int dp[200000][2];


void dfs(int v,int root,int p=-1)
{
  vis[v]=1;
  if(v!=root&&graph[v].size()==1)
  {
  	dp[v][0]=1;
  	dp[v][1]=1;
  	return;
  }
  for(int i=0;i<graph[v].size();i++)
  {
  	if(graph[v][i]!=p)
  	{
  	  if(vis[graph[v][i]]==0)
  	  	dfs(graph[v][i],root,v);
  	  dp[v][0] *= ((dp[graph[v][i]][0] + dp[graph[v][i]][1])%mod);
  	  dp[v][0]%=mod;
  	  dp[v][1] *= dp[graph[v][i]][0];
  	  dp[v][1]%=mod;
  	} 
  }
} 

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin>>u>>v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=1;
		dp[i][1]=1;
	}
	dfs(1,1);
	cout<<((dp[1][0] + dp[1][1])%mod);
	return 0;
}

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

short X[3001][3001];
short Y[3001][3001];

string lcs( string a, string b ) {
    int n = a.size();
    int m = b.size();
    for ( int i = 0; i < n+1; i++ ) {
        for ( int j = 0; j < m+1; j++ ) {
            X[i][j] = 0;
            Y[i][j] = 0;
        }
    }

    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < m; j++ ) {
            if ( a[i] == b[j] ) {
                X[i+1][j+1] = X[i][j] + 1;
                Y[i+1][j+1] = 0;
            } else if ( X[i+1][j] < X[i][j+1] ) {
                X[i+1][j+1] = X[i][j+1];
                Y[i+1][j+1] = +1;
            } else {
                X[i+1][j+1] = X[i+1][j];
                Y[i+1][j+1] = -1;
            }
        }
    }

    string answer;
    for ( int i = n, j = m; i > 0 && j > 0; ) {
        if ( Y[i][j] > 0 ) {
            i--;
        } else if ( Y[i][j] < 0 ) {
            j--;
        } else {
            answer += a[i-1];
            i--;
            j--;
        }
    }
    reverse( answer.begin(), answer.end() );
    return answer;
}

int main() {
    string input;
    while ( cin >> input ) {
        string a = input;
        string b = input;
        reverse( b.begin(), b.end() );
        string answer = lcs( a, b );
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 23000
#include <iostream>
using namespace std;
int main(){
    int n,a;
    cin >> n >> a;
    int x[n];
    for(int i = 0;i<n;i++) cin >> x[i];
    long long dp[51][2600];
    for(int i = 0;i<51;i++) for(int j = 0;j<2600;j++) dp[i][j]=0;
    dp[0][0] = 1;
    for(int i = 0;i<n;i++){
        for(int j = i;j>=0;j--){
            for(int k = 0;k<2501;k++){
                dp[j+1][k+x[i]]+=dp[j][k];
            }
        }
    }
    long long ans = 0;
    for(int i = 1;i<=n;i++) ans+=dp[i][a*i];
    //for(int i = 0;i<=n;i++) for(int j = 0;j<2501;j++) if(dp[i][j]>0) cout << i << " " << j << " " << dp[i][j] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1280
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

class Main {

	public static LinkedList<Integer>[] adj;
	public static int[] dp;
	public static boolean[] visited;
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int m=s.nextInt();
		adj=new LinkedList[n];
		for(int i=0;i<n;i++) {
			adj[i]=new LinkedList<Integer>();
		}
		dp=new int[n];
		visited=new boolean[n];
		Arrays.fill(dp, -1);
		while(m-->0) {
			int a=s.nextInt()-1;
			int b=s.nextInt()-1;
			adj[a].add(b);
		}
		int value=dfsUtil();
		out.println(value>=0?value:0);
		out.close();
	}
	
	public static int dfs(int curr) {
		visited[curr]=true;
		if(dp[curr]!=-1) {
			return dp[curr];
		}
		int max=0;
		for(Integer x:adj[curr]) {
			max=Integer.max(dfs(x), max);
		}
		dp[curr]=max+1;
		return max+1;
	}

	
	public static int dfsUtil() {
		int max=0;
		for(int i=0;i<adj.length;i++) {
			if(!visited[i]) {
				max=Integer.max(dfs(i),max);
			}
		}
		return max-1;
	}
	
	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}


Measured memory_bytes: 60760
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      mut n: usize,
   }
   let mut i = 2;
   let mut ans = 0;
   while i * i < n {
      if n % i == 0 {
         ans += 1;
         n /= i;
         let mut j = i * i;
         while n % j == 0 {
            ans += 1;
            n /= j;
            j *= i;
         }
         while n % i == 0 {
            n /= i;
         }
      }
      i += 1;
   }
   if n != 1 {
      ans += 1;
   }
   println!("{}", ans);
}


Measured memory_bytes: 2160
import java.util.Scanner;


public class Main{

	static int[] parent;
	static int[] leftChild;
	static int[] rightChild;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = new Integer(s.nextLine()).intValue();
		parent = new int[cnt];
		leftChild = new int[cnt];
		rightChild = new int[cnt];
		for(int i=0 ; i<cnt ; i++) {
			parent[i] = -1;
			leftChild[i] = -1;
			rightChild[i] = -1;
		}
		for(int i=0 ; i<cnt ; i++) {
			String[] tmp = s.nextLine().split(" ");
			if(new Integer(tmp[1]).intValue()!=-1) {
				parent[new Integer(tmp[1]).intValue()] = new Integer(tmp[0]).intValue();
				leftChild[new Integer(tmp[0]).intValue()] = new Integer(tmp[1]).intValue();
			}
			if(new Integer(tmp[2]).intValue()!=-1) {
				parent[new Integer(tmp[2]).intValue()] = new Integer(tmp[0]).intValue();
				rightChild[new Integer(tmp[0]).intValue()] = new Integer(tmp[2]).intValue();
			}
		}
		int root = -1;
		for(int i=0 ; i<parent.length ; i++) {
			if(parent[i]==-1)
				root = i;
		}
		System.out.print("Preorder");
		System.out.print("\n");
		preorder(root);
		System.out.print("\n");
		System.out.print("Inorder");
		System.out.print("\n");
		inorder(root);
		System.out.print("\n");
		System.out.print("Postorder");
		System.out.print("\n");
		postorder(root);
		System.out.print("\n");
	}

	public static void preorder(int root) {
		System.out.print(" " + root);
		if(leftChild[root]!=-1)
			preorder(leftChild[root]);
		if(rightChild[root]!=-1)
			preorder(rightChild[root]);
	}

	public static void inorder(int root) {
		if(leftChild[root]!=-1)
			inorder(leftChild[root]);
		System.out.print(" " + root);
		if(rightChild[root]!=-1)
			inorder(rightChild[root]);

	}

	public static void postorder(int root) {
		if(leftChild[root]!=-1)
			postorder(leftChild[root]);
		if(rightChild[root]!=-1)
			postorder(rightChild[root]);
		System.out.print(" " + root);
	}
}

Measured memory_bytes: 17336
N, M = map(int, input().split())
a_list =  list(map(int, input().split()))
a_list.sort(reverse = True)
a_total = sum(a_list)
count = 0
for voted in a_list[:M]:
  if voted < (1/(4*M))*a_total:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpConsoleApp {

    class Program {

        static int Main() {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var K = input[1];
            var longs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            longs.Sort();
            longs.Reverse();
            var Min = longs.Take(K).Sum();
            Console.WriteLine(Min);
            return 0;
        }
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main() {
    int A, B;
    scanf("%d %d", &A, &B);

    int count = 0;
    for(int i = A; i <= B; i++) {
        string s = to_string(i);

        bool flag = true;
        for(int index = 0; index < s.length(); index++) {
            if(s[index] != s[s.length() - 1 - index]) {
                flag = false;
                break;
            }
        }
        if(flag) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

signed main(){
    int x,a,b;
    cin >>  x >> a >> b;
    x -= a;
    x -= (x/b)*b;
    printf("%d\n",x);
}



Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main () {
	char str[20];
	gets( str);
	int lg=strlen(str);
	for (int i=0;i<=lg;i++){
	if (str[i]==','){
	str[i]=' ';} }
	 printf ("%s\n",str);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 998244353
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

llint n, m, k;
llint a[100005];
vector<P> vec;

llint get(llint l, llint r)
{
	return r*(r+1)/2 - l*(l+1)/2;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint rem = 0;
	for(int i = 1; i <= n; i++) rem += a[i];
	rem -= m;
	
	if(rem <= 0){
		cout << 0 << endl;
		return 0;
	}
	
	sort(a+1, a+n+1);
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(rem <= 0) break;
		llint x = a[i]*(a[i]+1)/2;
		if(a[i] <= rem){
			vec.push_back(P(0, 0));
			vec.push_back(P(a[i], 1));
			rem -= a[i];
			ans += x;
		}
		else{
			llint lb = a[i]-rem+1;
			vec.push_back(P(lb-1, 0));
			vec.push_back(P(a[i], 1));
			rem = 0;
			ans += x-lb*(lb-1)/2;
		}
	}
	sort(vec.rbegin(), vec.rend());
	
	rem = k;
	llint sum = 0;
	for(int i = 0; i < vec.size(); i++){
		if(rem <= 0) break;
		
		if(vec[i].second == 1) sum++;
		else sum--;
		
		if(i < (int)vec.size()-1){
			llint dist = vec[i].first - vec[i+1].first;
			if(sum * dist <= rem){
				rem -= sum * dist;
				ans -= sum * get(vec[i+1].first, vec[i].first);
			}
			else{
				llint pos = vec[i].first - rem/sum;
				rem %= sum;
				ans -= sum * get(pos, vec[i].first);
				ans -= pos * rem;
				rem = 0;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7860
#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>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main() {
    ll a,v,b,w;cin>>a>>v>>b>>w;
    ll t;cin>>t;
    if(v<=w){
        cout<<"NO"<<endl;
    }else{
        
        if(abs(a-b)<=t*(v-w)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N + K - 3) / ((K - 1));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define H 500000

int n;

void maxHeapify(int *A, int i) {
  int largest, left = i * 2, right = i * 2 + 1, tmp;

  if ((left <= n) && (A[left] > A[i])) {
    largest = left;
  } else {
    largest = i;
  }
  
  if ((right <= n) && (A[right] > A[largest])) {
    largest = right;
  }
  
  if (largest != i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A) {
  int i;
  
  for (i = n / 2; i >= 1; i--) {
    maxHeapify(A, i);
  }
}

int main() {
  int i, A[H];

  scanf("%d", &n);
  
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A);

  for (i = 1; i <= n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] a_asArgs)
        {
			Console.ReadLine();
			List<int> l_liCards = new List<int>(Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray());
			if (l_liCards.Count % 2 != 0)
			{
				l_liCards.Add(0);
			}
			l_liCards.Sort();
			int l_iDiff = 0;
			for (int l_iTurn = 0; l_iTurn < l_liCards.Count / 2; l_iTurn++)
			{
				l_iDiff += l_liCards[l_liCards.Count - l_iTurn * 2 - 1] - l_liCards[l_liCards.Count - l_iTurn * 2 - 2];
			}
			Console.WriteLine(l_iDiff);
		}
	}
}


Measured memory_bytes: 13396