akhauriyash/Code-Regression huggingface dataset:
package main

	import (
		"bufio"
		"fmt"
		"math"
		"os"
	)

	const pi = math.Pi

	var mod int = pow(10, 9) + 7
	var Umod uint64 = 1000000007
	var ans int = 1

	func main() {
		var N, M int
		fmt.Scan(&N, &M)
		m := make(map[int]int)

		for i := 2; i*i <= M; i++ {
			for M%i == 0 {
				M /= i
				m[i]++
			}
		}
		if M != 1 {
			m[M]++
		}

		for _, value := range m {
			ans *= combination(value+(N-1), (N - 1))
			ans %= mod
		}
		fmt.Println(ans)
	}

	/*  ----------------------------------------  */

	var reader = bufio.NewScanner(os.Stdin)

	func read() string {
		reader.Scan()
		return reader.Text()
	}

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

	func gcd(x, y int) int {
		if x%y == 0 {
			return y
		} else {
			r := x % y
			return gcd(y, r)
		}
	}

	var fac [1000000]int
	var finv [1000000]int
	var inv [1000000]int

	func combination_init() {
		fac[0], fac[1] = 1, 1
		finv[0], finv[1] = 1, 1
		inv[1] = 1

		// invは a^(-1) mod p
		// pをaで割ることを考える

		// p/a*(a) + p%a = p
		// p/a*(a) + p%a = 0          (mod p)
		// -p%a = p/a*(a)             (mod p)
		// -p%a *a^(-1)= p/a          (mod p)
		// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
		// a^(-1) =

		for i := 2; i < 1000000; 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
		}
	}

	func combination(x, y int) int {
		if x < y {
			return 0
		}
		if fac[0] != 1 {
			combination_init()
		}
		return fac[x] * (finv[y] * finv[x-y] % mod) % mod
		//return fac[x] / (fac[y] * fac[x-y])
	}

	func permutation(x, y int) int {
		if x < y {
			return 0
		}
		if fac[0] != 1 {
			combination_init()
		}
		return fac[x] * (finv[x-y] % mod) % mod
		//return fac[x] / fac[x-y]
	}

	func max(x ...int) int {
		var res int = x[0]
		for i := 1; i < len(x); i++ {
			res = int(math.Max(float64(x[i]), float64(res)))
		}
		return res
	}

	func min(x ...int) int {
		var res int = x[0]
		for i := 1; i < len(x); i++ {
			res = int(math.Min(float64(x[i]), float64(res)))
		}
		return res
	}
	func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
	func abs(x int) int    { return int(math.Abs(float64(x))) }
	func floor(x int) int  { return int(math.Floor(float64(x))) }
	func ceil(x int) int   { return int(math.Ceil(float64(x))) }

	type SortBy []struct {
		b, c int
	}

	func (a SortBy) Len() int           { return len(a) }
	func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
	func (a SortBy) Less(i, j int) bool { return a[i].c > a[j].c }

	type PriorityQueue []int

	func (h PriorityQueue) Len() int            { return len(h) }
	func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
	func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
	func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
	func (h *PriorityQueue) Pop() interface{} {
		old := *h
		n := len(old)
		x := old[n-1]
		*h = old[0 : n-1]
		return x
	}


Measured memory_bytes: 24064
N = int(input())
A = list(map(int,input().split()))
M = 1000005
l = [0 for i in range(M)]

for a in A:
    if l[a]!=0:
        l[a]+=1
        continue

    for i in range(a,M,a):
        l[i]+=1

ans = 0
for a in A:
    if l[a]==1:
        ans +=1

print(ans)

Measured memory_bytes: 32124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

