akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
  	cin>>n;
  	long long int ans=1,a[n];
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	if(a[i]==0){
        	cout<<"0";
          	return 0;
        }
    }
  	long long int moto=1000000000000000000;
  	for(int i=0;i<n;i++){
      	ans=ans*a[i];
      	if(moto>=a[i]) moto=moto/a[i];
      	else {
          			cout<<"-1";
             		return 0;
             }
    }
  	cout<<ans;
  	return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

int n, a[100001];
int dp[100001];

//LIS

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	fill(dp, dp + n, INF);
	for (int i = 0; i < n; i++) {
		*lower_bound(dp, dp + n, a[i]) = a[i];
	}
	cout << lower_bound(dp, dp + n, INF) - dp << endl;
	return 0;
}

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

	int res = 0;
	for (int i = 0; i < n; i++) {
		dp[i] = 1;
		for (int j = 0; j < i; j++) {
			if (a[j] < a[i]) {
				dp[i] = max(dp[i], dp[j] + 1);;
			}
		}
		res = max(res, dp[i]);
	}
	cout << res << endl;
	return 0;
}
*/


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


long long int knapsack(int wt[], int val[], int n, int w){

	long long int dp[n+1][w+1];

	for(int i=0;i<n+1;i++){
		for(int j=0;j<w+1;j++){

			if(i==0||j==0) dp[i][j]=0;
		}
	}

	for(int i=1;i<n+1;i++){
		for(int j=1;j<w+1;j++){

			if(wt[i-1]<=j){
				dp[i][j]= max(val[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
            }
            else dp[i][j]= dp[i-1][j];
            
            
		}
		
		
	}

	return dp[n][w];

}




int main(){

	int N,W;
    cin>>N>>W;

    int wt[N];
    int val[N];

    for(int i=0;i<N;i++){

    	cin>>wt[i]>>val[i];
    }

   cout<<knapsack(wt,val,N,W)<<endl;


}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;




void solve(){
  
  int n;
  cin>>n;

  vec arr(n+1);
  fo(i,1,n) {
    cin>>arr[i];
  }

  umap mp;
  mp[arr[1] + 1]++;

  ll ans = 0;

  for(int i=2; i<=n; i++) {
    
      int val = i - arr[i];

      ans+= mp[val];

      mp[arr[i] + i]++;

  }

  cout<<ans<<endl;




}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

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

int frog(vector<int> v){
  vector<int> a(v.size(), 0);
  a[1]=abs(v[0]-v[1]);
  for(int i=2; i<v.size(); i++){
  	a[i] = min(abs(v[i]-v[i-2])+a[i-2], abs(v[i]-v[i-1])+a[i-1]);
  }
  return a[v.size()-1];
}

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin>>v[i];
  cout<<frog(v);
  return 0;
}

Measured memory_bytes: 4272
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Info{
	Info(int arg_from_row,int arg_from_col,int arg_to_row,int arg_to_col){
		from_row = arg_from_row;
		from_col = arg_from_col;
		to_row = arg_to_row;
		to_col = arg_to_col;
	}

	int from_row,from_col,to_row,to_col;
};


int H,W;
int table[505][505];
vector<Info> info;

int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			scanf("%d",&table[row][col]);
		}
	}

	int to_right = 1;
	for(int row = 0; row < H; row++){
		if(to_right){
			for(int col = 0; col <= W-2; col++){

				if(table[row][col]%2 == 1){

					table[row][col+1]++;
					info.push_back(Info(row,col,row,col+1));
				}
			}
			if(row != H-1 && table[row][W-1]%2 == 1){

				table[row+1][W-1]++;
				info.push_back(Info(row,W-1,row+1,W-1));
			}

		}else{
			for(int col = W-1; col >= 1; col--){
				if(table[row][col]%2 == 1){

					table[row][col-1]++;
					info.push_back(Info(row,col,row,col-1));
				}
			}
			if(row != H-1 && table[row][0]%2 == 1){

				table[row+1][0]++;
				info.push_back(Info(row,0,row+1,0));
			}
		}

		to_right = 1-to_right;
	}

	printf("%lld\n",info.size());

	for(int i = 0; i < info.size(); i++){

		printf("%d %d %d %d\n",info[i].from_row+1,info[i].from_col+1,info[i].to_row+1,info[i].to_col+1);
	}

	return 0;
}


