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

public class Main {

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

		while(true){
			int n = Integer.valueOf(sc.nextLine());
			if(n==0) break;
			String[] s = new String[n];
			for(int i=0;i<n;i++) s[i] = sc.nextLine();
			char p = sc.nextLine().charAt(0);
			
			ArrayList<String> list = new ArrayList<String>();
			
			int[] num = new int[1000000];
			for(int i=0;i<n;i++){
				String[] t = s[i].split(" ");
				for(int j=0;j<t.length;j++){
					if(t[j].charAt(0)==p){
						if(list.contains(t[j])==true){
							num[list.indexOf(t[j])]++;
						}else{
							num[list.size()]++;
							list.add(t[j]);
						}
					}
				}
			}
			
			if(num[0]==0){
				System.out.println("NA");
			}else{
				ArrayList<String> ans = new ArrayList<String>();
				ArrayList<Integer> nlist = new ArrayList<Integer>();
				
				for(int i=0;i<list.size();i++){
					if(nlist.contains(num[i])==false) nlist.add(num[i]);
				}
				Collections.sort(nlist);
			
				int count = 0;
				for(int i=nlist.size()-1;i>=0;i--){
					for(int j=0;j<list.size();j++){
						if(num[j]==nlist.get(i)) ans.add(list.get(j));
					}
					Collections.sort(ans);
					for(int j=0;j<ans.size();j++){
						if(count!=0) System.out.print(" ");
						System.out.print(ans.get(j));
						count++;
						if(count==5) break;
					}
					if(count==5) break;
					ans.clear();
				}
				System.out.println();
			}
			
		}
	}
}

Measured memory_bytes: 151088
#include <bits/stdc++.h>
const int N = 1e5 + 54;
int n, m;
namespace Tree {
	struct node { int u, v; } edge[N << 1];
	int head[N], v[N], col[N], cnt;
	int sum, ans;
	inline void add(int x, int y) { edge[cnt].u = head[x], edge[cnt].v = y, head[x] = cnt++; }
	void dfs(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			col[y] = 1 - col[x], dfs(y, x);
		}
	}
	void solve(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			solve(y, x);
			v[x] += v[y];
		}
	}
	void SOLVE() {
		int x, y, i;
		memset(head, -1, sizeof head);
		for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), add(x, y), add(y, x);
		col[1] = 1, dfs(1, 0);
		for (i = 1; i <= n; ++i) {
			if (col[i]) v[i] = 1;
			else v[i] = -1;
			sum += v[i];
		}
		if (sum) {
			puts("-1");
			return;
		}
		solve(1, 0);
		for (i = 1; i <= n; ++i) ans += abs(v[i]);
		printf("%d\n", ans);
	}
}

namespace BRT {
	struct Edge { int id, x, y; } E;
	struct node { int u, v; } edge[N << 1];
	int head[N], v[N], col[N], cnt, tot, p[N], vis[N], f[N];
	int sum, ans;
	inline void add(int x, int y) { edge[cnt].u = head[x], edge[cnt].v = y, head[x] = cnt++; }
	void dfs(int x, int fa) {
		int i;
		vis[x] = 1;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa) continue;
			if (vis[y]) E.id = i, E.x = x, E.y = y;
			else col[y] = 1 - col[x], dfs(y, x);
		}
	}
	void solve(int x, int fa) {
		int i;
		for (i = head[x]; ~i; i = edge[i].u) {
			int y = edge[i].v;
			if (y == fa || i == E.id || (i ^ 1) == E.id) continue;
			solve(y, x), v[x] += v[y], f[x] += f[y];
		}
	}
	void SOLVE() {
		memset(head, -1, sizeof head);
		int x, y, i;
		for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), add(x, y), add(y, x);
		col[1] = 1, dfs(1, 0);
		for (i = 1; i <= n; ++i) {
			if (col[i]) v[i] = 1;
			else v[i] = -1;
			sum += v[i];
		}
		if (col[E.x] == col[E.y]) {
			if (abs(sum) & 1) {
				puts("-1");
				return;
			}
			v[E.x] -= sum / 2, v[E.y] -= sum / 2, ans += abs(sum / 2);
		} else {
			if (sum) {
				puts("-1");
				return;
			}
			f[E.x] = 1, f[E.y] = -1;
		}
		solve(1, 0);
		if (col[E.x] == col[E.y]) {
			for (i = 1; i <= n; ++i) ans += abs(v[i]);
			printf("%d\n", ans);
			return;
		}
		for (i = 1; i <= n; ++i)
			if (f[i] == 0) ans += abs(v[i]);
			else p[++tot] = f[i] * v[i];
		p[++tot] = 0;
		std::sort(p + 1, p + tot + 1);
		int mid = p[(tot + 1) >> 1];
		for (i = 1; i <= tot; ++i) ans += abs(p[i] - mid);
		printf("%d\n", ans);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	if (m == n - 1) Tree::SOLVE();
	else BRT::SOLVE();
}