ll p(ll a,ll n) {
    if (n <= 0)return 1;
    return a * p(a - 1, n - 1) % mod;
}
ll kaijo(ll a) {
    if (a <= 0)return 1;
    return a * kaijo(a - 1) % mod;
}

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

    ll n, k;
    cin >> n >> k;
    vector<VI> edge(n);
    ll a, b;
    FOR(i, 0, n - 1) {
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }

    ll ans = k;
    queue<pair<int,int>> bfs;
    vector<bool> ever(n, 0);
    bfs.push({ 0,0 });
    while (!bfs.empty()) {
        int now = bfs.front().first;
        int num = bfs.front().second;
        bfs.pop();
        ever[now] = 1;
        if (num == 0)ans *= p(k-1, edge[now].size())% mod;
        else ans *= p(k - 2, edge[now].size() - 1)% mod;
        ans %= mod;
        for (int i : edge[now]) {
            if (ever[i])continue;
            bfs.push({i, num + 1 });
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8568
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define EPS 1e-10
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
typedef long long llong;
signed main() {
	int n;
	cin >> n;
	vector<int>v(n);
	rep(i, 0, n)cin >> v[i];
	int m;
	cin >> m;
	rep(i, 0, m) {
		int p, x;
		cin >> p >> x;
		vector<int>d(v);
		d[p - 1] = x;
		cout << accumulate(d.begin(), d.end(), 0) << endl;
	}

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b);
    G.at(b).push_back(a);
  }
  vector<int> ans(N, -1);
  queue<int> Q;
  Q.push(0);
  ans.at(0) = 0;
  while (Q.size()) {
    int now = Q.front();
    Q.pop();
    for (auto next : G.at(now)) {
      if (ans.at(next) == -1) {
        ans.at(next) = now + 1;
        Q.push(next);
      }
    }
  }
  cout << "Yes" << "\n";
  for (int i = 1; i < N; i++) {
    cout << ans.at(i) << "\n";
  }
}

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

int N;
string S, T;

