akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	
	public static void main (String[] args) {
		
		Main main = new Main();
		main.solve();
	}
	
	private void solve() {
		
		Scanner scanner = new Scanner (System.in);
		
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int C = scanner.nextInt();
		
		int[] list = new int [M];
		
		for (int index=0; index<M; index++) {
			list[index]=scanner.nextInt();
		}
		
		int count = 0;
		
		for (int index=0; index<N; index++) {
			int sum = 0;
			for (int index2=0; index2<M; index2++) {
				int number = scanner.nextInt();
				sum+=(number*list[index2]);
			}
			
			sum+=C;
			
			if (sum>0) {
				count++;
			}
			
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

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

int main(){
    int a,b,c,sum;
    cin >> a >> b;
    while(b--){
        cin >> c;
        sum+=c;
    }
    if(sum>=a)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
    IOS;

    string s;
    cin >> s;
    int n = s.length();
    int val = 0;
    for(int i=0;i<n;i++){
        val = (val + (s[i] - '0')) % 9;
    }
    if(val) cout << "No\n";
    else cout << "Yes\n";
    return 0;    
}   

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll ct=0;
    ll mn=1000000000000;
    for(ll i=0;i<n;i++)
    {
        if(a[i]<mn)
        ct++;
        mn=min(mn,a[i]);
    }
    cout<<ct<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}





// bool prime[100000];

// // int gcdExtended(int a, int b, int *x, int *y) ;
// ll modInverse(int a, int m) 
// { 
//     int x, y; 
//     int g = gcdExtended(a, m, &x, &y); 
//     // if (g != 1) 
//     //     cout << "Inverse doesn't exist"; 
//     // else
//     // { 
//         // m is added to handle negative x 
//         int res = (x%m + m) % m; 
//         return res; 
//     // } 
// } 
  
// // // C function for extended Euclidean Algorithm 
// int gcdExtended(int a, int b, int *x, int *y) 
// { 
//     // Base Case 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
  
//     int x1, y1; // To store results of recursive call 
//     int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
//     // Update x and y using results of recursive 
//     // call 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
  
//     return gcd; 
// } 
// ll modu(ll x)
// {
//     if(x<0)
//     {
//         x+=mod;
//     }
//     else 
//     {
//         x=x%mod;
//     }
//     return x;
// }

// void SieveOfEratosthenes(int n) 
// { 
//     // Create a boolean aay "prime[0..n]" and initialize 
//     // all entries it as true. A value in prime[i] will 
//     // finally be false if i is Not a prime, else true. 
     
//     memset(prime, true, sizeof(prime)); 
  
//     for (int p=2; p*p<=n; p++) 
//     { 
//         // If prime[p] is not changed, then it is a prime 
//         if (prime[p] == true) 
//         { 
//             // Update all multiples of p greater than or  
//             // equal to the square of it 
//             // numbers which are multiple of p and are 
//             // less than p^2 are already been marked.  
//             for (int i=p*p; i<=n; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     prime[1]=false;
  
//     // Print all prime numbers 
//     // for (int p=2; p<=n; p++) 
//     //    if (prime[p]) 
//     //       cout << p << " "; 
// } 
// ll power(ll x, unsigned ll y, ll p) 
// { 
//     ll res = 1;      // Initialize result 
  
//     x = x % p;  // Update x if it is more than or  
//                 // equal to p 
  
//     while (y > 0) 
//     { 
//         // If y is odd, multiply x with result 
//         if (y & 1) 
//             res = (res*x) % p; 
  
//         // y must be even now 
//         y = y>>1; // y = y/2 
//         x = (x*x) % p;   
//     } 
//     return res; 
// } 

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

const int N = 5e5 + 25, MOD = 998244353;
int n, k, ans;
int F[N], Fdiv[N];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;
	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;
	return c;
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1)
			res = _mul(res, a);
		a = _mul(a, a);
	}
	return res;
}

int _choose (int a, int b) {
	if (b < a || min(a, b) < 0)
		return 0;

	return _mul(F[b], _mul(Fdiv[a], Fdiv[b - a]));
}