Measured memory_bytes: 9344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
typedef vector<pii> vp;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int main() {
	int n, a, b;
	cin >> n >> a >>b;
	
	string s;
	cin >> s;
	
	int now = 0, cnt = 1;
	REP(i, s.size()) {
		bool ok = true;
		
		if (a + b <= now) ok = false;
		else {
			if (s[i] == 'b') {
				if (cnt <= b) cnt++;
				else ok = false;
			}
			if (s[i] == 'c') ok = false;
		}
		
		if (ok) {
			puts("Yes");
			now++;
		}
		else 
			puts("No");
	}
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll k, n, ans = 0;
    cin >> k >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> d;
    for(int i = 1; i < n; i++){
        d.push_back(a[i] - a[i - 1]);
    }
    d.push_back(k - a.back() + a[0]);
    sort(begin(d), end(d));
    for(int i = 0; i < d.size() - 1; i++){
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int a = 0, b = 0, c = 0, d = 0;
  	cin>>a>>b>>c>>d;
  	
  	int aturn = c/b, bturn = a/d;
    if((aturn*b) != c)
      aturn += 1;
    if((bturn*d) != a)
      bturn += 1;
    if(aturn <= bturn)
      cout<<"Yes\n";
    else
      cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3648
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

from collections import deque
def solve():
    prev = [-1]*N
    prev[0]='Yes'
    d = deque([(0,0)])
    while len(d):
        v,cnt = d.popleft()
        for u in edge[v]:
            if prev[u]==-1:
                prev[u]=v+1
                d.append((u,cnt+1))
    if -1 in prev:
        return ['No']
    return prev
print(*solve(),sep='\n')

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


void trace(int A[], int N) {
    int i;
    for ( i = 0; i < N; i++) {
        if ( i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;

}


void insertionSort(int A[], int N) {
    int i, j, u;
    for ( i = 1; i < N; i++) {
        j = i - 1;
        u = A[i];
        while ( u < A[j] && j >= 0) {
            A[j+1] = A[j];
            j--;
    }
    A[j+1] = u;
    trace(A, N);
    }

}

            
int main() {
    int N, i, j;
    int A[100];

    cin >> N;
    for ( i = 0; i < N; i++)  cin >> A[i];
   
    trace(A, N);
    insertionSort(A, N);
    return 0;   
}


Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

const int SIZE = 50 + 5;
int bridge[SIZE << 1], n, m, tot;
int head[SIZE << 1], edge[SIZE << 1];
int _next[SIZE << 1], ver[SIZE << 1];
int dfn[SIZE], low[SIZE], cnt, ans;

inline void addEdge(int x, int y, int z) {
	ver[++tot] = y, edge[tot] = z;
	_next[tot] = head[x], head[x] = tot;
}

inline void Tarjan(int x, int fa) {
	dfn[x] = low[x] = ++cnt;
	for (int i = head[x]; i; i = _next[i]) {
		int y = ver[i], z = edge[i];
		if (!dfn[y]) {
			Tarjan(y, x);
			low[x] = min(low[x], low[y]);
			if (low[y] > dfn[x]) ans++;
		}
		else if (y ^ fa) low[x] = min(low[x], dfn[y]);
	}
}

signed main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int from, to;
		scanf("%d %d", &from, &to);
		addEdge(from, to, 1);
		addEdge(to, from, 1);
	}
	Tarjan(1, 0);
	printf("%d\n", ans);
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        System.out.println(Math.min(N*A,B));
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
   int n;
   cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
   std::sort(a.rbegin(), a.rend());
   ll ans = 0;
   int t=n-1; //何回足せるか
   rep(i,n){
      int lim = 2; //足せる回数
      if(i==0) lim = 1; //最初の1つは1回しか足せない
      rep(j,lim){
          if(t>0){
              ans+=a[i];
              t--;
          }
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int A,B;
  cin>>A>>B;
  
  int count=0;
  int outlet=1;
  
  while(outlet<B){
    --outlet;
    outlet+=A;
    ++count;
  }
  
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double

#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const ll mod =1e9+7;
const ll maxn=1e6+10;
ll f[maxn+10];
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
    }
int main()
{ 
  
   IOS
   f[0]=1;
  for(ll i=1;i<=maxn;i++)
  {
    f[i]=f[i-1]*i;
    f[i]%=mod;
  } 
  ll x,y;
  cin>>x>>y;
  if((x+y)%3!=0||(2*x<y)||(2*y<x))
    {
      cout<<0;
      return 0;
    }
  ll ans=((f[(x+y)/3]*(power(f[(2*x-y)/3],mod-2))%mod*(power(f[(2*y-x)/3],mod-2)))%mod)%mod;
  cout<<ans<<endl;
  
  

}


Measured memory_bytes: 8192
#include<cstdio>

double point[4][2];



double p(double b)
{

	if(0>b)return -b;
	return b;
}

int main()
{
	while(true)
	{
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<2;j++)
			{
				if(scanf("%lf",&point[i][j])==EOF)goto end;
			}
		}
	    if(((point[0][0]-point[1][0])*(point[2][0]-point[3][0])==-(point[2][1]-point[3][1])*(point[0][1]-point[1][1])))
			printf("YES\n");
		else printf("NO\n");
	}
end:
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

int m,k;
int main()
{
	scanf("%d%d",&m,&k);
	if(m == 1)
	{
		if(k == 0)
			puts("0 0 1 1");
		else
			puts("-1");
	}
	else
	{
		int n = (1<<m) -1;
		if(k>=0 && k<=n)
		{
			vector<int> ans;
			for(int i=n;i>=0;i--)
			{
				if(i == k)continue;
				ans.push_back(i);
			}
				
			ans.push_back(k);
			for(int i=0;i<=n;i++)
			{
				if(i == k)continue;
				ans.push_back(i);
			}
			ans.push_back(k);
			for(int i=0;i<ans.size()-1;i++)
			{
				printf("%d ",ans[i]);
			}
			printf("%d\n",ans[ans.size()-1]);
		}
		else
			puts("-1");
	}
	return 0;
}

Measured memory_bytes: 2932
array = gets.split(" ").map(&:to_i)
min = array[1] * (array[0] - 1) + array[2]
max = array[2] * (array[0] - 1) + array[1]
if array[2] < array[1]
  puts 0
elsif array[0] != 1 
  puts max - min +1
elsif array[1] == array[2]
  puts 1
else 
  puts 0
end

Measured memory_bytes: 1788
function Main(input) {
  input=input.split("\n");
  var array=input[0].split(" ");
  array.sort();
  //console.log(array);
  console.log((array[0]==="5"&&array[1]==="5"&&array[2]==="7")?"YES":"NO");
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  

Measured memory_bytes: 30656
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

p1 = (sum(p[:k]) + k)/2

ansum = [p1]
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum.append(p1)

print(max(ansum))

Measured memory_bytes: 72584
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		long ans = 0;
		int plus = s.length() - 1;
		int max = (int) Math.pow(2, plus);
		for (int i = 0; i < max; i++) {
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < 9; j++) {
				if ((i >> j) % 2 == 1) {
					list.add(j + 1);
				}
			}
			int start = 0;
			for (int end : list) {
				ans += Long.parseLong(s.substring(start, end));
				start = end;
			}
			ans += Long.parseLong(s.substring(start, s.length()));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && b != c) || (a == c && b != c) || (b == c && a != b))puts("Yes");
	else puts("No");
	ggr
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split(" "))

turn = 0

while a > 0 and c > 0:
    if turn % 2 == 0:
        c -= b
    else:
        a -= d
    turn += 1

if turn % 2 == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9132
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class CVacation {
public:
	void solve(istream& in, ostream& out) {
        int n; in >> n;
        ll a[n][3];
        rep(i,n) rep(j,3) in >> a[i][j];
      ll dp[100005][3];
      rep(i,100005) rep(j,3) dp[i][j] = 0;
                

        rep(i,n){
          rep(j,3){
                rep(k, 3){
                    if (j != k) dp[i+1][j] = max(dp[i][k] + a[i][j], dp[i+1][j]);
                }
            }
        }
        ll ans = 0;
      rep(i,3) ans = max(dp[n][i],ans);
      out << ans << endl;
        }

};

int main() {
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 4992
// 6/19 解き直し
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

const int INF = 1001001001;

int c[10][1005];

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int ans = INF;

    // 横向きの切り方を全列挙
    rep(div, 1<<(h-1)) {  // << はシフト演算子。2^(h-1)パターンある。（切り込みはh-1箇所ある）
        int g = 0;  // グループ番号。初めは１。
        vector<int> id(h);  // 各行が上から数えて何グループ目に属するかをメモする。
        rep(i, h) {
            id[i] = g;
            // divのi桁目が1かどうか。&1は1のくらいが1かどうか。
            if (div>>i&1) {
                ++g;  // グループ番号をインクリメントする。
            }
            
        }
        ++g;  // 最後に+1するとグループ数になる。

        // vector<vector<int>> c(g, w)  ←　Vectorで二次元配列は面倒！とのこと。
        rep(i, g)rep(j, w) c[i][j] = 0;  // 一旦初期化。何回も使うので。
        rep(i, h)rep(j, w) c[id[i]][j] += (s[i][j]-'0');  // グループにホワイトチョコの数を足していく。
        
        int num = g-1;  // とりあえず横向きにグループ数-1回は切る。
        vector<int> now(g);  // 各グループで合計何個ホワイトトコレートを持っているか見る。

        // j列目をnowに加算して、どこかがkを超えていたらfalseを返すラムダ式。
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            // bool ok = true;
            rep(i, g) if (now[i] > k) return false;
            return true;
        };

        rep(j, w) {
            // if (!ok) {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                if (!add(j)) {  // nowを初期化して、今の列を改めて足す。
                    num = INF;  // それでも失敗したら、１列にk以上含まれているので、絶対むり。
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define dump(x) cerr << #x " = " << boolalpha << (x) << endl;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  double k;
  cin >> n >> k;

  auto ans = 0.0;

  for (size_t dice = 1; dice <= n; ++ dice)
  {
    int b = ceil (log2 (k / dice));
    b = max (b, 0);
    ans += pow (0.5, b) / n;
  }

  char ans_string [1024];
  sprintf (ans_string, "%.24f", ans);

  cout << ans_string << endl;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function snk(x::Int)
	y = x
	t = 0
	while y>0
		t += y%10
		y = div(y,10)
	end
	x/t
end

function main()
	k = readline() |> parseInt
	x = 0
	r = 0
	now = 1
	while x<k
		s = div(now,10^r)*10^r
		t = (div(now,10^r)+1)*10^r
		for i in 0:r-1
			s += 9*10^i
			t += 9*10^i
		end
		if snk(s)>snk(t)
			r += 1
		else
			println(s)
			x += 1
		end
		now = t
	end
end
main()

Measured memory_bytes: 106308
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	int b;
	int c;
	int d;
	int min;
	cin>>a>>b>>c>>d;
	if(a<b)
		min+=a;
	else
		min+=b;
	if(c<d)
		min+=c;
	else
		min+=d;
	cout<<min;
			
} 

Measured memory_bytes: 256
d = int(input())
cl = list(map(int, input().split()))
sl = []
for _ in range(d):
    sl.append(list(map(int, input().split())))

tl = []
# for _ in range(d):
#     tl.append(int(input()))

last_di = [-1]*26
ans = 0
for day in range(d):
    # if day <= 100:
    #     coef = 1.0*day/36.0 + 3.0
    # else:
    #     coef = 10.0 - 1.0*day/36.0 + 3.0
    coef = 5.0 - day/400.0
    best_t = 0
    best_t_val = -999999999999
    for t in range(26):
        curr_val = sl[day][t]*1
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]*coef
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day
    ans += best_t_val
    # print(ans)
    # print('-- {}---'.format(day))
    # print(best_t)
    # print(last_di)

for t in tl:
    print(t)

# for day, t in enumerate(tl):
#     ans += sl[day][t-1]
#     last_di[t-1] = day
#     for ld, c in zip(last_di, cl):
#         # if ld == -1: continue
#         ans -= (day-ld)*c
#     print(ans)

Measured memory_bytes: 9400
[N,M] = list(map(int,input().split()))
X = list(map(int,input().split()))
X.sort()
output = 0
if N>=M:
    print(output)
else:
    Y = []
    for i in range(1,M):
        Y.append(X[i]-X[i-1])
    Y.sort()
    output += sum(Y[0:(M-N)])
    print(output)


Measured memory_bytes: 56744
#include <map>
#include <iostream>
#include <iterator>
using namespace std;
int main(){
    int q,k;
    string s;
    map<string,int>m;
    map<string,int>::iterator u,v;
    cin>>q;
    while(q--){
        cin>>k>>s;
        if(k==0){
            cin>>k;
            if(m.find(s)!=m.end())m[s]=k;
            else m.insert({s,k});
        }
        else if(k==1){
            if(m.find(s)!=m.end())cout<<m[s]<<endl;
            else cout<<0<<endl;
        }
        else if(k==2)m.erase(s);
        else{
            u=m.lower_bound(s);
            cin>>s;
            while(u!=m.end()){
                if(u->first>s)break;
                cout<<u->first<<' '<<u->second<<endl;
                u++;
            }
        }
    }
}


Measured memory_bytes: 27828
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long int
    int n,k,a,cnt=0,p=0;
    vector<int>v;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a;v.push_back(a);
    }
    if(k>=n){cout<<0<<endl;return 0;}
    else
    {
        sort(v.begin(),v.end(),greater<int>());
        if(k>=1)p+=k;
        else p=0;
        for(int i=p;i<n;i++)
        {
            cnt+=v[i];
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 2420
from collections import deque


s = list(input())
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    arr = list(map(str, input().split()))
    if arr[0] == '1':
        cnt += 1
        cnt %= 2
    else:
        if (arr[1] == '1' and cnt == 0) or (arr[1] == '2' and cnt == 1):
            ans.appendleft(arr[2])
        else:
            ans.append(arr[2])
if cnt == 0:
    print(*ans, sep='')
else:
    ans.reverse()
    print(*ans, sep='')



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

point = [0] * N

for i in A:
    point[i - 1] = point[i - 1] + 1

point1 = []
for p in point:
    point1.append(K - (Q - p))

for p in point1:
    if p <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 12636
#include<bits/stdc++.h>
using namespace std;
int main (){
    int A, C , a,b;
    char o;
    cin >> A>> o>> C;
    if(o == '+'){
        a = A + C;
        cout << a <<endl;
    }
    else{
        a= A - C;
        cout << a <<endl;
    }
    
}

Measured memory_bytes: 256
N, M = map(int, input().split())
if N%2:
    for i in range(1, M+1):
        print(i, N-i)
else:
    if M%2:
        for i in range(1, M+1):
            if i <= -(-(N//2)//2):
                print(i, N-i+1)
            else:
                print(i+1, N-i+1)
    else:
        for i in range(1, M+1):
            if i < -(-(N//2)//2):
                print(i, N-i+1)
            else:
                print(i+1, N-i+1)


Measured memory_bytes: 75144
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,k;
    cin>>n>>k;
        if(n%k==0)cout<<"0\n";
        else cout<<"1\n";


    
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
string s;cin>>s;int l=s.length();int a=0,b=0,i=l;
while(s[a]!='A')
{a++;}

while(s[i-1]!='Z')
{
	i--;b++;
}
cout<<l-(a+b);

return 0;
}


Measured memory_bytes: 640
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    
    priority_queue<int> q1,q2;
    int x,res1,res2;
    void solve()
    {
       cin>>n;
       fo(i,0,n)
       {
           cin>>x;
           q1.push(x);
           q2.push(-x);
       }
       
       if(n&1)
       {
           fo(i,0,n/2)
           {
               res1+=q1.top()*2;
               q1.pop();
               res2+=q2.top()*2;
               q2.pop();
           }
           
           res1-=q1.top();
           q1.pop();
           res1-=q1.top();
           q1.pop();
           res2-=q2.top();
           q2.pop();
           res2-=q2.top();
           q2.pop();
           
           fo(i,1,n/2)
           {
               res1-=q1.top()*2;
               q1.pop();
               res2-=q2.top()*2;
               q2.pop();
           }
           cout<<max(res1,res2)<<endl;
           
       }
       else
       {
           fo(i,1,n/2)
           {
               res1+=q1.top()*2;
               q1.pop();
           }
           res1+=q1.top();
           q1.pop();
           res1-=q1.top();
           q1.pop();
           fo(i,1,n/2)
           {
               res1-=q1.top()*2;
               q1.pop();
           }
           
           cout<<max(res1,res2)<<endl;
       }
 
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }


Measured memory_bytes: 2036
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	string c1, c2;
	cin >> c1 >> c2;
	
	reverse(c2.begin(), c2.end());
	if(c1 == c2) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int q = sc.nextInt();
        
        ArrayDeque<Integer> deq = new ArrayDeque<>();
        for (int i = 0; i < str.length(); i++) {
            deq.offerLast(str.charAt(i) - 'a');
        }
        boolean reverse = false;
        while (q-- > 0) {
            int type1 = sc.nextInt();
            
            if (type1 == 1) {
                reverse = !reverse;
            } else {
                int type2 = sc.nextInt();
                String s = sc.next();
                int t = s.charAt(0) - 'a';
                
                if (type2 == 1) {
                    if (!reverse) {
                        deq.offerFirst(t);
                    } else {
                        deq.offerLast(t);
                    }
                } else {
                    if (reverse) {
                        deq.offerFirst(t);
                    } else {
                        deq.offerLast(t);
                    }
                }
            }
        }
        
        if (!reverse) {
            while (!deq.isEmpty()) {
                char c = (char)(deq.pollFirst() + 'a');
                System.out.print(c);
            }
        } else {
            while (!deq.isEmpty()) {
                char c = (char)(deq.pollLast() + 'a');
                System.out.print(c);
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 157200
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var n = long.Parse(input[0]);
        var m = long.Parse(input[1]);
        var l = long.Parse(input[2]);
        var a = new long[n, m];
        var b = new long[m, l];
        var c = new long[n, l];
        for (int i = 0; i < n; i++)
        {
            var input2 = Console.ReadLine().Split();
            for (int j = 0; j < m; j++)
            {
                a[i, j] = int.Parse(input2[j]);
            }
        }
        for (int i = 0; i < m; i++)
        {
            var input3 = Console.ReadLine().Split();
            for (int j = 0; j < l; j++)
            {
                b[i, j] = int.Parse(input3[j]);
            }
        }
        for (int i = 0; i < n; i++)
        {
            var output = "";
            for (int j = 0; j < l; j++)
            {
                c[i, j] = 0;
                for (int k = 0; k < m; k++)
                {
                    c[i, j] += a[i, k] * b[k, j];
                }
                output += (j == 0) ? c[i, j].ToString() : (" " + c[i, j].ToString());
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 19912
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
#define INF 0xfffffff
typedef long long int lli;
typedef pair<lli,lli> P;
lli ans,sgx[10],sgy[10],w,h,n,dtmp[1000][1000],d[1000][1000],sx,sy,gx,gy,nx,ny;
lli dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char s[1001];
queue <P> que;
int main()
{
	scanf("%lld %lld %lld",&h,&w,&n);
	for(int i=0;i<h;i++){
		scanf("%s",s);
		for(int j=0;j<w;j++){
			if(s[j]=='X') dtmp[i][j]=-1;
			if(s[j]=='.') dtmp[i][j]=INF;
			if('1'<=s[j]&&s[j]<='9'){
				dtmp[i][j]=INF;
				sgx[s[j]-'0']=j;
				sgy[s[j]-'0']=i;
			}
			if(s[j]=='S'){
				dtmp[i][j]=INF;
				sgx[0]=j;
				sgy[0]=i;
			}
		}
	}
	for(int i=0;i<n;i++){
		while(!que.empty()) que.pop();
		for(int j=0;j<h;j++) for(int k=0;k<w;k++) d[j][k]=dtmp[j][k];
		sx=sgx[i];
		sy=sgy[i];
		gx=sgx[i+1];
		gy=sgy[i+1];
		d[sy][sx]=0;
		que.push(P(sx,sy));
		while(1){
			P p=que.front();
			que.pop();
			nx=p.first;
			ny=p.second;
			for(int j=0;j<4;j++){
				if(0<=nx+dx[j]&&0<=ny+dy[j]&&nx+dx[j]<w&&ny+dy[j]<h&&d[ny+dy[j]][nx+dx[j]]>d[ny][nx]+1){
					d[ny+dy[j]][nx+dx[j]]=d[ny][nx]+1;
					if(nx+dx[j]==gx&&ny+dy[j]==gy){
						ans+=d[ny+dy[j]][nx+dx[j]];
						goto next;
					}
					que.push(P(nx+dx[j],ny+dy[j]));
				}
			}
		}
		next: ;
	}
	printf("%lld\n",ans);
}

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

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

	string rev_s = s;
	reverse(rev_s.begin(), rev_s.end());
	if (rev_s != s) {
		cout << "No" << endl;
		return 0;
	}

	string cond2 = s.substr(0, s.length() / 2);
	string rev_cond2 = cond2;
	reverse(rev_cond2.begin(), rev_cond2.end());
	if (rev_cond2 != cond2) {
		cout << "No" << endl;
		return 0;
	}

	string cond3 = s.substr((s.length() + 2) / 2, s.length());
	string rev_cond3 = cond3;
	reverse(rev_cond3.begin(), rev_cond3.end());
	if (rev_cond3 != cond3) {
		cout << "No" << endl;
		return 0;
	}

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

Measured memory_bytes: 256
S = input()
T = input()
S_len = len(S)
T_len = len(T)
S_sorted = sorted(S)
T_sorted = sorted(T, reverse=True)
ans = True
for i in range(min(S_len, T_len)):
    s = ord(S_sorted[i])
    t = ord(T_sorted[i])
    if s < t:
        print('Yes')
        exit(0)
    if s == t:
        continue
    else:
        print('No')
        exit(0)
if S_len >= T_len:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 8972
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;

void go() {
	int n,k,x;
	x = 1;
	cin >> n >> k;
	for(;n--;) {
		int a,b;
		a = x*2;
		b = x+k;
		if(a<b) x = a;
		else x = b;
	}
	cout << x << endl;
}
 
int main() {
	go();
	return 0;
}




Measured memory_bytes: 256
// overkill sol to https://atcoder.jp/contests/abc097/tasks/arc097_a
// more functions https://github.com/bqi343/USACO/blob/master/Implementations/content/strings%20(14)/Heavy/SuffixAutomaton.h

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

struct state {
    int len, link;
    map<char, int> adj;
};
const int MAXLEN = 100002;
state a[MAXLEN * 2];
int sz, last;

void sa_init() {
    a[0].len = 0;
    a[0].link = -1;
    sz++;
    last = 0;
}

void sa_extend(char c) {
    int cur = sz++;
    a[cur].len = a[last].len + 1;
    int p = last;
    while (p != -1 && !a[p].adj.count(c)) {
        a[p].adj[c] = cur;
        p = a[p].link;
    }
    if (p == -1) {
        a[cur].link = 0;
    } else {
        int q = a[p].adj[c];
        if (a[p].len + 1 == a[q].len) {
            a[cur].link = q;
        } else {
            int clone = sz++;
            a[clone].len = a[p].len + 1;
            a[clone].adj = a[q].adj;
            a[clone].link = a[q].link;
            while (p != -1 && a[p].adj[c] == q) {
                a[p].adj[c] = clone;
                p = a[p].link;
            }
            a[q].link = a[cur].link = clone;
        }
    }
    last = cur;
}

ll cnt[MAXLEN];

ll getsize(int x) {
    if (cnt[x]) return cnt[x];
    cnt[x] = 1;
    for(auto i: a[x].adj){
        cnt[x] += getsize(i.second);
    }
    return cnt[x];
}

string kth(int cur, int k){
    assert(k < cnt[cur]);
    if(!k) return "";
    k--;
    for(auto i: a[cur].adj){
        if(k < cnt[i.second])
            return i.first+kth(i.second, k);
        k -= cnt[i.second];
    }
    return "";
}

int main(){
    string s; int k;
    cin >> s >> k;
    sa_init();
    for(auto c: s)
        sa_extend(c);
    getsize(0);
    cout << kth(0, k);
    
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
const ll INF = 1e17;

ll Pow(ll x, ll n){
  if(x == 0) return 0;
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod, n/2);
  else return x * Pow(x,n-1) % mod;
}

ll mod_inverse(ll a) {
  return Pow(a,mod-2);
}

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 1;
  ll a[n];
  P b[n];
  rep(i,n) {
    cin >> a[i];
    if(a[i] >= 0) b[i] = P(a[i],1);
    else b[i] = P(-a[i],-1);
  }
  sort(b,b+n,greater<P>());
  int sign = 1;
  ll minus = INF;
  ll plus = INF;
  rep(i,k) {
    (ans *= b[i].first) %= mod;
    sign *= b[i].second;
    if(b[i].second < 0) minus = min(minus,b[i].first);
    if(b[i].second > 0) plus = min(plus,b[i].first);
  }
  if(sign < 0) {
    ll c = -INF;
    ll d = -INF;
    for(int i = k; i < n; i++) {
      if(b[i].second > 0) c = max(c,b[i].first);
      else d = max(d,b[i].first);
    }
    if(plus != INF and d >= 0 and c >= 0) {
      if(d*minus >= c*plus) {
        (ans *= mod_inverse(plus)) %= mod;
        (ans *= d) %= mod;
      } else {
        (ans *= mod_inverse(minus)) %= mod;
        (ans *= c) %= mod;
      }
    } else if(plus == INF or d < 0) {
      if(c >= 0) {
        (ans *= mod_inverse(minus)) %= mod;
        (ans *= c) %= mod;
      } else {
        ans = -1;
        for(int i = n-1; i >= n-k; i--) (ans *= b[i].first) %= mod;
      }
    } else {
      (ans *= mod_inverse(plus)) %= mod;
      (ans *= d) %= mod;
    }
  }
  if(ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8292
#include<stdio.h>
#include<stdlib.h>

int main(){
 int time;
 scanf("%d",&time);
 int h,m,s;
 s=time%60;
 time=time/60;
 m=time%60;
 h=time/60;
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

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


int main() {
  int a,b;
  cin >> a >> b;
  if(a == 1) a += 13;
  if(b == 1) b += 13;

  if(a > b)cout << "Alice" << endl;
  else if(a == b) cout << "Draw" << endl;
  else cout << "Bob" << endl; 
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=50+5;
int a[MAXN];int n,ans;
void DFS(int now,long long v)
{
	if(now==n+1)
	{
//		printf("%d ",v);
		if(v%2==0) ans++;
		return;
	}
	for(int i=-1;i<=1;i++)
		DFS(now+1,v*(a[now]+i));
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	DFS(1,1);
	printf("%d",ans);
	return 0;
}


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

using namespace std;

int main(){
	int n , k;
	cin>>n>>k;
	vector<int> in(n);
	for(int i = 0 ; i < n ; i++) cin>>in[i];
	vector<int> dp(n , 2e9 + 7);
	dp[0] = 0;
	for(int i = 1 ; i < n ; i++)
		for(int t = (i - k >= 0 ? i - k : 0) ; t < i ; t++)
			dp[i] = min(dp[t] + abs(in[i] - in[t]) , dp[i]);
	cout<<dp[n - 1]<<endl;
}

Measured memory_bytes: 4040
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] point = new int[2];

            for (int i = 0; i < n; i++)
            {
                string[] animal = Console.ReadLine().Split(' ');
                if (string.Compare(animal[0],animal[1]) == 1)
                {
                    point[0] += 3;
                }
                else if (string.Compare(animal[0], animal[1]) == -1)
                {
                    point[1] += 3;
                }
                else
                {
                    point[0] += 1;
                    point[1] += 1;
                }
            }
            Console.WriteLine("{0} {1}", point[0], point[1]);
        }
    }
}


Measured memory_bytes: 18792
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, K;
	Long[] H;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		this.N = Integer.parseInt(tokens[0]);
		this.K = Integer.parseInt(tokens[1]);
		tokens = in.readLine().split(" ");
		this.H = new Long[N];

		for (int i = 0; i < N; ++i) {
			H[i] = Long.parseLong(tokens[i]);
		}
		Arrays.sort(H, new Comparator<Long>() {
			@Override
			public int compare(Long o1, Long o2) {
				return -1 * Long.compare(o1, o2);
			}
		});
	}

	void calc() {
		Queue<Long> que = new ArrayDeque<>(N);
		for (int i = 0; i < N; ++i) {
			que.add(H[i]);
		}
		// まず必殺技を可能な限りかける
		for (int i = 0; i < K; ++i) {
			que.poll();
			if (que.isEmpty()) {
				break;
			}
		}
		// のこりをたす
		while (!que.isEmpty()) {
			result += que.poll();
		}

	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 81880
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

//////////////////////////////////////////////////////////////////////
int num = 32;

int main() {
	int n; cin >> n;
	vi a(n); rep(n)cin >> a[i];
	
	for (int i = 0; i < 32; i++) {
		int c1=0, c2=0;
		for (int j = 0; j < n; j++) {
			if (((a[j]>>i)&1) == 0) c1++;
			else c2++;
		}
		if (!(c2 == 0 || c1 * 2 == c2)) { pno; fin; }
	}
	pyes; fin;
}


Measured memory_bytes: 1024
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := getString(), getString()
	c, _ := strconv.Atoi(a + b)

	d := int(math.Sqrt(float64(c)))
	if d*d == c {
		out("Yes")
	} else {
		out("No")
	}
}


Measured memory_bytes: 640
n, m = map(int, input().split())

mod = 1000000007

from collections import deque

d = deque()

for _ in range(m):
    d.append(int(input()))

old = 0
new = 1

for i in range(1, n+1):
    if len(d):
        if i != d[0]:
            old, new = new, (old+new) % mod
        else:
            old, new = new, 0
            d.popleft()
    else:
        old, new = new, (old+new) % mod



print(new)

Measured memory_bytes: 46040
from pprint import pprint
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []

c = 0
cp = []
cm = []
for a, b in zip(A, B):
    if a - b >= 0:
        cp.append(a - b)
    elif a - b < 0:
        cm.append(a - b)

ans = len(cm)
cp.sort(reverse=True)
pi = 0
pnum = cp[0]
for mnum in cm:
    while abs(mnum) >= pnum:
        pi += 1
        if pi >= len(cp):
            print(-1)
            exit()
        pnum += cp[pi]
    pnum += mnum

if cm:
    print(ans + pi + 1)
else:
    print(ans)


Measured memory_bytes: 19636