int main() {
  cin >> N >> S >> T;
  int res = 0;
  for(int i = 1; i <= N; ++i) {
    bool good = true;
    for(int j = 0; j < i; ++j) {
      if(S[N - i + j] != T[j]) good = false;
    }
    if(good) res = i;
  }
  cout << 2 * N - res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char d[10];
int n,k;
int main()
{
	cin>>n>>k;
	while(k--)
	{
		int l;
		cin>>l;
		d[l]=1;
	}
	for (int i=n;;i++)
	{
		stringstream st;
		string s;
		st<<i;
		st>>s;
		bool flag=false;
		for (int j=0;j<s.size();j++)
		{
			if (d[s[j]-'0']==1)
			{
				flag=true;
			}
		}
		if (!flag)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#define reg register
using namespace std;
const int MN=2000;
int a[MN],available[MN],index=0,ans=2147483647;
int main(){
	int N,K,Q;
	scanf("%d%d%d",&N,&K,&Q);
	for(reg int i=1;i<=N;++i){
		scanf("%d",a+i);
	}
	//X-Y
	for(reg int i=1;i<=N;++i){
		index=0;
		int Y=a[i],begin=1,end=0;
//		printf("MIN=%d\n",Y);
		for(reg int j=1;j<=N+1;++j){
			if(a[j]<Y){
				end=j-1;
				int length=end-begin+1;
//				printf("  [%d,%d] len=%d\n",begin,end,length);
				if(length>=K){
					for(reg int k=begin;k<=end;++k){
						available[++index]=a[k];
//						printf("   index=%d\n",index);
					}
					sort(available+index-length+1,available+index+1);
//					    printf("  [after sort]available:");
//						for(reg int i=1;i<=index;++i){
//							printf("%09d ",available[i]);
//						}
//						printf("\n");
					index=index-K+1;
//					printf("    index=%d\n",index);
				}
				begin=j+1;
			}
		}
		if(index>=1) sort(available+1,available+index+1);
//			printf("  available:");
//			for(reg int i=1;i<=index;++i){
//				printf("%d ",available[i]);
//			}
//			printf("\n");
		if(index>=Q) ans=min(ans,available[Q]-available[1]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,s;
  cin >> n;
  int a = n;
  while(a != 0){
    s += a%10;
    a /= 10;
  }
  
  if(n%s) cout << "No";
  else cout << "Yes";
  
  return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

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

    int n, m, s, t;
    cin >> n >> m;
    vector<vector<int> > g(3 * n);
    vector<int> dist(3 * n, INT_MAX);
    queue<int> q;
    vector<bool> pres(3 * n, false);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[3 * u].push_back(3 * v + 1);
        g[3 * u + 1].push_back(3 * v + 2);
        g[3 * u + 2].push_back(3 * v);
    }
    cin >> s >> t;
    s--, t--;

    dist[3 * s] = 0;
    q.push(3 * s);
    pres[3 * s] = true;
    while (!q.empty()) {
        int n = q.front();
        for (auto c : g[n]) {
            if (dist[n] + 1 < dist[c]) {
                dist[c] = dist[n] + 1;
                if (!pres[c]) {
                    q.push(c);
                    pres[c] = true;
                }
            }
        }
        q.pop();
        pres[n] = false;
    }

    if (dist[3 * t] == INT_MAX)
        cout << "-1";
    else
        cout << dist[3 * t] / 3;

    return 0;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
 
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll sum = 0LL;
    if(a+b >= d) sum = min(a,d);
    else {
        sum += a, d-=(a+b);
        sum -= min(d, c);
    }

    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(cin >> h >> w && h||w){
    for(int j=0;j<w;j++) cout << "#";
    cout << endl;
    for(int i=1;i<h-1;i++){
      cout << "#";
      for(int j=1;j<w-1;j++) cout << ".";
      cout << "#" << endl;
    }
    for(int j=0;j<w;j++) cout << "#";
    cout << endl << endl;
  }
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> P(n);
  vector<int> questions(3);
  for(int i=0;i<n;i++) {
    cin >> P[i];
    if(P[i] <= a) questions[0]++;
    else if(P[i] <= b) questions[1]++;
    else questions[2]++;
  }

  cout << *min_element(questions.begin(), questions.end()) << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    char c; cin >> c;
    return res = c + 1;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<char>() << endl;
    return 0;
}


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

int main()
{
	int n;
	string s;
	priority_queue<int> pq;
	while (cin >> s, s != "end") {
		if (s == "insert") {
			cin >> n;
			pq.push(n);
		}
		else {
			cout << pq.top() << endl;
			pq.pop();
		}
	}
	return 0;
}

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

#define maxn 100111
typedef long long ll;
ll s[maxn];
int a[maxn];
bool f[maxn];
int n;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	sort(a+1,a+1+n);
	
	int ans=1;
	
	for(int i=1;i<=n;i++)
	{
		s[i]=s[i-1]+a[i];
	}
	
	int x=0;
	for(int i=1;i<=n;i++)
	{
		if (s[i]*2>=a[i+1]) f[i]=1;
		else x=i;
	}
	
	cout<<n-x<<endl;
	
	return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
map<pair<int,int>,int> M;
int const P=1000000007;
int const PP=1000000009;
long long const Q=999983;
pair<int,int> f[100100];
int n;
long long ans=0;
vector<int> V[100100];
void dfs(int x){
	f[x]=make_pair(1,1);
	for(auto &&y:V[x]){
		dfs(y);
		f[x].first=(f[x].first+f[y].first*Q)%P;
		f[x].second=(f[x].second+f[y].second*Q)%PP;
	}
	ans+=M[f[x]]++;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		V[x].push_back(y);
	}
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }


int main() {
    INIT();
    int t;

    cin >> t;
    cout << (t < 30 ? "No" : "Yes");
}

Measured memory_bytes: 3648
N, K, Q = [int(i) for i in input().split()]
A = []
for _ in range(Q):
    A.append(int(input()))

points = [0]*N

for a in A:
    points[a-1] += 1

for i in range(N):
    if points[i] > Q - K:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8640
formula = gets
arr = formula.split(" ")
while arr.size != 1
	(arr.size).times do |i|
		if arr[i] == "+" and ((arr[i - 1] != "-" or arr[i - 1] != "*") and (arr[i - 2] != "-" or arr[i - 2] != "*"))
			arr[i] = arr[i - 2].to_i + arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		elsif arr[i] == "-" and ((arr[i - 1] != "+" or arr[i - 1] != "*") and (arr[i - 2] != "+" or arr[i - 2] != "*"))
			arr[i] = arr[i - 2].to_i - arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		elsif arr[i] == "*" and ((arr[i - 1] != "-" or arr[i - 1] != "+") and (arr[i - 2] != "-" or arr[i - 2] != "+"))
			arr[i] = arr[i - 2].to_i * arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		end
	end
end
puts arr[0]

Measured memory_bytes: 8884
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    int a_sum = 0;
    int b_sum = 0;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        a_sum += A[i];
    }

    for (int i = 0; i < N; i++) {
        cin >> B[i];
        b_sum += B[i];
    }

    if (a_sum > b_sum) {
        cout << "No" << endl;
        return 0;
    }

    int ope_num = b_sum - a_sum;
    int diff_num = 0; // 偶奇の異なる場所の数

    for (int i = 0; i < N; i++) {
        if (A[i] > B[i]) {
            diff_num += abs(A[i] - B[i]);
            continue;
        }

        if (abs(A[i] - B[i]) % 2 == 1) diff_num++;
    }

    if (diff_num > ope_num || abs(diff_num - ope_num) % 2 == 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};

int main() {
	int a;
	cin >> a;
	if (a == 3 ||a == 5||a == 7) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  char x, y;
  cin >> x >> y;
  if(x == y) {
    cout << '=' << endl;
  } else if(x<y) {
    cout << '<' << endl;
  } else {
    cout << '>' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
#define ll long long 

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	ll ans = 0;
	for(int i = 1; i < n; i++)
	{
		if(a[i] < a[i-1])
		{
			ans += a[i-1] - a[i];
			a[i] = a[i-1];
		}
	}
	
	cout << ans << "\n";
}


Measured memory_bytes: 3964
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var t=arr.shift()-0;
while(t--){
   var [n,k]=arr.shift().split(" ").map(Number);
   var x=arr.shift().split(" ").map(Number);
   var d=x[x.length-1]-x[0];
   var a=[];
   for(var i=0;i<x.length-1;i++)a.push(x[i+1]-x[i]);
   a.sort((a,b)=>b-a);
   var sum=0;
   for(var i=0;i<k-1;i++){
      if(i>a.length-1)break;
      sum+=a[i];
   }
   console.log(d-sum);
}


Measured memory_bytes: 54556
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  double N, T, A;
  cin >> N >> T >> A;
  double H[1010];
  double dist[1010];
  rep(i, N) cin >> H[i];
  
  rep(i, N) dist[i] = fabs(A - (T - H[i]*0.006));
  
  int num=10000;
  double mindist = 1000000;
  
  rep(i, N){
    if(mindist > dist[i]){
      mindist = dist[i];
      num = i;
    }
  }

  cout << num+1 <<endl;
}

Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const double time_limit = 1.9;
double start;

unsigned rando() {
	static unsigned y = 2463534242;
    y ^= y << 13;y ^= y >> 17;y ^= y << 5;
    return y;
}


double sec() {
	struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + tv.tv_usec * 1e-6;
}

double pastTime() {
	return sec() - start;
}

int d;

int c[26];
int s[365][26];

int score(vector<int>& t) {
	int score = 0;
	vector<int> last(26,0);
	rep(i, d) {
		score += s[i][t[i]];
		last[t[i]] = (i + 1);

		rep(j,26) {
			score -= ((i + 1) - last[j]) * c[j];
		}
		//cout  << score << endl;

	} 


	return score;

}

void output(vector<int>& t) {
	rep(i, d) {
		cout << t[i] + 1 << endl;
	}
}


int main() {
	


	cin >> d;
	rep(i, 26) {
		cin >> c[i];
	} 
	rep(i, d) {
		rep(j,26) {
			cin >> s[i][j];
		}
	}
	start = sec();
	vector<int> t(d);

	rep(i, d) {
		t[i] = rando() % 26;
	}

	int cur = score(t);


	while(true) {
		double cur_time = pastTime();
		if (cur_time > time_limit) {
			break;
		}
		//vector<int> nt = t;

		for (int loop = 0; loop < 100; loop++) {
			int cur_d = rando() % d;
			int cur_c = rando() % 26;
			int prev_c = t[cur_d];
			t[cur_d] = cur_c;
			int next = score(t);
			if (cur < next) {
				cur = next;
			} else {
				t[cur_d] = prev_c;
			}
		}
	}

	output(t);

	//cout << "score:" <<  << endl;

	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int H, W; cin >> H >> W;
    int c[11][11];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }

    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j <W; j++){
            int a; cin >> a;
            if(a == -1) continue;
            else ans += c[a][1];
        }
    }

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


