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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int M, N;
	static boolean[][] f;
	static int ans;
	static int[] DR = { 1, 0, -1, 0 };
	static int[] DC = { 0, 1, 0, -1 };

	static void dfs(int r, int c, int d) {
		f[r][c] = false;
		for (int i = 0; i < 4; ++i) {
			int nr = r + DR[i];
			int nc = c + DC[i];
			if (nr < 0 || N <= nr || nc < 0 || M <= nc || !f[nr][nc]) continue;
			dfs(nr, nc, d + 1);
		}
		f[r][c] = true;
		ans = Math.max(ans, d);
	}

	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt();
			N = sc.nextInt();
			if (N == 0) break;
			f = new boolean[N][M];
			ans = 0;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					f[i][j] = sc.next().equals("1");
				}
			}
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					if (f[i][j]) dfs(i, j, 1);
				}
			}
			System.out.println(ans);
		}
	}
}

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

int main() {
  int k,sum;
  cin>>k>>sum;
  
  int tori=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(sum-i-j>=0 && sum-i-j<=min(k,sum))
        tori+=1;
    }
  }
    
    cout <<tori<<endl;
}

Measured memory_bytes: 256
while 1:
  try:
    s=list(map(float,input().split()))
    up=s[4]/s[1]
    a=s[0]*up
    b=s[1]*up
    c=s[2]*up
    d=s[3]
    e=s[4]
    f=s[5]
  
    ad=a-d
    cf=c-f
    x=round(cf/ad,3)
    if x==-0.000:
      x=0.00
    y=round((s[2] - s[0]*x)/s[1],3)
    if y==-0.000:
      y=0.000
    print('{:.3f}'.format(x),'{:.3f}'.format(y))

  except EOFError:
    break


Measured memory_bytes: 5592
n, m = map(int, input().split())
np = list()
for _ in range(n):
    np.append(list(map(int, input().split())))
mp = list()
for _ in range(m):
    mp.append(list(map(int, input().split())))