void preProcess() {
	F[0] = 1;
	Fdiv[0] = 1;
	for (int i = 1; i < N; i++) {
		F[i] = _mul(F[i - 1], i);
		Fdiv[i] = _pow(F[i], MOD - 2);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	preProcess();
	cin >> n >> k;

	for (int B = 0; B + B < k && n <= k - B; B++) {
		int R = k - B;
		int T = R - n + 1;

		if (B < T)
			ans = _sum(ans, _choose(R, R + B));
		else
			ans = _sum(ans, _sub(_choose(R, R + B), _choose(B - T, R + B)));
	}
	if (k % 2 == 0 && n * 2 <= k) {
		int R = k / 2;
		int B = k / 2;
		B--;
		int T = R - n + 1;

		if (B < T)
			ans = _sum(ans, _choose(R, R + B));
		else
			ans = _sum(ans, _sub(_choose(R, R + B), _choose(B - T, R + B)));
	}

	cout << ans << "\n";
	return 0;	
}

Measured memory_bytes: 7548
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
long long d(long long a,long long b){
	int c=0;
	for(long long i=a;i>0;i/=10)c++;
	int x=c;
	c=0;
	for(long long i=b;i>0;i/=10)c++;
	int y=c;
	return max(x,y);
}
int main(){
	long long n;
	cin>>n;
	int c=11;
	for(long long i=1;i<=sqrt(n);i++){
		if(n%i==0&&d(i,n/i)<c)c=d(i,n/i);
	}
	cout<<c<<endl;
	return 0;
}


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

struct StCst
{
  int m_nNo;
  int m_nInSeq;
  bool m_bDone;

  static bool AsdNo(const StCst& cnroLeft, const StCst& cnroRight) 
  { return cnroLeft.m_nNo < cnroRight.m_nNo; }
};

void fnInput(int &rnMaxSiz, vector<StCst> &rvoSort, int &rnMinNo)
{
  int nCnt = 0;
  cin >> rnMaxSiz;

  rvoSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
  {
    cin >> rvoSort[i].m_nNo;
    rnMinNo = min(rnMinNo, rvoSort[i].m_nNo);
    rvoSort[i].m_nInSeq = nCnt++;
  }
}

void fnMinCostSort(vector<StCst> &rvoSort, int nMinNo, int &rnSwpCnt)
{
  sort(begin(rvoSort), end(rvoSort), StCst::AsdNo);

  int nCost;
  for (int i = 0; i < rvoSort.size(); i++)
  {
    if (rvoSort[i].m_bDone)  continue;

    int nTotal = rvoSort[i].m_nNo;
    int nCurSize = 1;
    int nCurMin = rvoSort[i].m_nNo; 
    rvoSort[i].m_bDone = true;

    int j = rvoSort[i].m_nInSeq;
    while  (rvoSort[j].m_nNo != rvoSort[i].m_nNo)
    {
      nTotal += rvoSort[j].m_nNo;
      nCurSize++;
      nCurMin = min(nCurMin, rvoSort[j].m_nNo);
      rvoSort[j].m_bDone = true;
      j = rvoSort[j].m_nInSeq;
    }

    if (nCurSize == 1)
        nCost = 0;
    else
      if (nMinNo == nCurMin)
        nCost = nTotal + (nCurSize - 2) * nCurMin;
      else
        nCost = min(nTotal + (nCurSize - 2) * nCurMin, 
                    nTotal + nCurMin + (nCurSize + 1) * nMinNo);
    rnSwpCnt += nCost;
  }
}

void fnResult(int nSwpCnt)
{
  cout << nSwpCnt << endl;
}

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

  int nMaxSiz;
  vector<StCst> voSort;
  int nMinNo = INT_MAX;

  fnInput(nMaxSiz, voSort, nMinNo);

  int nSwpCnt = 0;
  fnMinCostSort(voSort, nMinNo, nSwpCnt);

  fnResult(nSwpCnt);
  return 0;
}

Measured memory_bytes: 1228
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    int a  = sc.nextInt();
    
    System.out.println(a*a*a + a*a + a);

  }
}

Measured memory_bytes: 35672
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,D[110][110],a[1100],b[1100],c[1100];
    cin>>N>>M;
    rep(i,N)rep(j,N){
        if(i!=j){
            D[i][j]=LLINF;
        }else{
            D[i][j]=0;
        }
    }
    rep(i,M){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        D[a[i]][b[i]]=min(D[a[i]][b[i]],c[i]);
        D[b[i]][a[i]]=min(D[b[i]][a[i]],c[i]);
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
            }
        }
    }
    ll ans=M;
    rep(i,M){
        bool can=false;
        rep(j,N){
            if(D[j][a[i]]+c[i]==D[j][b[i]]) can=true;
        }
        if(can) ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	while(1){
		int n;
		vector<int> a;
		
		cin>>n; 
		if(n == 0)
			break;
			
		for(int i=0; i<n; i++){
			int x; 
			cin>>x; 
			a.push_back(x);
		}
		sort(a.begin(),a.end());
		
		int diff=1000000; 
		for(int i=0; i<n-1; i++){
			if(a[i+1] - a[i] < diff){
				diff=a[i+1] - a[i];
			}
			if(diff == 0)
				break;
		}
		cout<<diff<<endl;
	}
	return 0;
}