Measured memory_bytes: 256
def test(x, j):
    # X, A = map(int, input().split())
    A = j.split()
    numbers = []
    result = True
    for i in A:
        numbers.append(int(i))
    result = sorted(numbers)
    if (result == True):
        print("YES")
        return "YES"
    if (result == False):
        # numbers2 = numbers[:]
        for i in range(len(numbers)):
            for x in range(i+1, len(numbers)):
                numbers2 = numbers[:]
                if swap(numbers2, i, x) == True:
                    print("YES")
                    return "TRUE"
    print("NO")
    return "FALSE"


def sorted(list):
    result = True
    for i in range(len(list)):
        if i < len(list) - 1:
            if (list[i] > list[i+1]):
                result = False
    return result


def swap(list, pos1, pos2):
    list[pos1], list[pos2] = list[pos2], list[pos1]
    return sorted(list)


N = int(input())
p = input()
test(N, p)


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

int main(){
  const int Nlen= 100000;
  string S;
  int Q;
  cin >> S >> Q;
  S.reserve(Nlen);
  
  int query,q1; string s_q;
  bool is_flipped= false;
  for(int i=0; i<Q; i++){
    cin >> query;
    if(query==1){
      is_flipped= !is_flipped;
    }
    else{
      cin >> q1 >> s_q;
      if(q1==1){
        if(!is_flipped) S.insert(0, s_q);
        else            S.append(s_q);
      }
      else{
        if(!is_flipped) S.append(s_q);
        else            S.insert(0, s_q);
      }
    }
  }
  if(is_flipped) reverse(S.begin(), S.end());

  cout << S << endl;
}

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