Measured memory_bytes: 6372
#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--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll L;
    cin >> L;
    long double A = (long double)L/3*(long double)L/3*(long double)L/3;
    cout << fixed << setprecision(15) << A << endl;
    return 0;    
}

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

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

  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;

    vector<int> x;
    x.reserve(n);
    for (int j = 0; j < n; j++) {
      int _x;
      cin >> _x;
      x.emplace_back(_x);
    }

    vector<int> y;
    y.reserve(n - 1);
    for (int j = 0; j < n - 1; j++) {
      int _y = x[j + 1] - x[j];
      y.emplace_back(_y);
    }
    sort(y.begin(), y.end());

    int sum = 0;
    for (int j = 0; j < n - k; j++) {
      sum += y[j];
    }

    cout << sum << endl;
  }

  return 0;
}




Measured memory_bytes: 3664
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, _ := nextInt2()
	a := nextInts(n)

	// min[i]: i以前の街で最小のりんごの値段
	// max[i]: i以後の街で最高のりんごの値段
	// max-minの最大値を与えるmax,minが発生した地点で売買することとなる
	min, max := make([]int, n), make([]int, n)
	min[0], max[n-1] = a[0], a[n-1]
	for i := 1; i < n; i++ {
		min[i], max[n-1-i] = min[i-1], max[n-i]
		if a[i] < min[i] {
			min[i] = a[i]
		}
		if a[n-1-i] > max[n-1-i] {
			max[n-1-i] = a[n-1-i]
		}
	}
	profit := make([]int, n)
	for i := 0; i < n; i++ {
		profit[i] = max[i] - a[i]
	}
	// puts(min)
	// puts(max)
	// puts(profit)

	m := map[int]int{}
	maxProfit := -1
	for _, p := range profit {
		m[p]++
		if p > maxProfit {
			maxProfit = p
		}
	}

	puts(m[maxProfit])
}


Measured memory_bytes: 9088
#include <stdio.h>
int main(){
  int x,y,box;
  scanf("%d%d",&x,&y);
  if(x<y){
    box=x;
    x=y;
    y=box;
  }
  box=x%y;
  while(box!=0){
   x=y;
   y=box;
   box=x%y;
  }
  printf("%d\n",y);
  return 0;
}



Measured memory_bytes: 2732
#include<stdio.h>
int main(){
	int m,i,j,n,k,c,cc,x,max;
	while(scanf("%d %d",&n,&k),n!=0 && k!=0){
		c=0,x=0,max=0;
		int a[100002]={0};
		for(i=0;i<k;i++){
			scanf("%d",&m);
			a[m]=1;
			if(m==0)c=1;
		}
		cc=c;
		for(i=1;i<=n;i++){
			if(a[i]==1)x++;
			else if(c==1)x++,c=0,m=i+1;
			else{
				if(cc==1)c=1,i=m-1;
				if(max<x)max=x;
				x=0;
			}
		}
		if(max<x)max=x;
		printf("%d\n",max);
	}
	return 0;
}


Measured memory_bytes: 2112
// DP

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

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

ll W[110],V[110];
ll dp[110][100100] = {0};

int main() {
  ll n,w; cin >> n >> w;
  rep(i,n) cin >> W[i] >> V[i];

  rep(i,n) {
    rep(j,w+1) {
      if(j >= W[i])
      chmax( dp[i+1][j], dp[i][j-W[i]] + V[i] );
      
      chmax( dp[i+1][j], dp[i][j] );
    }
  }
  cout << dp[n][w] << endl; 
}

Measured memory_bytes: 81684
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;

    int summ = 0;
    int tmp = n;
    while(tmp>0){
        summ += tmp%10;
        tmp/=10;
    }
    if(n%summ==0)cout << "Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