Measured memory_bytes: 3144
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
let h = input[0].split(' ').map(x => +x)[0];
const nums = input[1]
    .split(' ')
    .map(x => +x)
    .sort((a, b) => b - a);
let flag = false;
nums.forEach(n => {
    h -= n;
    if (h <= 0) {
        flag = true;
        return;
    }
});
console.log(flag ? 'Yes' : 'No');


Measured memory_bytes: 28072
def postalcode(a,b,s):
    if s[a]!="-":
        return "No"
    numbers=[str(i) for i in range(10)]
    for i in s[:a]+s[-b:]:
        if i not in numbers:
            return "No"
    return "Yes"

a,b=map(int,input().split())
s=input()
print(postalcode(a,b,s))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

#define MP 999983
#define MAX 1000000
int Prime[MAX+1];
bool prime[MAX+1];

void make(){
  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;

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

  int sum = 0;
  for(int i = 0 ; i <= MAX ; i++){
    if(prime[i]){
      sum++;
    }
    Prime[i] = sum;
  }
}

int main(){
  int n;

  make();

  while(cin >> n ,n){
    int p,m,ans = 0;
    for(int i = 0 ; i < n ; i++){
      cin >> p >> m;

      int large = p + m;
      int small = p - m;

      if(large > MP){
	large = MP;
      }     
      if(small < 0){
	small = 0;
      }
      int X = Prime[large] - Prime[small] + prime[small];
      if(X == 0){
	ans--;
      }else{
	ans += X-1;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    if(T >= A){
        ans = (T / A) * B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a,m,b,s[100],t[100],cnt=1;
vector<int> v[100];
void dfs(int n){
    if(s[n]==0){s[n]=cnt;cnt++;}
    for(auto x:v[n]){
        if(s[x]==0)dfs(x);
    }
    if(t[n]==0){t[n]=cnt;cnt++;}
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>m;
        for(int j=0;j<m;j++){
            cin>>b;
            if(a==b)continue;
            v[a-1].push_back(b-1);
        }
    }
    for(int i=0;i<n;i++)if(s[i]==0)dfs(i);
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<s[i]<<" "<<t[i]<<endl;
    }
}



Measured memory_bytes: 3164
n = int(input())
L = [input() for i in range(n)]
for line in L:
	A = line.split()
	B = sorted([int(A[i]) for i in range(3)])
	if B[2]**2 == B[0]**2 + B[1]**2:
		print('YES')
	else:
		print('NO')

Measured memory_bytes: 7944
K, N = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]
diff = []

sum_num = 0
max_num = 0
max_num = K - A[-1] + A[0]
sum_num += K - A[-1] + A[0]
diff.append(K - A[-1] + A[0])
for i in range(N - 1):
    tmp = A[i + 1] - A[i]
    diff.append(tmp)
    if tmp >= max_num:
        max_num =tmp
    sum_num += tmp

ans = sum_num - max_num
print(ans)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

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

    int n;
    cin>>n;
    unsigned ll ans = 1;
    unsigned ll lim = 1000000000000000000LL;
    bool bl=true;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(ans==0)continue;
        if(lim/ans < a){

            bl=false;
        }
        if(bl!=false)ans *= a;
        if(a==0){
            bl=true;
            ans=0;
        }

    }
    if(bl){
        cout<<ans<<"\n";
    }
    else{
        cout<<-1<<"\n";
    }
    /*ll a;

    long double b;
    cin>>a>>b;
    b*=100.00;

    ll B = b;
    ll ans = a*B;
    ans/=100;
    cout<<(ans)<<"\n";*/

}


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

int main() {
  string S;
  cin >> S;
  
  int nsun;
  if (S == "SUN") {
    nsun = 7;
  } else if (S == "MON") {
    nsun = 6;
  } else if (S == "TUE") {
    nsun = 5;
  } else if (S == "WED") {
    nsun = 4;
  } else if (S == "THU") {
    nsun = 3;
  } else if (S == "FRI") {
    nsun = 2;
  } else if (S == "SAT") {
    nsun = 1;
  }
  
  cout << nsun << endl;
  return 0;
}


Measured memory_bytes: 256
import math
def I():
  return input()
def II():
  return int(input())
def MII():
  return map(int, input().split())