int main(){
long long a,d,e,s,sum;
cin>>a;
s=sqrt(a)/1;
sum=0;
  for(long long i=1;i<s+1;i++){
    if((a-i)%i==0&&(a-i)/i>i){
      sum+=(a-i)/i;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
   if(s.size()==1){
cout<<s;
return 0;
}
    bool a9=1;
    for(char c:s){
        if(c!='9'){
            a9=false;
            break;
        }
    }
if(a9){
cout<<9*s.size();
return 0;
}
  
  int ans=9*(s.size()-1)+s[0]-'0'-1;
   int sum=0;
for(char c:s) sum+=c-'0';
cout<<max(ans,sum);
    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 N = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int input1 = sc.nextInt();
			int input2 = sc.nextInt();
			ans += input2 - input1 + 1;
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 27988
N, M, Q = map(int, input().split())
a = []
for i in range(Q):
	a.append(list(map(int, input().split())))
P = 0
for i in range(1,M+1):
	for p in range(i,M+1):
		for j in range(p,M+1):
			for k in range(j,M+1):
				for m in range(k,M+1):
					for n in range(m,M+1):
						for o in range(n,M+1):
							for q in range(o,M+1):
								for r in range(q,M+1):
									for s in range(r,M+1):
										l=[i,p,j,k,m,n,o,q,r,s]
										ans=0
										for b in range(Q):
											if l[a[b][1]-1]-l[a[b][0]-1]==a[b][2]:
												ans+=a[b][3]
										P=max(P,ans)
print(P)

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


int main(void){
	char str[200000];
	scanf("%s",str);
	long long length=strlen(str);
	char abc[26]="abcdefghijklmnopqrstuvwxyz";
	long long count[26];
	long long temp=0;
	for(int i=0;i<26;i++){
		for(int j=0;j<length;j++){
			if(str[j]==abc[i]) temp++;
		}
		count[i]=temp;
		temp=0;
	}
	long long sum=0;
	for(int i=0;i<26;i++){
		if(count[i]>1) sum+=count[i]*(count[i]-1)/2;
	}

	printf("%lld",length*(length-1)/2+1-sum);
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    ll n,a;
    cin>>n;
    vector<ll> v(9);
    rep(i,0,n){
        cin>>a;
        if(a<3200)v.at(a/400)=1;
        else v.at(8)++;
    }
    rep(i,1,8)v.at(0)+=v.at(i);
    cout<<max(v.at(0),(ll)1)<<' '<<(v.at(0)+v.at(8))<<endl;
}

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

Measured memory_bytes: 1796
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	ll x;
	cin >> x;
	for(ll a = -120; a <= 120;a++)
	{
		for(ll b = -120;b<=120;b++)
		{
			ll num = a * a * a * a * a - b * b * b * b * b;
			if(num == x)
			{
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3556
# -*- coding: utf-8 -*-
from math import ceil
from math import floor
from math import sqrt

if __name__ == '__main__':
    input_line = 1
    for i in range(input_line):
        s = input().rstrip().split(' ')
        a = int(s[0])
        b = int(s[1])
        c = int(s[2])
        if(c-a-b > 0):
            print('Yes' if 4*a*b < (c-a-b)**2 else 'No')
        else:
            print('No')


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

int main() {
   vector<vector<int>> c(3, vector<int>(3));
   for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++) {
            int www; 
            cin >> www;
            c[i][j] = www;
      }
   }
   vector<int> x(3), y(3);
   x[0] = 0;
   for(int i = 0; i < 3; i++) y[i] = c[0][i] - x[0];
   for(int i = 0; i < 3; i++) x[i] = c[i][0] - y[0];
   
   bool aaa = true;
   for(int i = 0; i < 3; i++) {
   for (int j = 0; j < 3; j++) {
            if(x[i] + y[j] != c[i][j]) {
                  aaa = false;
            }
      }
   }
   
   if(aaa) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const int INF=0x7fffffff;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
const int N=200005;
int n, a[N], b[N];
ll ans;
int main(){
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout); 
	scanf("%d", &n);
	int i;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]),b[a[i]]++;
	for(i=1;i<=n;i++) ans+=b[a[i]]-1;
	ans/=2;
	for(i=1;i<=n;i++)
		printf("%lld\n", ans-(b[a[i]]-1));
	return 0;
}

Measured memory_bytes: 3712
nums = [int(i) for i in input().split()]
Max = max(nums)
a = Max - nums[0]
b = Max - nums[1]
c = Max - nums[2]
 
d = a + b + c
  
if d % 2 != 0 :
  a += 1
  b += 1
  c += 1
    
print( (a+b+c)//2 )    
    


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>	// require memset
//#include <fstream>	// require freopen

using namespace std;

const int N = 10001;
bool prime[N];

void make_prime (void )
{
	memset (prime, true, sizeof (prime ) );

	prime[0] = false;
	prime[1] = false;

	for (int i = 2; i*i <= N; ++i){
		if (prime[i] ) {
			for (int j = i*i; j <= N; j += i ){
				prime[j] = false;
			} // end for
		} // end if	
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.dat", "r", stdin );
	int n;

	make_prime();

	while (cin >> n && n ){
		int res = 0;
		for (int i = 1; i <= n; ++i){
			if (prime[i] && prime[n-i+1] ){
				++res;
			} // end if
		} // end for
		cout << res << endl;	
	} // end loop

	return 0;
}

Measured memory_bytes: 0
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll a,b,i,ans;
	cin>>a>>b;
	ans=(a+b)/2;
	if(abs(a-ans)==abs(b-ans))cout<<ans;
	else cout<<"IMPOSSIBLE";
	return 0;
}

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

int main()
{
  int64_t N, a, x, y, ans = 0;
  cin >> N;
  vector<vector<pair<int64_t, int64_t>>> vp(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    for (int j = 0; j < a; j++)
    {
      cin >> x >> y;
      x--;
      vp[i].push_back({x, y});
    }
  }
  for (int bit = 0; bit < (1 << N); bit++)
  {
    bool ok = 1;
    for (int i = 0; i < N; i++)
    {
      if (!(bit & (1 << i)))
        continue;
      for (auto p : vp[i])
      {
        tie(x, y) = p;
        if (y == 1 && (!(bit & (1 << x))))
          ok = 0;
        else if (y == 0 && (bit & (1 << x)))
          ok = 0;
      }
    }
    if (ok)
    {
      ans = max(ans, (int64_t)__builtin_popcount(bit));
    }
  }
  cout << ans << endl;
}


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)



void solve(){
    int N;//, K;
    cin >> N;// >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    sort(ALL(A), greater<>());
    int ans = A[0];
    rep(i,N-1-1){
        ans += A[i/2+1];
        dump(A[i/2+1]);
    }
    cout << ans << endl;
    
    /*

    priority_queue<P> pq;
    rep(i,N){
        if(A[i]>0) pq.push({A[i],+1});
        else pq.push({-A[i],-1});
    }
    
//    int ans = 1;
    vector<int> ans;
    int minus=0;
    while(K--){
        P v = pq.top(); pq.pop();
        ans.push_back(v.first);
        if(v.second<0) minus++;
    }
    if(minus%2==1)
    */
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 4836
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

def modfact(n, m):
    res = 1
    for i in range(2, n + 1):
        res = res * i % m
    return res

n, m = na()
a = abs(n - m)
if a > 1:
    print(0)
elif a == 1:
    print(modfact(n, mod) * modfact(m, mod) % mod)
else:
    print(modfact(n, mod) * modfact(m, mod) * 2 % mod)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
	string s;
	int n;
	string p,q,rp,rq;

	

	cin>>n;
	for(int i1=0;i1<n;i1++){
		cin>>s;
		set<string> ans;

		for(int i2=1;i2<s.size();i2++){
			p=s.substr(0,i2);
			q=s.substr(i2,s.size()-i2);
			rp=p;
			rq=q;

			reverse(rp.begin(), rp.end());
			reverse(rq.begin(), rq.end());

			ans.insert(p+q);
			ans.insert(q+p);
			ans.insert(p+rq);
			ans.insert(rq+p);
			ans.insert(rp+q);
			ans.insert(q+rp);
			ans.insert(rp+rq);
			ans.insert(rq+rp);

		}

		cout<<ans.size()<<endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

// const ll MOD = 1000000007ll;
#define MOD 1000000007

int n,m;
vector<pii> tree[25];
int cnt[1<<19];

int dfs(int s, int t, int bef, int msk){
    if(s==t)return msk;
    for(pii P : tree[s]){
        int to = P.first;
        if(to==bef)continue;
        int ret = dfs(to,t,s,msk | (1<<P.second));
        if(ret != -1)return ret;
    }
    return -1;
}

pii dp[1<<19];
int ppc[1<<19];

int main(){
    scanf("%d%d",&n,&m);
    REP(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        if(i<n-1){
            tree[a].push_back(pii(b,i));
            tree[b].push_back(pii(a,i));
        }else{
            int msk = dfs(a,b,-1,0);
            cnt[msk]++;
        }
    }
    /*REP(i,n)if(n==20 && m==190 && tree[i].size()==19){
        puts("581303120"); return 0;
    }*/
    // a
    REP(j,n-1)REP(i,1<<(n-1))if(i&(1<<j))cnt[i]+=cnt[i^(1<<j)];
    REP(i,1<<(n-1))ppc[i] = __builtin_popcount(i);
    // dp
    dp[0] = pii(1,0);
    REP(j,m-n+2){
        REP(msk,1<<(n-1))if(dp[msk] != pii(0,0)){
            ll v = ppc[msk] + j + 1;
            // use tree edge
            int rmsk = ~msk & ((1<<(n-1))-1);
            for(int x=rmsk&-rmsk; x; x=rmsk&(~rmsk+(x<<1))){
                int nmsk = msk | x;
                dp[nmsk].first += dp[msk].first;
                if(dp[nmsk].first >= MOD){
                    dp[nmsk].first -= MOD;
                }
                dp[nmsk].second = (dp[nmsk].second + dp[msk].second + 1ll * dp[msk].first * v) % MOD;
            }
            REP(i,n-1)if(!(msk>>i&1)){
                int nmsk = msk | (1<<i);
            }
        }
        if(j==m-n+1)break;
        REP(msk,1<<(n-1))if(dp[msk] != pii(0,0)){
            // use non-tree edge
            dp[msk].first = 1ll * dp[msk].first * (cnt[msk]-j) % MOD;
            dp[msk].second= 1ll * dp[msk].second* (cnt[msk]-j) % MOD;
        }
    }
    printf("%d\n",dp[(1<<(n-1))-1].second);
    return 0;
}


Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			long c = sc.nextInt();
			long d = sc.nextInt();

			long result = Long.MIN_VALUE;
			if (result < a * c) {
				result = a * c;
			}
			if (result < a * d) {
				result = a * d;
			}
			if (result < b * c ) {
				result = b * c;
			}
			if (result < b * d) {
				result = b * d;
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int now = n - r * i - g * j;
			if (now >= 0 && now % b == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

struct cubes {
  int n;
  int e;
  int w;
  int s;
  int t;
  int b;
};

void roll(cubes* cube, char dst){
  int tmp;
  switch(dst){
    case 'N' :
      tmp = cube->b;
      cube->b = cube->n;
      cube->n = cube->t;
      cube->t = cube->s;
      cube->s = tmp; 
      break;
    case 'E' :
      tmp = cube->b;
      cube->b = cube->e;
      cube->e = cube->t;
      cube->t = cube->w;
      cube->w = tmp; 
      break;
    case 'W' :
      tmp = cube->b;
      cube->b = cube->w;
      cube->w = cube->t;
      cube->t = cube->e;
      cube->e = tmp; 
      break;
    case 'S' :
      tmp = cube->b;
      cube->b = cube->s;
      cube->s = cube->t;
      cube->t = cube->n;
      cube->n = tmp; 
      break;
    default : break;
  }
}

int main(){
  cubes cube;
  string dst;
  cin >> cube.t >> cube.s >> cube.e >> cube.w >> cube.n >> cube.b;
  cin >> dst;
  for (int i=0;i<dst.size();i++){
    roll(&cube,dst[i]);
  }
  cout << cube.t << endl;
}


Measured memory_bytes: 3212
#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 ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define eb emplace_back

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

    if('A' <= c[0]  && c[0] <= 'Z') PR("A");
    else PR("a");

    return 0;
}

/*



*/

Measured memory_bytes: 3592
N, M = map(int, input().split())
H = list(map(int, input().split()))
near_max = [0]*N
for i in range(M):
  a, b = map(int, input().split())
  near_max[a-1] = max(near_max[a-1], H[b-1])
  near_max[b-1] = max(near_max[b-1], H[a-1])

ans = 0
for i in range(N):
  if near_max[i] < H[i]:
    ans += 1

print(ans)

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

using namespace std;
using ll = long long;

ll mod = 2019;
ll a[2] = {3, 673};

int main() {

  ll L, R;
  cin >> L >> R;
  if (R - L + 1 >= mod ) {
    cout << 0 << endl;
    return 0;
  }
  if (R - L == 1) {
    cout << R * L % mod << endl;
    return 0;
  }
  ll b = L % a[1] == 0 ? L : L + (a[1] - L % a[1]);
  ll c = L % a[0] == 0 ? L : L + (a[0] - L % a[0]);
  // 673の倍数が範囲外
  if (b > R) {
    ll ret = mod;
    for (ll i = L; i <= R; ++i) {
      for (ll j = i+1; j <= R; ++j) {
        ret = min(i * j % mod, ret);
      }
    }
    cout << ret << endl;
    return 0;
//    if(c<=R){
//      b = c != L ? L : L + 1;
//      for (ll i = b + 1; i <= R; ++i) {
//        if (c != i && (b * c % mod > c * i % mod))
//          b = i;
//      }
//    }else {
//      b = L % mod > R % mod ? R : L;
//      c = b != L ? L : L + 1;
//      for (ll i = c + 1; i <= R; ++i) {
//        if (b != i && (b * c % mod > b * i % mod))
//          c = i;
//      }
//    }
  } else {
    if (b == c || c > R) {
      c = b != L ? L : L + 1;
      for (ll i = b - a[0] >=0 ? b - a[0]:0; i < b + a[0] + 1; ++i) {
        if (L <= i && R >= i && b != i && (b * c % mod > b * i % mod))
          c = i;
      }
    }
  }
  cout << b * c % mod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}


main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    int re = 0;
    int BA=0, B=0, A=0;
    REP(i,n){
    	string s; cin>>s;
    	REP(j,s.length()-1){
    		if (s[j]=='A' && s[j+1] == 'B') re++;
    	}
    	bool b = s[0]=='B', a = s[s.length()-1]=='A';
    	if (b&&a) BA++;
    	else if (b) B++;
    	else if (a) A++;
    }
    // debug(BA);
    if (A>0||B>0){
    	re+=BA;
    }else{
    	if (BA) re+=BA-1;
    }
    int x = min(B, A); A-=x; B-=x; re+=x;
    if (A<B) swap(A,B);
    
    cout<<re<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	long long n,V;
	long long w[105],v[105],dp[100025];
    memset(dp,0x3f3f3f3f,sizeof(dp));
    cin>>n>>V;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    long long ans=0;
    dp[0]=0;
    for(int i=1;i<=n;i++)
	{
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=V)
                    ans=max(ans,1ll*j);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	
	int a,b,c,x;
	int ans=0;
	
	cin>>a>>b>>c>>x;
	
	for(int i=0;i<100;i++){
		
		for(int j=0;j<100;j++){
			
			for(int k=0;k<100;k++){
				
				if(500*i+100*j+50*k==x && i<=a && j<=b && k<=c){
					ans++;
				}
				
			}
			
		}
		
	}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int kaijo(int n){
    int fact = 1;
    if(n == 0) return 1;
    else{for(int i = 1; i <= n; i++){
        fact*=i;
    }
    }
    return fact;
}


/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

//for(int i = ; i < ; i++){}

int main(){
    int n,x;
    cin>>n>>x;
    int sum=0;
    int c = 0;
    for(int i = 0; i < n; i++){
        int l;
        cin>>l;
        if(sum<=x) c++;
        sum+=l;
    }
    if(sum<=x) c++;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256