const int maxn=1e5+5;
vector<int> G[maxn],path;
int fa[maxn];
int countb=1,countw=1;
int color[maxn];
int n;
void dfs(int u,int p){
    int d=G[u].size();
    for(int i=0;i<d;i++){
        int v=G[u][i];
        if(v!=p)dfs(v,fa[v]=u);
    }
}
void CalPath(){
    int k=fa[n];
    while(k!=1){
        path.push_back(k);
        k=fa[k];
    }
}
void Go(){
    if(path.size()==0)return;
    for(int i=0;path.size()-i-1>=i;i++){
        int s=path[path.size()-1-i],t=path[i];
        if(path.size()-i-1==i){
            color[s]=1;
            countb++;
            break;
        }
        color[s]=1;
        color[t]=0;
        countb++;
        countw++;
    }
}
void CheckColor(int x){
    if(color[x]!=-1)return;
    CheckColor(fa[x]);
    color[x]=color[fa[x]];
    if(color[x]==1)countb++;
    else if(color[x]==0)countw++;
}
int main(){
    cin>>n;
    memset(color,-1,sizeof(color));
    color[1]=1;
    color[n]=0;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,1);
    CalPath();
    Go();
    for(int i=2;i<n;i++){
        if(color[i]==-1)
            CheckColor(i);
    }
    if(countb>countw){
        cout<<"Fennec"<<endl;
    }
    else cout<<"Snuke"<<endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

int main() {
  cin.sync_with_stdio(false);

  int r, g, b;
  cin >> r >> g >> b;

  int n = r * 100 + g * 10 + b;

  if (n % 4 == 0) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>

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

int main() {
    int N, K;
    cin >> N >> K;
    ll h[N];
    REP(i, N) {
        cin >> h[i];
    }
    sort(h, h + N);
    cout << accumulate(h, h + (max(0, N - K)), 0L);

}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

class P1142
{
  public static void Main()
  {
    int m = Int32.Parse(Console.ReadLine());
    for(int i=0; i<m; i++)
      {
	string train = Console.ReadLine();
	HashSet<string> org = new HashSet<string>();
	org.Add(train);
	for(int j=1; j<=train.Length; j++)
	  {
	    string fore = train.Substring(0,j);
	    string after = train.Substring(j,train.Length-j);
	    char[] rf = fore.ToCharArray();
	    char[] ra = after.ToCharArray();
	    Array.Reverse(rf);
	    Array.Reverse(ra);
	    string rfore = new string(rf);
	    string rafter = new string(ra);

	    org.Add(fore+after);
	    org.Add(rfore+after);
	    org.Add(fore+rafter);
	    org.Add(after+fore);
	    org.Add(after+rfore);
	    org.Add(rafter+fore);
	    org.Add(rafter+rfore);
	    org.Add(rfore+rafter);
	  }
	
	Console.WriteLine(org.Count);
      }
  }
}

Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
long long int flagE,flagW,n,ans=10000000;
char prevchar='W',s[300001];
int main()
{
	long long int i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		if((prevchar=='E')&&(s[i]=='E')&&((flagW-flagE-1)<ans))
		ans=(flagW-flagE-1);
		if(s[i]=='W')
		flagW++;
		else
		flagE++;
		prevchar=s[i];
	}
	if(0<ans)
	cout<<flagE;
	else
	cout<<(ans+flagE)<<'\n';
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll INF=1e9+5;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    ll left=n;
    
    if(n==2)
    {
        cout<<1<<endl;
        return 0;
    }
    rep(i,n-1)
    {
        sum+=i+1;
    }
    cout<<sum;
}

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

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    if(a < b){
        cout <<  "a < b" << "\n";
    }
    else if(a > b){
        cout << "a > b" << "\n";
    }
    else{
        cout << "a == b" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	string A,B;
	int a, b,ans;
	ans = 0;
	cin >> A >> B;
	a = stoi(A);
	b = stoi(B);
	for (int i = a; i <= b; i++) {
		string I = to_string(i);
		if (I[0] == I[4] && I[1] == I[3])ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long
signed main(){
    boost;
   int n,sum=0;
   cin>>n;
   map<int,int> mp;
   for(int i=0;i<n;i++){
       int x;
       cin>>x;
       mp[x]++;
       sum+=x;
   }
   int q;
   cin>>q;
   while(q--){
       int b,c;
       cin>>b>>c;
       sum -= mp[b]*b;
       sum += mp[b]*c;
       mp[c] += mp[b];
       mp[b] = 0;
       cout<<sum<<"\n";
   }
}


Measured memory_bytes: 9552
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      int S = Integer.parseInt(sc.next());
      int W = Integer.parseInt(sc.next());
      
      String kotae = S <= W ? "unsafe" : "safe";
      System.out.println(kotae);
    }  
}