def LMII():
  return list(map(int, input().split()))

n, r = MII()
i = 1
a = r
while True:
  if n < a:
    break
  else:
    a *= r
    i += 1
print(i)


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  double tmp_sum = 0.0000;
  for(int x : vec) {
    tmp_sum += 1.0 / x;
  }
  cout << 1.0 / tmp_sum << endl;
}

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

int main()
{
	int N,X,sum(0),L;
	cin >> N >> X;
	for(int i(0);i<N+1;++i){
		cin >> L;
		sum += L;
		if(sum>X){
			cout << i+1 << endl;
			return 0;
		}
	} 
	cout << N+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll suma = 0, sumb = 0;
	rep(i, n) suma += a[i];
	rep(i, n) sumb += b[i];
	ll res = sumb - suma;
	if (res < 0) {
		cout << "No" << endl;
		return 0;
	}
	ll tmp1 = 0, tmp2 = 0;
	rep(i, n) {
		if (a[i] > b[i]) {
			tmp1 += a[i] - b[i];
		}
		if (a[i] < b[i]) {
			tmp2 += (b[i] - a[i] + 1) / 2;
		}
	}
	if (tmp1 <= res && tmp2 <= res) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <cstdlib>
using namespace std;
#define pii pair<int,int>
#define ft first
#define sc second
#define INF 1000000006
#define INFLL 4000000000000000006ll
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define gc getchar_unlocked
#define getInt(x) while((_c=gc())<'0'); x=_c-'0'; while((_c=gc())>='0') x=x*10+_c-'0';
#define LL long long
#define DB double
#define PARAM int id, int l, int r
#define _L id*2,l,mid
#define _R id*2+1,mid+1,r
#define PREP int mid = (l+r)/2
#define MEMSET(x,y) memset(x,y,sizeof(x));
#define MOD 1000000007
int main(){
	LL n, m; scanf("%lld%lld",&n,&m);
	if(abs(n-m)>1){
		printf("0\n"); return 0;
	}
	LL res = 1;
	for(int i = 1; i <= n; i++ ) res = (res*i)%MOD;
		
	for(int i = 1; i <= m; i++ ) res = (res*i)%MOD;
	if(n==m) res *= 2;
	printf("%lld\n",res%MOD);
	return 0;
}


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

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

  int ans = false;
  for (int i = 0; i < s.size(); i++) {  // startのindex
    string tmp;
    for (int j = 0; j < s.size(); j++) {
      tmp += s[(i + j) % s.size()];
    }
    // cout << tmp << endl;
    if (tmp == t) {
      ans = true;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int n;
int num[2000000];
vector<string>s;

int main(void){
    cin >> n;
    for(int i=0; i<n; i++){
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    sort(s.begin(), s.end());

    int j=0;
    int maxvote=0;
    num[0]=1;
    for(int i=1; i<n; i++){
        if(s[i-1] != s[i]){
            j++;
        }
        num[j]++;
        if(maxvote < num[j]){
            maxvote = num[j];
        }
    }
    
    s.erase(unique(s.begin(), s.end()), s.end()); 

//            cout << "##" << endl;
//            cout << maxvote << endl;
//            cout << num[0] << endl;


    for(int i=0; i<s.size(); i++){
        if(num[i] == maxvote){
            cout << s[i] << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 15088
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(5, 0);
  int N, K;
  string S;
  cin >> N;
  cin >> S;
  cin >> K;
  auto target = S[K - 1];
  int i = 0;
  for (auto c : S) {
    if (c != target) {
      S[i] = '*';
    }
    ++i;
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define debug(x) cerr << #x << ": " << x << "\n"
#define task ""
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> li;
typedef vector<int> vi;

const int N = 1000 + 5;
const int M = 2000 + 5;
const ll md = 1e9 + 7;
struct Edge{
	int u, v, c;
	bool operator < (Edge oth) {
		return c < oth.c;
	}
} e[M]; 
int n, m, lab[N], rnk[N];
ll x;

ll Pow(int x) {
	if (x == 0) return 1;
	else {
		ll res = Pow(x / 2);
		res = res * res % md;
		if (x % 2) res = res * 2 % md;
		return res;
	}
}
int root(int u) {
	if (lab[u] == -1) return u;
	else return lab[u] = root(lab[u]);
}
void join(int u, int v) {
	u = root(u), v = root(v);
	if (rnk[u] > rnk[v]) {
		lab[v] = u;
	} else {
		lab[u] = v;
		if (rnk[u] == rnk[v]) rnk[v] ++;
	}
}
ll MST() {
	ll res = 0;
	REP(i, m) {
		int u = e[i].u, v = e[i].v;
		if (root(u) != root(v)) {
			join(u, v);
			res += e[i].c;
		}
	}
	return res;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//freopen(task".inp", "r", stdin);
	//freopen(task".out", "w", stdout);
	cin >> n >> m >> x;
	REP(i, m) {
		cin >> e[i].u >> e[i].v >> e[i].c;
	}	
	sort(e, e+m);
	int cnt1 = 0, cnt2 = 0, cnt0 = 0;
	REP(i, m) {
		memset(lab, -1, sizeof lab);
		memset(rnk, 0, sizeof rnk);
		join(e[i].u, e[i].v);
		ll tmp = e[i].c + MST();
		if (tmp < x) cnt0 ++;
		else if (tmp == x) cnt1 ++;
		else if (tmp > x) cnt2 ++;
	}
	//cer  << cnt0 << " " << cnt1 << " " << cnt2 << "\n";
	if (cnt1 == 0) cout << 0;
	else if (cnt0 == 0) cout << ((Pow(n-1) - 2) * Pow(m-n+1) % md + 2 * (Pow(cnt1 - n + 1) - 1) % md * Pow(cnt2) % md) % md;
	else cout << 2 * (Pow(cnt1) - 1) % md * Pow(cnt2) % md;
}


Measured memory_bytes: 256
#include <cstdio>
#define min(a,b) a<b?a:b
int n,m,k,d[105][105];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(i*j<=n*m-k) d[i][j]=0;
			else d[i][j]=min(d[i-1][j]+1,d[i][j-1]+1);
	printf("%d",d[n][m]);
	return 0;
}

Measured memory_bytes: 256
def main():
    n, k = [int(i) for i in input().split()]
    #smallのバリエーション
    mod = 1000000007
    res = 0
    for i in range(k, n+2):
        min_s = int(i*(i-1)/2)
        max_s = int(n*(n+1)/2 - (n-i)*(n-i+1)/2 )
        res += max_s - min_s + 1
        res = res % mod
    print(int(res))

if __name__ == '__main__':
    main()



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

using namespace std;

int main() {
  string o;
  string e;
  cin >> o >> e;
  for (int i = 0; i < o.size(); ++i) {
    cout << o[i];
    if (i < e.size()) cout << e[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first
 
int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************


int32_t main()
{     fio;
      cin>>n;
      while(n)
      {
            n--;
            s.push_back((char)('a'+n%26));
            n/=26;
      }
      Rev(s);
      cout<<s;
}


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

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

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

  vector<int> vprice(n);
  vector<vector<int>> vv(n, vector<int>(m));

  bool ans = false;
  int ans_price = 10000000;

  for (int i = 0; i < n; i++)
  {
    int p; cin >> p;
    vprice.at(i) = p;
    for (int j = 0; j < m; j++)
    {
      int q; cin >> q;
      vv.at(i).at(j) = q;
    }
  }

  for (int i = 0; i < (1 << 12); i++)
  {
    bitset<12> b(i);
    vector<int> vtmp(m, 0);
    int sum = 0;
    for (int j = 0; j < n; j++)
    {
      if(b.test(j))
      {
        for (int k = 0; k < m; k++)
        {
          vtmp.at(k) += vv.at(j).at(k);
        }
        sum += vprice.at(j);
      }
    }
    bool test = true;
    for (int j = 0; j < m; j++)
    {
      if(vtmp.at(j) < x)
      {
        test = false;
        break;
      }
    }
    if(test)
    {
      ans = true;
      ans_price = min(ans_price, sum);
    }
  }
  
  if(ans)
  {
    cout << ans_price << endl;
  }
  else
  {
    cout << -1 << endl;
  }
  
  
  return 0;
}

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

#define sc(x) scanf("%d",&x);
#define rep(x ,n) for(int x=0; x<n; x++)
#define ll long long
#define finish(x) return cout << x << endl,0;
#define scarr(a,n) for(int x=0; x<n; x++)scanf("%d",&a[x]);

int n ,d;
int a[25];

int main()
{
    sc(n)
    scarr(a ,n);
    int ans = 0;
    for(int i=1; i<n-1; i++){
        if(min(a[i-1] ,a[i+1]) < a[i] && a[i] < max(a[i-1] ,a[i+1]))
            ans++;

    }
    finish(ans);
}


Measured memory_bytes: 256
import kotlin.math.max
import kotlin.math.min

fun main(args: Array<String>) {
    val regex = Regex("<*>*")
    val s = regex.findAll(readString()).map { it.value }.toList()

    var ans = 0L
    s.forEach {
        val gt = it.count { it == '<' }
        val lt = it.count { it == '>' }

        for (i in 0..max(gt, lt)) {
            ans += i
        }
        for (i in 0 until min(gt, lt)) {
            ans += i
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!

Measured memory_bytes: 63688
loop do
    n = gets.to_i
    break if n == 0
    s = gets
    hand = Array.new(n, 0)
    field = 0
    s.each_char.with_index do |c, k|
        k = k % n
        if c == "S"
            field += hand[k] + 1
            hand[k] = 0
        elsif c == "L"
            hand[k] += field + 1
            field = 0
        elsif c == "M"
            hand[k] += 1
        end
    end
    puts (hand.sort + [field]).join(" ")
end

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


int main() {
  int n; cin >> n;
  vector<int> h(n); rep(i,n)cin >> h[i];
  vector<int> down(1);
  int p = 0; //それぞれで下った回数
  rep(i,n-1){
    if(h[i] < h[i+1]){
      down.push_back(p);
      p = 0;
    }
    else p++;
  }
  down.push_back(p);
  sort(down.begin() , down.end());
  reverse(down.begin() , down.end());
  cout << down[0] << endl;
  
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  string S;
  cin >> S;
  REP(i, (int)S.size()) {
    char c = S[i];
    if(i % 2 == 0 && c == 'L') {
      cout << "No" << endl;
      return 0;
    }
    if(i % 2 == 1 && c == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int dis1[N],dis2[N];
vector<int>v[N];
bool vis[N];
void dfs1(int x,int c){
    vis[x]=true;
    dis1[x]=c;
    for (int i=0;i<v[x].size();i++){
        if (!vis[v[x][i]])
            dfs1(v[x][i],c+1);
    }
}
void dfs2(int x,int c){
    vis[x]=true;
    dis2[x]=c;
    for (int i=0;i<v[x].size();i++){
        if (!vis[v[x][i]])
            dfs2(v[x][i],c+1);
    }
}
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int r,l;
    for (int i=0;i<x-1;i++){
        cin>>r>>l;
        v[r].push_back(l);
        v[l].push_back(r);
    }
    dfs1(1,0);
    memset(vis,false,sizeof (vis));
    dfs2(x,0);
    int black=0,white=0;
    for (int i=1;i<=x;i++){
        if (dis1[i]<=dis2[i])
            black++;
        else
            white++;
    }
    cout<<(black>white?"Fennec":"Snuke");
    return 0;
}


Measured memory_bytes: 11264
import java.io.*;
import java.math.BigDecimal;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    
    System.out.println(BigDecimal.valueOf(n*n*n/27.0).toPlainString());
  }
}


Measured memory_bytes: 21332
#include <iostream>

using namespace std;

int main() {
    string S;
    cin >> S;
    if (S.size() < 5) {
        cout << "NO" << endl;
        return 0;
    }
    int i = S.size();
    while (i >= 5) {
        if (i - 5 >= 0 && S.substr(i - 5, 5) == "dream") {
            i -= 5;
        } else if (i - 7 >= 0 && S.substr(i - 7, 7) == "dreamer") {
            i -= 7;
        } else if (i - 5 >= 0 && S.substr(i - 5, 5) == "erase") {
            i -= 5;
        } else if (i - 6 >= 0 && S.substr(i - 6, 6) == "eraser") {
            i -= 6;
        } else {
            break;
        }
    }
    if (i == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	vector<int> ans(26, 100);
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		vector<int> cnts(26, 0);
		for (char c : s) cnts[c-'a']++;
		for (int v = 0; v < 26; v++) {
			ans[v] = min(ans[v], cnts[v]);
		}
	}
	for (int v = 0; v < 26; v++) {
		while (ans[v]--) {
			cout << char(v+'a');
		}
	}
	cout << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib> 
#include<sstream>
#include<cstdio>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=1111122;
const int M=200005;
int main()
{

    LL a,i,j,n,m,b,x,flag=0;
    cin>>x;
    for(a=-2000;a<=2000;a++)
    {
        for(b=-2000;b<=2000;b++)
        {
            LL ans=a*a*a*a*a;
            LL ans1=b*b*b*b*b;
            if(ans-ans1==x)
            {
                cout<<a<<" "<<b<<endl;
                flag=1;
                break;
            }
        }
        if(flag)break;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3172
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let T = read![usize, usize; M];
    let (s, t) = read!(usize, usize);

    let (s, t) = (s - 1, t - 1);

    let mut G = vec![vec![]; N];
    for (u, v) in T {
        G[u - 1].push(v - 1);
    }

    let mut done = vec![vec![false; 3]; N];
    let mut dist = vec![vec![None; 3]; N];
    let mut Q = VecDeque::new();
    Q.push_back((s, 0));

    while let Some((u, x)) = Q.pop_front() {
        let r = x % 3;

        if done[u][r] {
            continue;
        }

        done[u][r] = true;
        dist[u][r] = Some(x);

        debug!((u, r, x));

        for i in 0..G[u].len() {
            let v = G[u][i];
            let y = x + 1;
            Q.push_back((v, y));
        }
    }

    match dist[t][0] {
        None => println!("-1"),
        Some(d) => println!("{}", d / 3),
    }
}


Measured memory_bytes: 24828
/*
AizuOJ ALDS1_11_B

???;DFS;????´¢;?¨????
*/
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int MAXN=110;
int n;
vector<int> adj[MAXN];
int visited[MAXN], d[MAXN], f[MAXN], t=0;

void dfs(int s) {
    visited[s]=true;
    d[s]=++t;
    for (vector<int>::iterator iter=adj[s].begin(); iter!=adj[s].end(); iter++) {
        if (!visited[*iter]) dfs(*iter);
    }
    f[s]=++t; // ????????¶????????????
}

void add_edge(int u, int v) {
    adj[u].push_back(v);
}

int k, tmp, v;
int main() {
    scanf("%d", &n);
    for (int u=1; u<=n; u++) {
        scanf("%d%d", &tmp, &k); // k ?????????
        while (k--) {
            scanf("%d", &v);
            add_edge(u, v);
        }
        sort(adj[u].begin(), adj[u].end());
    }
    for (int u=1; u<=n; u++) {
        if (!visited[u]) dfs(u);
    }
    for (int u=1; u<=n; u++) {
        printf("%d %d %d\n", u, d[u], f[u]);
    }
    return 0;
}

Measured memory_bytes: 2632
#include<stdio.h>
#include<math.h>
int main(){
    int n,ax,ay,bx,by,cx,cy;
    double t,x,y;
    scanf("%d%d%d%d",&ax,&ay,&bx,&by);
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&cx,&cy);
        t=((ax-bx)*(ax-cx)+(ay-by)*(ay-cy))/(pow(ax-bx,2)+pow(ay-by,2));
        x=2*(ax+t*(bx-ax))-cx;
        y=2*(ay+t*(by-ay))-cy;
        printf("%.10f %.10f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 640
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
x,y,z,k = ma()
A = lma()
B=lma()
C=lma()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
i,j,m = 0,0,0
h=[(-A[i]-B[j]-C[m],i,j,m)]
cnt=0
d=collections.defaultdict(lambda:True)
while cnt<k:
    ans,i,j,m=hq.heappop(h)
    print(-ans)
    if i+1<x and d[(i+1,j,m)]:
        hq.heappush(h,(-A[i+1]-B[j]-C[m],i+1,j,m))
        d[(i+1,j,m)]=False
    if j+1<y and d[(i,j++1,m)]:
        hq.heappush(h,(-A[i]-B[j+1]-C[m],i,j+1,m))
        d[(i,j+1,m)]=False
    if m+1<z and d[(i,j,m+1)]:
        hq.heappush(h,(-A[i]-B[j]-C[m+1],i,j,m+1))
        d[(i,j,m+1)]=False
    cnt+=1


Measured memory_bytes: 90276
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
ll longinf=(1ll<<31)-1;

int main(){
      ll n,a,b;
      cin>>n>>a>>b;
      ll ok = 1e9;
      ll ng = -1;
      ll h[n];
      rep0(i,n) cin>>h[i];
      while(ok - ng > 1){
            ll pos=(ok+ng)/2;
            ll pp=pos;
            ll q[n]; 
            rep0(i,n){
                  q[i]=h[i]-(b*pos);
            }
            rep0(i,n){
                  pp-=max(0ll,((q[i]+a-b-1)/(a-b)));
            }
            if(pp>=0) ok=pos;
            else ng=pos;
      }
      cout<<ok<<endl;
      return 0;
}

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

int main(){
  int N,i,n,tmp;
  std::vector<int> x;
  std::vector<int> y;

  std::cin >> N;

  for(i=0;i<N;i++) {
    std::cin >> n;
    x.push_back(n);
    y.push_back(n);
  }

sort(x.begin(),x.end());

  std::map<int, int>ind;
  for(i=0;i<N;i++){
    ind[x[i]]=i;
  }



  for(i=0;i<N;i++){
  int j=ind[y[i]];

  if(j<N/2){
    std::cout << x[N/2] << '\n';
  }
  else{
    std::cout << x[N/2-1] << '\n';
  }

}



  return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }
    if(s=="Rainy"){
        cout<<"Sunny"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b ,c, d; cin >> a >> b >> c >> d;
    bool judge = 0;
    if(c >= a and c - a <= d) judge = 1;
    else if(a >= c and a - c <= d) judge = 1;
    else if(c > a and a + d >= b and b + d >= c) judge = 1;
    else if(a > c and c + d >= b and b + d >= a) judge = 1;
    cout << (judge ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}


template<class T>
struct seg_tree{
    int N;
    T init = inf;
    vector<T> node;

    seg_tree(int n){
        N = 1;
        while(N < n) N *= 2;
        node.resize(N * 2 - 1);
        for(auto& u : node){
            u = init;
        }
    }

    void update(int i, T x){
        i += N - 1;
        node[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    T get_min(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r == -1) r = N;
        if(b <= l || r <= a) return init;
        if(a <= l && r <= b) return node[k];

        T vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

struct sec{
    int l, r, val;
    sec(){}
    sec(int l, int r, int val) : l(l), r(r), val(val) {}

    bool operator < (const sec& s1) const {
        return val < s1.val;
    }
    bool operator > (const sec& s1) const {
        return val > s1.val;
    }
};

int N;
int idx[200010];
vector<pii> ans;
priority_queue<sec, vector<sec>, greater<sec>> range;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    seg_tree<int> ps[2] = {seg_tree<int>(N), seg_tree<int>(N)};
    
    for(int i = 0; i < N; ++i){
        int p;
        cin >> p;
        ps[i & 1].update(i, p);
        idx[p] = i;
    }

    range.push({0, N, ps[0].get_min(0, N)});
    while(!range.empty()){
        sec p = range.top();
        range.pop();
        int l = p.l, r = p.r;
        if(l == r) continue;

        int n1 = p.val;
        int n2 = ps[(l + 1) & 1].get_min(idx[n1], r);
        ans.push_back({n1, n2});

        int id1 = idx[n1], id2 = idx[n2];

        range.push({l, id1, ps[l & 1].get_min(l, id1)});
        range.push({id1 + 1, id2, ps[(id1 + 1) & 1].get_min(id1 + 1, id2)});
        range.push({id2 + 1, r, ps[(id2 + 1) & 1].get_min(id2 + 1, r)});
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].first << " " << ans[i].second << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i =0;i<N;i++)
    cin >>vec.at(i);
  for (int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      if(vec.at(j) <vec.at(j+1)){
        int a = vec.at(j);
        vec.at(j) = vec.at(j+1);
        vec.at(j+1) = a;
      }
    }
  }
  int count = 1;
  for(int i=0;i<N-1;i++){
    if(vec.at(i) != vec.at(i+1))
      count++;
  }
  cout << count <<endl;
     
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i;cin>>n;
	vector<llint>ps,ms;
	for(i=0;i<n;i++){
		llint x;cin>>x;
		if(x>0){ps.pub(x);}
		else{ms.pub(x);}
	}
	SO(ps);
	SO(ms);REV(ms);
	
	if(ps.size()>0&&ms.size()>0){
		llint M=0;
		for(auto it:ps){M+=abs(it);}
		for(auto it:ms){M+=abs(it);}
		cout<<M<<endl;
		while(ps.size()>1){cout<<ms[0]<<" "<<ps.back()<<endl;ms[0]-=ps.back();ps.pob();}
		while(ms.size()>1){cout<<ps[0]<<" "<<ms.back()<<endl;ps[0]-=ms.back();ms.pob();}
		cout<<ps[0]<<" "<<ms[0]<<endl;
	}else if(ps.size()>0){
		llint M=-2*ps[0];
		for(auto it:ps){M+=abs(it);}
		cout<<M<<endl;
		while(ps.size()>2){cout<<ps[0]<<" "<<ps.back()<<endl;ps[0]-=ps.back();ps.pob();}
		cout<<ps[1]<<" "<<ps[0]<<endl;
	}else{
		llint M=2*ms[0];
		for(auto it:ms){M+=abs(it);}
		cout<<M<<endl;
		while(ms.size()>1){cout<<ms[0]<<" "<<ms.back()<<endl;ms[0]-=ms.back();ms.pob();}
		
	}
	return 0;
}

Measured memory_bytes: 2804