for N in np:
    tmp = list()
    for M in mp:
        tmp.append([abs(N[0]-M[0])+abs(N[1]-M[1]), mp.index(M)+1])

    tmp.sort()
    print(tmp[0][1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;

typedef pair<int,int> pii;
const int maxn = 5e5 + 10;
string answer;
int n;
int curstate[maxn];
int check(int first,int second){
    curstate[0] = first,curstate[1] = second;
    int cstate;
    for (int i = 1;i < n - 1;i++){
        cstate = curstate[i] ^ answer[i];
        curstate[i + 1] = curstate[i - 1] ^ cstate;
    }
    for (int i = 0;i < n;i++){
        int l = (i - 1 + n) % n,r = (i + 1) % n;
        if (answer[i] ^ curstate[i] ^ curstate[l] ^ curstate[r] ) return 0;
    }
    for (int i = 0;i < n;i++){
        if (curstate[i] == 0) cout << 'S';
        else cout << 'W';
    }
    cout << endl;

    return 1;
}
int32_t main(){
    cin >> n >> answer;
    for (int i =0;i < n;i++){
        if (answer[i] == 'o') answer[i] = 0;
        else answer[i] = 1;
    }
    if (check(0,0)) return 0;
    else if (check(0,1)) return 0;
    else if (check(1,0)) return 0;
    else if (check(1,1)) return 0;
    else cout << -1 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n;

int main() {
	cin >> n;
	
	LL ans = n - 1;
	inc1(i, n) {
		if(i > n / i) { break; }
		if(n % i == 0) { setmin(ans, i + n / i - 2); }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> f(n, 0);
    REP(i, n){
        ll ai;
        cin >> ai;
        f.at(--ai)++;
    }
    sort(f.begin(), f.end());

    vector<ll> cs(n, 0);
    cs.at(0) = f.at(0);
    for(ll i = 1; i < n; ++i){
        cs.at(i) = cs.at(i - 1) + f.at(i);
    }

    ll x = n, idx = n;
    for(ll k = 1; k <= n; ++k){
        while(1){
            while(idx > 0 && f.at(idx - 1) >= x){ idx--; }
            ll sum = x * (f.size() - idx);
            if(idx > 0){
                sum += cs.at(idx - 1);
            }
            if(sum >= k * x){
                break;
            }else{
                x--;
            }
        }
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 5504
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
tmp = 0
a.sort()
b.sort()
c.sort()
for i in range(n):
    tmp = bisect.bisect_left(a,b[i])
    tmp2 = n - bisect.bisect_left(c,b[i]+1)
    ans += tmp*tmp2
print(ans)

Measured memory_bytes: 23232
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>

using namespace std;

int main(){
		int n,num,cont,v;
		string a,nex;
	while(1){
		
		cin>>n;
		
		if(n==0){break;}
		
		cin>>a;
		
		for(int i=0;i<n;i++){
			cont=0;
			while(1){
				if(cont>=a.size()){break;}
				
				num=a[cont];
				
				v=0;
				while(1){
					if(a[cont]!=num){break;}
					v++;
					cont++;
				}
				
				stringstream ss;
				ss<<v;
				
				nex+=ss.str();
				nex+=num;
			}
			a=nex;
			nex="";
		}
			cout<<a<<endl;
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++) {
        if ((a * b * i) % 2 != 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
	int N, i, sum = 0, absum = 0;
	scanf("%d", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		sum += A[i];
		absum += abs(A[i]);
	}
	sort(A.begin(), A.end());
	for(i = 0; A[i] < 0; i++);
	int t = i;
	if(t == N){
		printf("%d\n", -sum + 2 * A[N - 1]);
		for(i = 0; i < N - 1; i++){
			printf("%d %d\n", A[N - 1], A[i]);
			A[N - 1] -= A[i];
		}
	}
	else if(t == 0){
		printf("%d\n", sum - 2 * A[0]);
		for(i = 1; i < N - 1; i++){
			printf("%d %d\n", A[0], A[i]);
			A[0] -= A[i];
		}
		printf("%d %d\n", A[N - 1], A[0]);
		A[N - 1] -= A[0];
	}
	else{
		printf("%d\n", absum);
		for(i = 1; i < t; i++){
			printf("%d %d\n", A[N - 1], A[i]);
			A[N - 1] -= A[i];
		}
		for(i = t; i < N - 1; i++){
			printf("%d %d\n", A[0], A[i]);
			A[0] -= A[i];
		}
		printf("%d %d\n", A[N - 1], A[0]);
		A[N - 1] -= A[0];
	}
	return 0;
}

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

int main(){
    
    string W;

     cin>>W;
     if(W=="RRR"){
cout<<3<<endl;
     }
     if(W=="RRS"){
cout<<2<<endl;
     } 
     if(W=="RSR"){
cout<<1<<endl;
     }
    if(W=="RSS"){
cout<<1<<endl;
     }
    if(W=="SRR"){
cout<<2<<endl;
     }
     if(W=="SRS"){
cout<<1<<endl;
     }
      if(W=="SSR"){
cout<<1<<endl;
     }
      if(W=="SSS"){
cout<<0<<endl;
     }
   
   
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N,M;
    cin >> N >> M;
    
    vector<int> a(M);
    vector<int> b(M);
    vector<vector<int> > points(N,vector<int>());
    rep(i,M)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        points[a[i]].push_back(b[i]);
        points[b[i]].push_back(a[i]);
    }

    vector<int> dist(N,-1);
    vector<int> ans(N,-1);
    queue<int> que;
    int key = 0;

    que.push(0);

    while(!que.empty())
    {
        int p = que.front();
        que.pop();
        
        rep(i, points[p].size())
        {
            if( dist[points[p][i]] == -1 )
            {
                dist[points[p][i]] = dist[p]+1;
                ans[points[p][i]] = p+1;
                que.push(points[p][i]);
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, 1, N) cout << ans[i] << endl;
}


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

int main(){
   string s;
   cin >> s;
   if(s[0]=='9'||s[1]=='9'){
      cout << "Yes";
   }else{
      cout << "No";
   }

   return 0;
}

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

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

int main()
{
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans;
    for (int i = 0; i < n; i++) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//chebyshev's  theorem


#include <stdio.h>

#define maxprime  123456*2
 
 
int prime[maxprime + 1];
 
void make_prime(void)  //?´???°????±?????????¢??° 
{
    int i;
    int j;
    int n;
    int c;
     
    for (i = 2; i * i <= maxprime; i++){
        if (prime[i] == 0){
            for (j = i * 2; j <= maxprime; j += i){
                prime[j] = 1;
            }
        }
    }
}
     
 
 
int main(void)
{
    int n;
    int i;
    int count;
     
    make_prime();
 
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
         
        count = 0;
        for (i = n + 1; i <= n * 2; i++){
            if (prime[i] == 0){
                count++;
            }
        }
        printf("%d\n", count);
    }
     
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int n1, n2, n3;
  n1 = n / 100;
  n2 = (n - (n1 * 100)) / 10;
  n3 = n - (n1 * 100) - (n2 * 10);

  if (n1 == n3) cout << "Yes";
  else cout << "No";
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  if(S[0]==S[1]&&S[1]==S[2]){
    cout<<"Yes"<<endl;
  }
  else if(S[1]==S[2]&&S[2]==S[3]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
void solve(){
	int s;
	cin>>s;
	s%=10;
	if(s==3)
		cout<<"bon";
	else if(s==0 || s==1 || s==6 || s==8)
		cout<<"pon";
	else cout<<"hon";
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>

using namespace std;

bool is_square(int n) {
        long long r = (long long)floor(sqrt((long double)n));
        return (r * r) == n;
}

int counter(int n) {
        int count = 0;
        int x_range = ceil(sqrt((long double)n));
        for (int x = 1; x <= x_range; x++) {
                int y_range = ceil(sqrt((long double) n - x*x));
                for (int y = 1; y <= y_range; y++) {
                        int tmp = 4*n - 3*x*x - 2*x*y - 3*y*y;
                        if (is_square(tmp)) {
                                tmp = sqrt(tmp) - x - y;
                                if (tmp % 2 ==0 && tmp > 0) {
                                        count++;
                                }
                        }

//                      for (int z = 1; z <= n - x*x - y*y - x*y; z++) {
//                              int f = x * x + y * y + z * z + x * y + y * z + z * x;
//                              if (f == n)
//                                      count++;
//                      }
                }
        }
        return count;
}

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

        for (int i=1; i<=n; i++) {
                cout << counter(i) << endl;
        }

        return 0;
}

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

using namespace std;

#define int long long

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

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int H, W;

char s[51][51];

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

	cin>>H>>W;
	rep(i, H)cin>>s[i];

	rep(i, H) {
		rep(j, W) {
			if(s[i][j]=='#')continue;
			s[i][j] = '0';
			rep(k, 3) {
				rep(l, 3) {
					int u = i+k-1, v=j+l-1;
					if(k==1&&l==1)continue;
					if(u<0 || H<=u)continue;
					if(v<0 || W<=v)continue;

					if(s[u][v]=='#')s[i][j]++;

				}
			}
		}
	}

	rep(i, H)cout<<s[i]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
long long sousa(long long a,long long b)
{
	if(min(a,b)!=0)return 0;
	else if(max(a,b)==1)return 2;
	else return 1;
}
long long pat(long long m,long long n)
{
	long long g,k,pg,pk,a[10]={0},mm=m;
	if(m%2==1)k=pk=0,g=pg=1;
	else k=pk=1,g=pg=0;
	for(;;)
	{
		if(m<8)
		{
			for(long long i=m;i>=n;i--)
			{
				if(m==mm&&i==m)a[i]=0;
				else if(i==m)a[i]=m%2?k:g;
				else if(i*2<=mm&&i*2<=m)a[i]=sousa(a[i*2],a[i+1]);
				else if(i*2<=mm)a[i]=sousa(pg,a[i+1]);
				else if(a[i+1]==0)a[i]=1;
				else a[i]=0;
			}
			return a[n];
		}
		else if((m>>1)<n)
		{
			if(n%2==1)return k;
			else return g;
		}
		else
		{
			pg=g;
			pk=k;
			m=(m>>1);
			if(m%2==1)
			{
				k=sousa(pg,pg);
				g=sousa(pg,k);
			}
			else
			{
				g=sousa(pg,pk);
				k=sousa(pg,g);
			}
		}
	}
}

int main()
{
	long long k,n,m,f=0;
	cin>>k;
	for(long long i=0;i<k;i++)
	{
		cin>>n>>m;
		f^=pat(m,n);
	}
	if(f==0)cout<<"tubuann"<<endl;
	else cout<<"mo3tthi"<<endl;
	return 0;
}




Measured memory_bytes: 3120
import numpy as np
import sys
readline = sys.stdin.readline
read = sys.stdin.read

a = int(readline())
b = int(readline())
c = int(readline())
d = int(readline())
e = int(readline())

A = np.array([a, b, c, d, e])
B = A
A = (A // 10) * 10 + 10
mx = 0
s = np.sum(A)
for i in range(5):
	if A[i] - B[i] == 10:
		s -= 10
	else:
		if mx < A[i] - B[i]:
			mx = A[i] - B[i]
print(s - mx)


Measured memory_bytes: 17212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int n; cin >> n;
    int ans = 1;
    vi h(n);
    rep(i, n) {
        cin >> h[i];
    }
    REP(i, 1, n) {
        int m = 0;
        rep(j, i) {
            m = max(m, h[j]);
        }
        if(h[i] >= m) ans++;
    }
    COUT(ans);
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long LL;
constexpr int MAXN = 2e5 + 5;
using namespace std;
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while(isdigit(ch)) x = (x << 3) + (x << 1) + ch -48, ch = getchar();
    return x * f;
}
LL n, k;
vector<LL>arr;
inline bool check(LL mid) {
	LL cnt = 0;
	for (int i = 0; i < n; i++) {
		if (arr[i] < 0) 
			cnt += n - (lower_bound(arr.begin(), arr.end(), (long double )mid / arr[i]) - arr.begin());
		else if (arr[i] > 0) 
			cnt += upper_bound(arr.begin(), arr.end(), (long double )mid / arr[i]) - arr.begin();
		else if (mid >= 0) cnt += n;
		if (arr[i] * arr[i] <= mid) cnt--;
	}
	return (cnt >= k * 2);
}
int main(){
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k, arr.resize(n);
	for (int i = 0; i < n; i++) cin >> arr[i];
	sort(arr.begin(), arr.end());
	LL l = -1e18, r = 1e18, ans;
	while (l <= r) {
		LL mid = (l + r) >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], k = tmp[1], s = tmp[2];

    long t;
    if (n - k)
    {
        if (s == 10L ^^ 9) t = 1;
        else t = 10L ^^ 9;
    }
    foreach (i; 0 .. n)
    {
        if (i < k) s.write;
        else t.write;

        if (i == n - 1) writeln;
        else " ".write;
    }
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define pb push_back
#include <string> 
using namespace std;
const int N = 1000000;
int n, a[N];

void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		int l = 2 * i + 1, r = 2 * i + 2, pa = (i - 1) / 2;
		string s = "node " + to_string(i + 1) + ": ";
		s += "key = " + to_string(a[i]) + ", ";
		if(pa >= 0 && pa != i){
			s += "parent key = " + to_string(a[pa]) + ", ";
		}
		if(l < n){
			s += "left key = " + to_string(a[l]) + ", ";
		}
		if(r < n){
			s += "right key = " + to_string(a[r]) + ", ";
		}
		cout << s << endl;
	}
}
int main(void){
	solve();
	return 0;
}



Measured memory_bytes: 3276
#include "bits/stdc++.h"

using namespace std;

const int MAX = 1000000000;

void Main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }

    auto at0 = lower_bound(x.begin(), x.end(), 0);
    vector<int> pos(at0, x.end());
    vector<int> neg;
    if (abs(distance(x.begin(), at0)) > 0) {
        neg = vector<int>(x.begin(), at0);
    }
    sort(neg.begin(), neg.end(), greater<int>());

    int ans = MAX;
    for (int i = 0; i <= K; ++i) {
        // i : num of taking right
        // K - i : num of taking left
        if (pos.size() < i || neg.size() < K - i) {
            continue;
        }
        int posLen = (i > 0) ? pos[i - 1] : 0;
        int negLen = (K - i > 0) ? neg[K - i - 1] : 0;
        negLen *= -1;
        int length = min(2 * posLen + negLen, posLen + 2 * negLen);
        ans = min(ans, length);
    }

    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4036
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  string ans="No";
  for (int i=0; i<=N; i++){
    for (int j=0; j<=N; j++){
      int total=i*4 + j*7;
      if (total==N) ans="Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl

while (<>) {
    ($a, $b) = split /\s/, $_;
}

$win = 'Draw';
if ($a > $b) {
    $win = 'Alice';
    if ($b == 1) {
        $win = 'Bob';
    }
} elsif ($b > $a) {
    $win = 'Bob';
    if ($a == 1) {
        $win = 'Alice';
    }
}
print "$win\n";


Measured memory_bytes: 512
#include <stdio.h>

int tail[1000];
int cnt;
int nxt[501010];
int val[501010];

int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)tail[i]=i,nxt[i]=-1;
    cnt=n;
    while(q--){
        int t;
        scanf("%d",&t);
        if(t==0){
            int k,x;
            scanf("%d%d",&k,&x);
            nxt[cnt]=-1;
            val[cnt]=x;
            nxt[tail[k]]=cnt;
            tail[k]=cnt;
            cnt++;
        }else if(t==1){
            int k;
            scanf("%d",&k);
            k=nxt[k];
            if(k==-1)puts("");
            else{
                while(k!=-1){
                    printf("%d%c",val[k],nxt[k]==-1?10:32);
                    k=nxt[k];
                }
            }
        }else{
            int k;
            scanf("%d",&k);
            tail[k]=k;
            nxt[k]=-1;
        }
    }
}


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
string a;
multiset <string> se;
int main()
{
//	cin >> a;
//	for(int i=0;i<a.length();i++)
//		se.insert(a.substr(i,1));
	int x,y,z;
	cin >> x >> y >> z;
	for(int i=1;i<=x;i++)
		se.insert("a");
	for(int i=1;i<=y;i++)
		se.insert("b");
	for(int i=1;i<=z;i++)
		se.insert("c");
	while(se.size()>1)
	{
		string tem=*se.begin()+*--se.end();
		se.erase(se.begin());
		se.erase(--se.end());
		se.insert(tem);
	}
	cout << *se.begin() << endl;
    return 0;
}


Measured memory_bytes: 256
#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;



int main(){

	ll H,W;
	scanf("%lld %lld",&H,&W);

	if(H%3 == 0 || W%3 == 0){

		printf("0\n");
		return 0;
	}

	ll ans = min(H,W); //縦に3つor横に3つ

	for(int right = 0; right <= W-2; right++){
		ll base = H*(right+1);

		ll A = (W-(right+1))*(H/2);
		ll B = (W-(right+1))*(H/2);
		if(H%2 == 1){

			B += (W-(right+1));
		}
		ll tmp = max(base,B)-min(base,A);
		ans = min(ans,tmp);
	}

	for(int under = 0; under <= H-2; under++){

		ll base = W*(under+1);

		ll A = (H-(under+1))*(W/2);
		ll B = (H-(under+1))*(W/2);

		if(W%2 == 1){

			B += (H-(under+1));
		}
		ll tmp = max(base,B)-min(base,A);
		ans = min(ans,tmp);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3792
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int a,b,sum;
	scanf("%d %d",&a,&b);
	sum=(a+b)/2;
	if((a+b)%2 != 0)
		sum=sum+1;
	printf("%d\n",sum);
	return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    ll n;
    cin >> n;
    std::cout << n * (n-1) / 2 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main(){
    vector<int> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    if ( ((abc[0]&1) == (abc[1]&1)) && ((abc[1]&1) == (abc[2]&1)) ) {
        cout << ( abc[2] - abc[1] ) / 2 + ( abc[2] - abc[0] ) / 2 << endl;
    }
    else if ( ((abc[0]&1) == (abc[1]&1)) && ((abc[1]&1) != (abc[2]&1)) ) {
        cout << ( abc[1] - abc[0] ) / 2 + ( abc[2] - abc[1] ) << endl; 
    }
    else if ( ((abc[0]&1) != (abc[1]&1)) && ((abc[1]&1) == (abc[2]&1)) ) {
        cout << ( abc[2] - abc[1] ) / 2 + ( abc[2] - abc[0] + 1 ) / 2 + 1 << endl;
    }
    else if ( ((abc[0]&1) == (abc[2]&1)) && ((abc[1]&1) != (abc[2]&1)) ) {
        cout << ( abc[2] - abc[0] ) / 2 + ( abc[2] - abc[1] + 1 ) / 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fin << '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep( i, m, n ) for ( int i = m; i < n; ++i )
typedef long long ll;
typedef vector<int> vi;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n, l; cin >> n >> l;

  int tas;
  int sumtas = 0;
  int minv = INF;
  int tmp;
  for ( int i = 1; i <= n; ++i ) {

    tas = l + i - 1;

    minv = min( minv, abs( tas ) );

    if( tas < 0 ) tmp = -minv;
    else tmp = minv;

    sumtas += tas;

  }

  cout << sumtas - tmp fin;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	cout<<min(a,min(b,c)) + min(d,e) - 50 << endl;
	return 0;
}

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

int main(){
	vector<int> abcd(4);
	for(int i = 0; i < 4; i++)
	{
		char j;
		cin >> j;
		abcd[i] = j - '0';
	}

	for(int bit = 0; bit < (1 << 3); bit++)
	{	
		int num = abcd[0];
		for(int i = 0; i < 3; i++)
		{	
			//puls
			if(bit & (1<<i)) num += abcd[i+1];
			
			//minus
			else num -= abcd[i+1];
		}
		if(num == 7){
			cout << abcd[0];
			for(int i = 0; i < 3; i++)
			{
				if(bit&(1<<i)) cout << '+' << abcd[i+1];
				else cout << '-' << abcd[i+1];
			}
			cout << "=7"<< endl;
			break;
		}
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;

const int MN = 500500;

int n;
ll d[MN][2];
ll dps[MN], num[MN], dist[MN];

// ll num(int i) {
//     if (i == -1) return 1;
//     return num(d[i][0]) + num(d[i][1]);
// }

// ll dist(int i) {
//     if (i == -1) return 0;
//     return dist(d[i][0]) + num(d[i][0]) + dist(d[i][1]) + num(d[i][1]);
// }


ll dfs(int i) {
    if (i == n-1) return 0;
    ll res = dist[i];
    res = min(res, dist[d[i][0]] + num[d[i][0]] + 1 + dfs(d[i][1]));
    res = min(res, 1 + dfs(d[i][0]) + dist[d[i][1]] + num[d[i][1]]);
    res = min(res, 1 + dfs(d[i][0]) + dps[i] + 1 + dfs(d[i][1]));
    return res;
}


void main2() {
    scanf("%d", &n);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        scanf("%d %d", &a, &b); a--; b--;
        d[i][0] = a; d[i][1] = b;
    }
//    init(0, 0);
    dps[0] = 0;
    for (int i = 0; i < n-1; i++) {
        dps[d[i][0]] = dps[d[i][1]] = dps[i]+1;
    }
    num[n-1] = 1;
    dist[n-1] = 0;
    for (int i = n-2; i >= 0; i--) {
        num[i] = num[d[i][0]] + num[d[i][1]];
        dist[i] = num[i] + dist[d[i][0]] + dist[d[i][1]];
    }
//    for (int i = 0; i < n-1; i++) {
//        printf("dps:%lld num:%lld dist:%lld dfs:%lld\n", dps[i], num[i], dist[i], dfs(i));
//    }
    printf("%lld\n", dfs(0));
}

ll eord, enew;
int main() {
    const int SZ = 120*1024*1024;
    void *p = malloc(SZ);
    enew = (long long)p + SZ - 1;

    __asm__("mov %rsp, eord");
    __asm__("mov enew, %rsp");

    main2();

    __asm__("mov eord, %rsp");
}

Measured memory_bytes: 52468
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[3];
		for(int i = 0;i < 3;i++) {
			num[i] = sc.nextInt();
		}
		int cost = 0;
		Arrays.sort(num);
		cost = num[1] - num[0];
		cost = num[2] - num[1] + cost;
		System.out.println(cost);
	}
}


Measured memory_bytes: 21972
#include <cstdio>
#include <utility>
#include <vector>
#include <iostream>
#include <cassert>

using namespace std;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int tot = (n - 1) * (n - 2) / 2;
  if (m > tot) {
    puts("-1");
    return 0;
  }
  vector<pair<int, int>> ans;
  for (int i = 1; i < n; ++i) {
    ans.emplace_back(0, i);
  }
  for (int i = 1; i < n && tot > m; ++i) {
    for (int j = i + 1; j < n && tot > m; ++j) {
      ans.emplace_back(i, j);
      --tot;
    }
  }
  assert(tot == m);
  printf("%d\n", (int)ans.size());
  for (auto &e : ans) {
    printf("%d %d\n", e.first + 1, e.second + 1);
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int a = sc.nextInt();
		
		System.out.println((h+ a - 1)/a);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
using namespace std;

long long int wa(string s, int l, int r){
    long long int ans = 0;
    for(int i = l; i <= r; i++){
        ans = ans *10 + (s[i] - '0');
    }
    return ans;
}

int main(void){
    string s;
    long long int ans = 0;
    cin >> s;
    int pls = s.length();

    for (int bit = 0; bit < (1<<(pls - 1)); ++bit) {
        int left = 0, right = 0;
        for(int i=0; i < pls + 1; i++){
            if(bit & (1<<i)){
                ans += wa(s, left, i);
                left = i + 1;
            }
        }
        ans += wa(s, left, pls - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	else:
		word = word.replace('?', "D", 1)
	start = i + 1
print(word)

Measured memory_bytes: 9188
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = long.Parse(Console.ReadLine());
		var ans = "";
		while (n > 0)
		{
			--n;
			ans += (char)(97 + n % 26);
			n /= 26;
		}
		Console.WriteLine(new string(ans.Reverse().ToArray()));
	}
}

Measured memory_bytes: 28196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N= scanner.nextInt();
			int A = scanner.nextInt();

			System.out.println((N % 500) - A <= 0 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 22612
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,h[101],garden[101],l,r,ret;

signed main(){
    I(n);
    REP(i,n) I(h[i]);
    l = -1;
    REP(i,101){ 
        REP(j,n){
            if (h[j] > i) {
                l = j;
            } else if (l >= 0){
                l = -1;
                ret++;
            }
        }
        ret += (l != -1);
        l = -1;
    }
    cout << ret << 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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  string ans = "Yes";
  int t = 0, x = 0, y = 0;
  bool flag = 0;
  rep(i, n) {
    int c, a, b; cin >> c >> a >> b;
    int d = abs(x-a)+abs(y^b);
    if((c-t)%2) {
      if(d % 2 == 0 || c-t < d) {
	flag = 1;
      }
    } else {
      if(d % 2 || c-t < d) {
	flag = 1;
      }
    }
    if(flag) {
      ans = "No";
      break;
    }
  }
  cout << ans;
}


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

int main()
{
    int n,a,b;
    cin>>n>>a>>b;

    int dif = max(a,b) - min(a,b);

    if(dif%2==0) puts("Alice");
    else puts("Borys");

    //main();


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main()
{
  int a[N],b,e=0,i,d,c,j;

  scanf("%d",&b);
  for(i=0;i<b;i++)
    scanf("%d",&a[i]);

 for(i=0;i<b-1;i++){
    c=i;
    for(j=i+1;j<b;j++){
      if(a[j]<a[c])
	c=j;
      }
      d=a[i];
      a[i]=a[c];
      a[c]=d;
    if(i != c)e++;
  }

	  
  for(i=0;i<b;i++){
    if(i>0)printf(" ");
                printf("%d",a[i]);
            }
            printf("\n");
            printf("%d\n",e);
            
            return 0;
        }



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

vector<bool> binary(int num){
  vector<bool> ans(6);
  for(int z=0;z<6;z++){
    if(num%2==1){
      ans.at(z)=true;
      num/=2;
    }else{
      ans.at(z)=false;
      num/=2;
    }
  }
  return ans;
}

int main() {
  int h,w,k=0;
  cin>>h>>w>>k;
  vector<vector<char>> vec(h,vector<char>(w));
  rep(i,0,h){
    rep(j,0,w){
      cin>>vec.at(i).at(j);
    }
  }
  int ans=0;
  
  int rephm=pow(2,h);
  int repwm=pow(2,w);
  
  rep(i,0,rephm){
    vector<bool> a(6);
    a=binary(i);
    rep(l,0,repwm){
      vector<bool> b(6);
      b=binary(l);
      vector<vector<char>> copyvec(h,vector<char>(w));
      copyvec=vec;
      
      /*rep(e,0,6){
        cout<<a.at(e);
      }
      cout<<endl;
      rep(g,0,6){
        cout<<b.at(g);
      }
      cout<<endl;*/
      
      rep(j,0,h){
        if(a.at(j)==true){
          rep(k,0,w){
            copyvec.at(j).at(k)='.';
          }
        }
      }
    
    
      rep(m,0,w){
        if(b.at(m)==true){
          rep(n,0,h){
            copyvec.at(n).at(m)='.';
          }
        }
      }
      
      /*rep(ii,0,h){
        rep(jj,0,w){
          cout<<copyvec.at(ii).at(jj);
        }
        cout<<endl;
      }*/
      
      int count=0;
      rep(o,0,h){
        rep(p,0,w){
          if(copyvec.at(o).at(p)=='#'){
            count++;
          }
        }
      }
      if(count==k){
        ans++;
      }
    }
  }
  cout<<ans;
}

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

#define cMaxLimit 250
#define NIL 2000000001

typedef struct {
	int key;
	int parent;
	int leftChild;
	int rightChild;
}Node;

void print(Node node[], int maxNum) {
	for (int i = 1; i <= maxNum; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << node[i].key << ", ";
		if (node[i].parent != NIL) {
			cout << "parent key = " << node[i].parent << ", ";
		}
		if (node[i].leftChild != NIL) {
			cout << "left key = " << node[i].leftChild << ", ";
		}
		if (node[i].rightChild != NIL) {
			cout << "right key = " << node[i].rightChild << ", ";
		}
		cout << endl;
	}
}

int main() {
	int nodeMaxNum;
	Node node[cMaxLimit+1];//????????????????????????1-???????????????????????????
	cin >> nodeMaxNum;

	for (int i = 1; i <= nodeMaxNum; i++) {
		int key; cin >> key;
		node[i].key = key;
		node[i].leftChild = NIL;
		node[i].rightChild = NIL;
		node[i].parent = NIL;
	}
	for (int i = 1; i <= nodeMaxNum; i++) {
		if (i / 2 >= 1) {
			node[i].parent = node[i / 2].key;
		}
		if (i * 2 <= nodeMaxNum) {
			node[i].leftChild = node[i * 2].key;
		}
		if (i * 2 + 1 <= nodeMaxNum) {
			node[i].rightChild = node[i * 2 + 1].key;
		}
	}

	print(node, nodeMaxNum);

	return 0;
}

Measured memory_bytes: 3096
from itertools import product

INF = 10**18

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(N)]

# i番目までのケーキの内、j個食べた時のpointの最大値
# (ただしpointの計算時には、8通りのmaskを乗算する)

def mul_mask(l, mask):
    # p = []
    # for i, m in enumerate(l):
    #     p.append(m*mask[i])
    #     # print(p)
    # return p
    return [a*b for a, b in zip(l, mask)]

dp_std = [[-INF for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
    dp_std[i][0] = 0
# print(dp_std)

max_p = -INF
masks = product([-1, 1], repeat=3)
# masks = []
# for i in [1, -1]:
#     for j in [1, -1]:
#         for k in [1, -1]:
#             masks.append([i, j, k])
# print(masks)
for mask in masks:
    dp = dp_std[:]
    for i in range(1, N+1):
        score = sum(mul_mask(XYZ[i-1], mask))
        for j in range(1, M+1):
            # print(i, j, XYZ[i-1], mask)
            dp[i][j] = max(
                dp[i-1][j],
                dp[i-1][j-1] + score
            )
            # for dp_i in dp:
            #     print(dp_i)
    p = dp[N][M]
    max_p = max(max_p, p)
    # print(p)

print(max_p)

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


int main(){
	long long int n,y;
	cin>>n>>y;
	long long int temp;
	int a,b,c;
	bool f = false;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if((i+j) > n) break;

			temp = 10000*i + 5000*j + 1000*(n-i-j);
			if( temp == y){
				a = i;
				b = j;
				c = n-i-j;
				f = true;
				break;
			}
		}
		if(f) break;
	}
	if(f) cout<<a<<" "<<b<<" "<<c;
	else cout<<-1<<" "<<-1<<" "<<-1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int x;
    cin >> x;
    cout << ( x < 1200 ? "ABC" : "ARC" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a,b;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;return 0;
    }
    int len=a,ans=1;
    while(len<b){
        len+=a-1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(auto &a : h) cin>>a;
    sort(h.begin(),h.end());
    ll sum =0ll;
    for(int i=0;i<max(0,n-k);++i){
        sum += h[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
long long n,m,k,a[20002],b[20002],m2,min,max,i;
int main(void)
{	
	scanf("%lld %lld %lld",&n,&m,&k);
	for(i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(i=0;i<=n+1;i++) b[i]=1000000000000000;
	m2=0; max=0; min=1000000000000000; b[0]=0;
	for(i=1;i<=n;i++){
		if(m2==m) m2=0, max=0, min=1000000000000000, i=i-(m-1);
		m2++;
		if(max<a[i]) max=a[i];
		if(min>a[i]) min=a[i];
		if(b[i]>b[i-m2]+k+m2*(max-min)) b[i]=b[i-m2]+k+m2*(max-min);
		//printf("i=%d m2=%d b[i]=%d %d\n",i,m2,b[i],k+m2*(max-min));
		if(i==n&&m2>1) i=i-(m2-1), m2=0, max=0, min=1000000000000000;
	}
	//for(i=1;i<=n;i++) printf("%d %lld\n",i,b[i]);
	printf("%lld\n",b[n]);
	return 0;
}


Measured memory_bytes: 3036
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

nums = [0]*(n+1)
for i in range(n+1): nums[i] = abs(a[i]-a[i+1])

total = sum(nums)
for i in range(n):
  ans = total - nums[i] - nums[i+1] + abs(a[i]-a[i+2])
  print(ans)

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

int n;

vector<int> S;

void print(int p, int r) {
	for (int i = r; i >= 1; i--) {
		S.push_back(i);
		if (p - i != 0) { print(p - i, min(p - i, i)); }
		if (p - i == 0) { 
			for (int i = 0; i < S.size(); i++) {
				if (i) { cout << ' '; }
				cout << S[i];
			}
			cout << endl; 
			S.pop_back();
		}
	}
	if (S.size() > 0) { S.pop_back(); }
	return;
}

int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		print(n, n);
	}
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

ll n;
vi a;
ll fac[101010] = {1};

ll mod_pow(ll x, ll n){
    // x^n % mod : O(logn)
    if(n == 0) return 1;
    ll res = mod_pow(x * x % mod, n/2);
    if(n & 1) res = res * x % mod;
    return res;
}

ll mod_comb(ll n, ll k){
    // requires fac[maxn](s.t. fac[i] = i!)
    if(n < k) return 0;
    ll top = fac[n];
    ll bot = (fac[k]*fac[n-k]) % mod;
    //cout << n << ' ' << k << endl;
    return (top*mod_pow(bot, mod-2)) % mod;
}

int main()
{
    rrep(i,101000) fac[i] = fac[i-1] * i % mod;

    cin >> n;
    a.resize(n);
    rep(i,n+1) cin >> a[i];

    ll pn[101010]; fill(pn+1, pn+n+1, -1);
    ll l,r;
    rep(i,n+1){
        if(pn[a[i]] != -1){
            l = ++pn[a[i]];
            r = ++i;
        }
        else pn[a[i]] = i;
    }

    rrep(k,n+1){
        cout << (mod_comb(n+1,k)-mod_comb(l+n-r,k-1)+mod)%mod << endl;
    }
}



Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;

vector<vector<LL>> d;

int main() {
  int N; cin >> N;
  d.resize(N, vector<LL>(N));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> d[i][j];
    }
  }

  LL sum = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) continue;
      bool ok = true;
      for (int k = 0; k < N; ++k) {
        if (i == k || j == k) continue;
        if (d[i][j] == d[i][k] + d[k][j]) {
          ok = false;
          break;
        } else if (d[i][j] > d[i][k] + d[k][j]) {
          cout << "-1" << endl;
          return 0;
        }
      }
      if (ok) sum += d[i][j];
    }
  }

  cout << sum/2 << endl;
}


Measured memory_bytes: 1024