Measured memory_bytes: 35716
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
   ll limit;
   cin >> limit;
    ll nowprice = 100;
    int count = 0;
    while(nowprice < limit) {
        nowprice *= 1.01;
        count++;
    }
    cout << count << endl;

}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr int MX = 100005, MOD = 1e9+7;
int n, k, a[MX];
ll fact[MX] = {1}, invf[MX], ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n) scanf("%d", a+i);
	sort(a,a+n);
	setcomb(n);
	rep(i,n-k+1) ans -= a[i] * comb(n-i-1,k-1) % MOD;
	for(int i=n-1; i>=k-1; i--) ans += a[i] * comb(i,k-1) % MOD;
	printf("%lld\n", (ans % MOD + MOD) % MOD);
}

Measured memory_bytes: 2176
# https://atcoder.jp/contests/abc102/submissions/7991084

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

def abc102_c():
    N = int(readline())
    A = np.array(read().split(), dtype=np.int64)

    # b=0として変形する
    B = A - np.arange(1, N+1)
    # 中央値が0になるよう高さ調整する
    B.sort()
    x = B[N//2]
    # 絶対値の合計をとる
    ans = np.abs(B - x).sum()
    print(ans)

abc102_c()

Measured memory_bytes: 25072
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int[] abc = new int[3];

		for (int i = 0; i < 3; i++) {
			abc[i] = ni();
		}
		Arrays.sort(abc);

		if (abc[0] + abc[1] == abc[2]) {
			out(Y);
		} else {
			out(N);
		}
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

static const auto fast_io = [] {
 ios_base::sync_with_stdio(false); 
 cin.tie(nullptr); cout.tie(nullptr); 
 return nullptr;
}();

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

int rnd() {
 return uniform_int_distribution<int> (1, (int) 1e9) (rng);
}

template<class A> 
A rnd(A x, A y) {
 return uniform_int_distribution<A> (x, y) (rng);
}

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

template<class A, class B, class C>
string to_string(priority_queue<A, B, C> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(priority_queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(stack<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 return to_string(res);
}

template<class A>
string to_string(queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.front());
  a.pop();
 }
 return to_string(res);
}

vector<string> __vector_tuple;
template<int index, class... A>
struct print_tuple {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<index>(a)));
  print_tuple<index-1, A...>{}(a);
 }
};

template<class... A>
struct print_tuple<0, A...> {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<0>(a)));
 }
};

template<class... T>
string to_string(tuple<T...> a) {
 const int ttsz = tuple_size<decltype(a)>::value;
 print_tuple<ttsz-1, T...>{}(a);
 string __ss = to_string(__vector_tuple);
 __vector_tuple.clear();
 return __ss;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

typedef long long int ll;

int main()
{
 int x;
 cin >> x;
 int ans = 0;
 if(x >= 400 && x < 600) ans = 8;
 if(x >= 600 && x < 800) ans = 7;
 if(x >= 800 && x < 1000) ans = 6;
 if(x >= 1000 && x < 1200) ans = 5;
 if(x >= 1200 && x < 1400) ans = 4;
 if(x >= 1400 && x < 1600) ans = 3;
 if(x >= 1600 && x < 1800) ans = 2;
 if(x >= 1800 && x < 2000) ans = 1;
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

vi v,v2;
string s,t;
ll n,m;
ll ans=0;

int main(){
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='1'){
            v.pb(9);
        } else{
            v.pb(1);
        }
    }
    rep(i,v.size()){
        cout<<v[i];
    }
    cout<<""<<endl;
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n;
ll l[100005], r[100005];
ll suml[100005], sumr[100005];
void solve() {
    cin >> n;
    rep(i, n) { cin >> l[i] >> r[i]; l[i] *= 2; r[i] *= -2; }
    sort(l, l + n, greater<>());
    sort(r, r + n, greater<>());
    rep(i, n) suml[i + 1] += suml[i] + l[i];
    rep(i, n) sumr[i + 1] += sumr[i] + r[i];
    ll ans = 0;
    reps(i, n) {
        maxs(ans, suml[i] + sumr[i], suml[i - 1] + sumr[i], suml[i] + sumr[i - 1]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cout<<#x<<": "<<x<<endl;
const double PI = acos(-1.0);
using namespace std;

set<ll> vis;
void bfs()
{
    queue<ll> q;
    for(int i = 1; i < 10; i++)
        vis.insert(i), q.push(i);
    while(!q.empty())
    {
        ll x = q.front();
        q.pop();
        int last = x%10;
        vector<int> temp;
        temp.pb(last-1);
        temp.pb(last);
        temp.pb(last+1);
        // cout<<last<<": ";
        for(int i=0;i<3;i++)
        {
            if(temp[i] >=0 && temp[i] <= 9)
            {
                // cout<<c<<" ";
                x = x*10+temp[i];
                if(vis.lower_bound(x) == vis.end() && x <= 3234566667 )
                {
                    q.push(x);
                    vis.insert(x);
                }
                x = x/10;
            }
        }
        // cout<<endl;
    }

}
void cp()
{
    int k,c=0;
    cin >> k;
    bfs();
    ll ans;
    for(auto it=vis.begin(); it!=vis.end();it++)
    {
        c++;
        ans = *it;
        // cout<<*it<<" ";
        if(c==k){
            break;
        }

    }
    // cout<<endl;
    cout<<ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin>>t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1000000007
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    int h,w;
    cin>>h>>w;
	char s[h+1][w+1];
	rep(i,1,h+1){
		rep(j,1,w+1)
			cin>>s[i][j];
	}
	int dp[h+1][w+1]={0};
	dp[1][1]=1;
	rep(i,0,h+1){
		rep(j,0,w+1){
			if(i!=1||j!=1){
				if(s[i-1][j]=='.'){
					dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				}
				if(s[i][j-1]=='.'){
					dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
				}
			}
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 5120
#include <stdio.h>

int main()
{
	char A, B, C;
	scanf("%c%c%c", &A, &B, &C);
	
	if(A==B && B!=C || A==C && C!=B || B==C && C!=A)
 {	
	    puts("Yes");
 }
    else {
	    puts("No");
 }
    return 0;
 }

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

typedef long long int int64;

int cmp(const void *a,const void *b){
  int64 p=*(int64 *)a;
  int64 q=*(int64 *)b;
  return p==q?0:p-q<0?-1:1;
}

void run(void){
  int n,p;
  scanf("%d%d",&n,&p);
  int64 *d=(int64 *)calloc(n,sizeof(int64));
  int64 sumW=0;
  int64 sum=0;
  int i;
  for(i=0;i<n;i++){
    int64 w,b;
    scanf("%lld%lld",&w,&b);
    sumW+=(100-p)*w;
    d[i]=(100-p)*w+p*b;
    sum+=d[i];
  }
  qsort(d,n,sizeof(int64),cmp);
  int k=0;
  while(sum>sumW){
    sum-=d[n-1-k++];
  }
  printf("%d\n",k);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1788
/* 
 * Project: AtCoder Beginners Contest 175 A - Rainy Season
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

int main() {

    int_fast8_t c;
    uint_fast32_t cnt = 0;
    uint_fast32_t max_cnt = 0;
    for (int i=0;i<3;i++) {
        scanf("%c", &c);
        if (c == 'R') {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt > max_cnt)
            max_cnt = cnt;
    }
    printf("%lu\n", max_cnt);

}

Measured memory_bytes: 3164
#include<iostream>
#include<deque>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main() {
	deque<int>d(3);
	for (int i = 0; i < 3; i++)
		cin >> d[i];
	sort(d.begin(), d.end());

	int sum = d[1] - d[0];
	sum += (d[2] - d[1]);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n, i, a[100];
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=n-1; i>=0; i--){
        printf("%d", a[i]);
        if(i!=0){
            printf(" ");
        }
    }
    printf("\n");
     
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    vector<int> arr(4);
    for (int i = 0; i < 4; i++) {
        arr.at(i) = (int) S.at(i) - '0';
    }

    bitset<3> b;
    string formular;
    int ans;
    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        b = tmp;
        ans = arr.at(0);
        formular = S.substr(0, 1);
        for (int i = 2; i >= 0; i--) {
            if (b.test(i)) {
                ans += arr.at(3 - i);
                formular = formular + "+" + S.substr(3 - i, 1);
            } else {
                ans -= arr.at(3 - i);
                formular = formular + "-" + S.substr(3 - i, 1);
            }
        }
        if (ans == 7) {
            cout << formular + "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3600
#include <map>
#include <set>
#include <cmath>
#include <ctime> 
#include <queue>
#include <stack>
#include <bitset> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 1e3 + 7;

int n, a[MAXN];

int main() {
    scanf("%d", &n);
    bool f = 1;
    rep(i, 1, n) scanf("%d", &a[i]);
    rep(i, 1, n) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 && a[i] % 5) f = 0;
        }
    }
    puts(f ? "APPROVED" : "DENIED");
    return 0;
}

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n;cin>>n;
  priority_queue<ll> a;
  for (int i=0; i<n*3; i++) {
    ll t;cin>>t;
    a.push(t);
  }
  ll ans=0;
  for (int i=0; i<n; i++) {
    a.pop();
    ans+=a.top();
    a.pop();
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

ll gcd(int x,int y){
    if(x%y == 0) return y;
    return gcd(y,x%y);
}

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*b/gcd(a,b);

}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

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

int main() {
    int x;cin >> x;
    ll now = x;
    ll ans = 1;
    while(now % 360 != 0) {
        now += x;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007

using namespace std;
void run(){
	ll n,k;
	cin>>n>>k;
	cout<<n-k+1;
	
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;


void testcase() {
	int x, n; cin >> x >> n;
	int min = 10000;
	vector<int> v(101,1);
	for (int i = 0; i < n; i++) {
		int f; cin >> f;
		v[f] = 0;
	}
	for (int i = 0; i < 100; i++) {

		if ((x - i >= 0 && v[x - i] == 1) || x - i < 0) {
			cout << x - i;
			return;
		}
		else if (x + i < 101 && v[x + i] == 1 || x + i > 100) {
			cout << x + i;
			return;
		}
	}
	

	
}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll H, W;
  cin >> H >> W;
  if(H != 1 && W != 1) cout << (H * W + 1) / 2 << endl;
  else cout <<  1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
signed main(){
  string s;
  cin >> s;
  int zero = 0;
  int one = 0;
  rep(i,s.size()){
    if(s[i] == '0') zero++;
    else one++;
  }
  cout << min(zero,one)*2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>


using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
 	string s, t, b;
	int ans = 0, ans2 = 0;
	
	cin>>s;
	
	
	if(s.size() == 1){
		cout<<1<<endl;
		return 0;
	}
	
	
	for(int i = 0; i < s.size(); i++){
		t += s[i];
		// cout<<t<<" b = "<<b<<endl;
		if(t == b){
			
		} else {
			
			b = t;
			t.clear();
			ans++;
		}
	}
	
	// if(t.size())ans--;
	
	
	
	t.clear();
	b.clear();
	b = s[0];
	b += s[1];
	ans2 = 1;
	
	for(int i = 2; i < s.size(); i++){
		t += s[i];
		
		// cout<<i<<" <> "<<t<<" b = "<<b<<endl;
		if(t == b){
			
		} else {
			
			b = t;
			t.clear();
			ans2++;
		}
	}
	
	// if(t.size())ans2--;
	
	cout<<max(ans,ans2)<<endl;
	
	return 0;
}
/*

*/

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, k;
  cin >> n >> k;
  vector<LL> x(n), y(n);
  vector<LL> nx(n), ny(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    nx[i] = x[i];
    ny[i] = y[i];
  }

  sort(all(nx));
  sort(all(ny));

  LL ans = (nx.back() - nx.front()) * (ny.back() - ny.front());
  for (int xi = 0; xi < n; xi ++) {
    for (int xj = xi + 1; xj < n; xj ++) {
      for (int yi = 0; yi < n; yi ++) {
        for (int yj = yi + 1; yj < n; yj ++) {
          int num = 0;
          LL left = nx[xi], right = nx[xj];
          LL down = ny[yi], up = ny[yj];
          rep(i, n) {
            if (nx[xi] <= x[i] && x[i] <= nx[xj] && ny[yi] <= y[i] && y[i] <= ny[yj]) num ++;
          }
          if (k <= num) {
            ans = min(ans, (right - left) * (up - down));
          }
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b)cout<<"delicious"<<endl;
    else if(a+x>=b)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;

    return 0;
}



Measured memory_bytes: 3624
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())
ips=lambda:input().split()

"""========main code==============="""
a,b=ml()
n=ll()
n.sort()
print(sum(n[:b]))

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string s; cin>>s;
  int l = (int)(s.length());
  int m = 0;
  for (int i=0; i<l; i++) {
    if (s[i]=='o') m++;
  }
  if ((15-l)+m >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "";
		result = s.charAt(0) + String.valueOf(s.length() -2) + s.charAt(s.length() -1);
		
		// 出力
		System.out.println(result);
	}
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  cout << (int)pow(k-1,n-1)*k << endl;
}



Measured memory_bytes: 4052
N = int(input())
A = list(map(int,input().split()))
ans = 1
if(0 in A):
  print("0")
  exit()
for i in range(N):
  tmp = A[i]
  ans = ans * tmp
  if(ans > 10**18):
    print("-1")
    exit()
print(str(ans))

Measured memory_bytes: 21708
#include <stdio.h>

int main(void) {
  int ans = 0, i, n, x, min = 1000000, m;
  scanf("%d%d", &n, &x);
  for(i = 0; i < n; ++i) {
    scanf("%d", &m);
    ans += m;
    if(min > m) min = m;
  }
  printf("%d", n + (x - ans) / min);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, long long S){
  vector<ll> v(N);
  for(ll i=0; i<K; i++) {
    v[i] = S;
  }
  for(ll i=K; i<N; i++) {
    if(S==1000000000)
      v[i] = S-1;
    else
      v[i] = S+1;
  }
  for(ll i=0; i<N; i++) {
    if(i+1<N)
      std::cout << v[i] <<" ";
    else
      std::cout << v[i];
  }
  std::cout  << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  long long S;
  scanf("%lld",&S);
  solve(N, K, S);
  return 0;
}



Measured memory_bytes: 2048
#pragma GCC optimize ("O3")

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

int n,y;

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n>>y;
    for(int i=0;i<=y/10000;++i)
        for(int j=0;j<=y/5000;++j){
            int t=n-i-j;
            if(t>=0&&t*1000+j*5000+i*10000==y){
                cout<<i<<' '<<j<<' '<<t;
                return 0;
            }
        }
    cout<<"-1 -1 -1";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll K;
    cin >> K;
    ll a = K / 50;
    ll b = K % 50;
    bool f = false;
    cout << 50 << endl;
    for(int i=0;i<51;i++){
        if(i == 50-b) continue;
        if(f) cout << " ";
        cout << a + i;
        f = true;
    }
    cout << endl;   
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(5);}} __init;
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; }
int main(){
    int n;
    cin>>n;
    V<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    sort(all(a));sort(all(b));sort(all(c));
    ll l=0,r=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        while(l<n&&a[l]<b[i])l++;
        while(r<n&&c[r]<=b[i])r++;
        ans+=l*(n-r);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
		
	static List<ArrayList<int[]>> to;
	static int x, y;
	static long memo[];
	
	public static void main(String[] args) {
		
		//入力値の受け取り
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		//連結リスト
		to = new ArrayList();
		for(int i=0;i<N;i++) {
			to.add(new ArrayList<int[]>());
		}
		
		for(int i=0;i<N-1;i++) {
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
			a--;b--;
			int t[] = {b,c};
			to.get(a).add(t);
			int u[] = {a,c};
			to.get(b).add(u);
		}
		int Q = sc.nextInt(), K = sc.nextInt();
		K--;
		
		//問題
		int q[][] = new int[Q][2];
		for(int i=0;i<Q;i++) {
			int x = sc.nextInt(), y = sc.nextInt();
			x--;y--;
			q[i][0]=x; q[i][1]=y;
		}
		sc.close();
		
		memo = new long[N];//Kからの距離をメモする配列
		memo[K]=0;
		dfs(K, -1, 0L);
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<Q;i++) {
			int x = q[i][0];  int y = q[i][1];
			long ans = memo[x]+memo[y];
			sb.append(ans+"\n");
		}	
		System.out.println(sb.toString());
	}
	
	static void dfs(int a, int p, long len) {
		for(int t[] : to.get(a)) {
			int na = t[0];
			int d = t[1];
			if(na == p)continue;
			memo[na]=len+d;
			dfs(na , a, len+d);
		}
	}
	
}

Measured memory_bytes: 190160
s = input()
 
s = s[::-1]
 
dp = [[0 for _ in range(13)] for __ in range(len(s)+1)]
 
l = len(s)
 
 
if s[0] == '?':
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(s[0])] = 1
 
m = 1
MOD = 10**9 +7
 
for i in range(1,len(s)):
    m = m*10 % 13
 
    if s[i] == '?':
        for k in range(13):
            for j in range(10):
                dp[i][(j*m+k)%13] += dp[i-1][k]
                dp[i][k] %= MOD
    else:
        for k in range(13):
            dp[i][(int(s[i])*m + k) %13] += dp[i-1][k]
            dp[i][k] %= MOD
 
print(dp[len(s)-1][5] % MOD )

Measured memory_bytes: 66012