akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

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

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N, M;
  cin >> N >> M;
  int64 cnt = 0;
  int64 num_of_S_can_use = min(M / 2, N);
  cnt += num_of_S_can_use;
  M -= num_of_S_can_use * 2;
  cnt += M / 4;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c = (int(x) for x in input().split())

if a==7 and b==5 and c==5:
    print('YES')
elif a==5 and b==7 and c==5:
    print('YES')
elif a==5 and b==5 and c==7:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int k;
    int x[105];
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&x[i]);
        int sum=0;
    for(int i=1;i<=n;i++)
        sum+=min(x[i],k-x[i]);
    printf("%d\n",sum*2);
    return 0;
}


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

int main() {
  int N, Sum=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  sort(A.begin(), A.end());
  rep(i, N-1){
    for(int j=i+1; j<N-1; j++){
      for(int k=j+1; k<N; k++){
        if(A.at(i)+A.at(j)<=A.at(k)){
          break;
        }
        else{
          Sum++;
        }
      }
    }
  }
  cout << Sum << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(input() for _ in range(n))
D = dict.fromkeys(set(L),0)

for l in L:
  D[l] += 1

m = max(D.values())
SD = sorted(D.items(), key=lambda x:x[0])

for k, v in SD:
  if v == m:
    print(k)

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

int main() {
	int n; cin >> n;
	vector<int>a(n), b(n), c(n);
	auto input = [&](vector<int>&x) {
		for (auto&& xx : x)cin >> xx;
	};
	input(a), input(b), input(c);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		auto A = lower_bound(a.begin(), a.end(), b[i]);
		auto C = upper_bound(c.begin(), c.end(), b[i]);
		ans += (A - a.begin()) * (c.end() - C);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
a,b=list(map(int,input().strip().split()))
if a-b>1 or b-a>1:
	print(0)
else:
	ans=1
	if a==b:
		ans=ans*2
	for i in range(1,a+1,1):
		ans=ans*i%1000000007
	for i in range(1,b+1,1):
		ans=ans*i%1000000007
	print(ans)

Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int r;
    cin >> r;

    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n;
	int a[105000];
	int b[105000];
	scanf("%d",&n);
	for(int i=0; i<n+1; i++) {
		scanf("%d",&a[i]);
	}
	for(int i=0; i<n; i++) {
		scanf("%d",&b[i]);
	}
	long long int max=0;
	for(int i=0; i<n; i++) {
		if(a[i]>=b[i]) {
			max+=b[i];
			continue;
		} else if(a[i]<b[i]) {
			max+=a[i];
			b[i]-=a[i];
			if(a[i+1]>=b[i]) {
				max+=b[i];
				a[i+1]-=b[i];
			} else {
				max+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	printf("%lld",max);
	return 0;
}

Measured memory_bytes: 1024
list_s = list(str(input()))
for i in range(4):
    list_s[i] = int(list_s[i])

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            if i == 0:
                ans += list_s[0] + list_s[1]
            else:
                ans += list_s[0] - list_s[1]
            if j == 0:
                ans += list_s[2]
            else:
                ans -= list_s[2]
            if k == 0:
                ans += list_s[3]
            else:
                ans -= list_s[3]
            if ans == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
list_sgn = ["+","-"]
print(str(list_s[0]) + list_sgn[i] + str(list_s[1]) + list_sgn[j] + str(list_s[2]) + list_sgn[k] + str(list_s[3]) + "=7")


Measured memory_bytes: 3064
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
import string
input = sys.stdin.readline

S = input()
All_string = list(string.ascii_lowercase)

for i in range(len(S)):
    if S[i] in All_string:
        n = All_string.index(S[i])
        All_string.pop(n)

if not All_string:
    print("None")
else:
    print(All_string[0])


Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

/// Lib
///

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    int count = 0;
    for(int i = 0; i < n; ++i){
        if(p[i] != i + 1){
            ++count;
        }
    }

    if(count <= 2){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


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

using namespace std;

const int MAX_N=131072;
int score[MAX_N];
int dat[2*MAX_N-1];
const int INF=1<<29;

void update(int ok,int a){
  score[ok]=a;
  int k=ok+MAX_N-1;
  dat[k]=ok;
  while(k>0){
    k=(k-1)/2;
    dat[k]=(score[dat[k*2+1]]>=score[dat[k*2+2]])?dat[k*2+1]:dat[k*2+2];
  }
}

int main(){
  int N,R,L;
  cin>>N>>R>>L;
  vector<tuple<int,int,int> >v;
  for(int i=0;i<R;i++){
    int d,t,x;
    cin>>d>>t>>x;
    v.emplace_back(d,t,x);
  }
  fill(begin(score),end(score),-INF);
  for(int i=1;i<=N;i++){
    update(i,0);
  }
  int x=0;
  int t[MAX_N]={};
  for(int i=0;i<L;i++){
    while(x<R&&get<1>(v[x])==i){
      int d=get<0>(v[x]);
      update(d,score[d]+get<2>(v[x]));
      x++;
    }
    t[dat[0]]++;
  }
  cout<<max_element(begin(t),end(t))-begin(t)<<endl;
}

Measured memory_bytes: 15360
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N,R;
    cin>>N>>R;
    int ans=0;
    if (N<=10){
         ans = R + 100*(10-N);
    }
    else{
        ans = R;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

   int N;
   cin >> N;
   vector<int> A(N);
   int M = 0;
   rep(i,N) { cin >> A[i]; M=max(A[i],M); }
   vector<int> check(M+5,0);
   for(int x: A){
    if(check[x]!=0){
        check[x] = 2;
        continue;
    }
    for(int i=x; i <= M+1; i+=x) check[i]++;
   }
   int ans = 0;
   for(int x: A){
    if(check[x]==1) ans++;
   }
   cout << ans << endl;

}

Measured memory_bytes: 7944
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abcPpc_b();
	}
  
  	public static void solve_abcPpc_b(){

		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		long W = sc.nextLong();
		long ans = 0;

		if((H == 1) || (W == 1)){
			ans = 1;
		}
		else if((W % 2 == 0) || (H % 2 == 0)){
			ans = (H * W ) / 2;
		}
		else{
			ans = (H * W + 1) / 2;
		}

		System.out.println(ans);

		sc.close();

	}
}

Measured memory_bytes: 21844
H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)

DP = [0]*(H+A_max)
for i in range(1, H+A_max):
    dp = float('inf')
    for a, b in zip(A,B):
        if i-a>=0:
            dp = min(dp, DP[i-a] + b)
    DP[i] = dp
print(min(DP[H:]))

Measured memory_bytes: 43740
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<pair<int, int>>> adj;
vector<int> dis;
vector<bool> vis;
set<int> s;
bool fullCl = false;

void dfs( int u, int d ){
	
	if( dis[u] != -1 && dis[u] != d ){
		fullCl = true;
		return;
	}
	dis[u] = d;
	if( vis[u] ) return;
	vis[u] = true;
	if( fullCl ) return;
	//cout << " " << u << " " << d << endl;
	for( auto v : adj[u] ){
		dfs(v.first, v.second+d);
	}
} 

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, x, y, z;
	cin >> n >> m;
	dis.assign(100001, -1);
	vis.assign(100001, false);
	adj.assign(100001, vector<pair<int, int>>());
	
	for( int i = 0; i < m; ++i ){
		cin >> x >> y >> z;
		x--; y--;		
		adj[x].push_back(make_pair(y, z));
		adj[y].push_back(make_pair(x, -z));
		s.insert(x); s.insert(y);
	}

	for( auto it : s ){
		if( !vis[it] ){
			//cout << it << endl;
			dfs(it, 0);
			if( fullCl )
				break;
		}
	}

	if( !fullCl )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0;i<N;i++)  cin >> X.at(i);

  int ans=1e9;
  for(int i=1;i<=100;i++){
    int sum=0;
    for(int j=0;j<N;j++){
      sum+=(X.at(j)-i)*(X.at(j)-i);
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL ll[400005],rr[400005],l[400005],r[400005];
LL stk[400005],tp = 0;
LL n,a[400005],tot = 0;

LL dp[25][400005];
LL LOG[400005];

void init(){
	LOG[0] = -1;
	for(LL i = 1;i <= n;i ++) LOG[i] = LOG[i >> 1] + 1;
	for(LL i = 0;i <= n;i ++) dp[0][i] = a[i];
	for(LL i = 1;i <= 20;i ++){
		for(LL j = 0;j <= n;j ++){
			if(j + (1 << (i - 1)) > n) break;
			dp[i][j] = max(dp[i - 1][j],dp[i - 1][j + (1 << (i - 1))]);
		}
	}
}

LL query(LL x,LL y){
	LL k = LOG[y - x + 1];
	return max(dp[k][x],dp[k][y - (1LL << k) + 1]);
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++){
		l[i] = 0;
		r[i] = n + 1;
	}
	l[0] = 0; r[n + 1] = n + 1;
	
	tp = 0;
	for(LL i = 1;i <= n;i ++){
		while(tp && a[stk[tp]] < a[i]){
			r[stk[tp]] = i;
			tp --;
		}
		stk[++ tp] = i;
	}
	
	tp = 0;
	for(LL i = n;i >= 1;i --){
		while(tp && a[stk[tp]] < a[i]){
			l[stk[tp]] = i;
			tp --;
		}
		stk[++ tp] = i;
	}
	
	init();
	for(LL i = 1;i <= n;i ++){
		LL L = 0,R = l[i] - 1,mid,tmp = 0;
		while(L <= R){
			mid = (L + R) >> 1;
			if(query(mid,l[i] - 1) > a[i]){
				tmp = mid;
				L = mid + 1;
			}
			else R = mid - 1;
		}
		ll[i] = tmp;
	}
	for(LL i = 1;i <= n;i ++){
		LL L = r[i] + 1,R = n + 1,mid,tmp = n + 1;
		while(L <= R){
			mid = (L + R) >> 1;
			if(query(r[i] + 1,mid) > a[i]){
				tmp = mid;
				R = mid - 1;
			}
			else L = mid + 1;
		}
		rr[i] = tmp;
	}
	
	for(LL i = 1;i <= n;i ++){
		tot += a[i] * ((rr[i] - r[i]) * (i - l[i]));
		tot += a[i] * ((r[i] - i) * (l[i] - ll[i]));
	}
	
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 70656
def calc(s):
    n = s.split("+")
    sum = 0
    for i in range(len(n)):
        sum += int(n[i])
    return sum

def bfs(S,n,s):
    if n == len(S):
        # 数式sを計算する
        return calc(s)
    else:
        return bfs(S,n+1,s+"+"+S[n]) + bfs(S,n+1,s+S[n])

S=input()
s=S[0]
print(bfs(S,1,s))


Measured memory_bytes: 3060
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
bool is753(ll i){
  vi b(10,0);
  while(i>0){
    int k = i%10;
    b[k] = 1;
    i /= 10;
  }
  if(b[3]==1 && b[5]==1 && b[7]==1) return true;
  return false;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll N = IN();
  vi n753 = {3,5,7};
  stack<ll> s;
  rep(i,3) s.push(n753[i]);
  int cnt=0;
  while(!s.empty()){
    ll i = s.top(); s.pop();
    if(i<=N){
      if(is753(i)) cnt++;
      rep(j,3) { s.push(10*i+n753[j]); }
    }
  }
  cout << cnt << endl;
  return 0;
}


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


int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	long long ansa = 0;
	long long ansb = 0;

	if(a>=k){
		ansa = a-k;
		ansb = b;
	}else if(a+b>=k){
		ansa = 0;
		ansb = a+b-k;
	}else{
		ansa = 0;
		ansb = 0;
	}
	cout << ansa << " " << ansb << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n,k; cin>>n;
  string s; cin>>s;
  cin>>k;
  k--;
  char c=s[k];
  rep(i,0,n){
	if(s[i]!=c)s[i]='*';
  }
cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let l: usize = read();
    let edge: f64 = (l as f64) / 3.0; 
    println!("{}", edge*edge*edge);
}


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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)
		if (i * 27 / 25 == n) {
			cout << i << endl;
			return 0;
		}
	cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
	int H, W;
	cin >> H>>W;
	vector<string> A(H);
	for (int a = 0; a < H; a++) {
		cin>>A[a];
	}

	for (int a = 0; a < H+2; a++) {
		string str = "";
		for (int b = 0; b < W+2; b++) {
			if (a == 0 || a == H + 1) {
				str += "#";
			}
			else if (b==0||b==W+1) {
				str += "#";
			}
			else {
				str += A[a - 1][b - 1];
			}
		}
		cout << str<<endl;
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
const int max_n = 1e6;
ll h[max_n];
void solve(){
  ll mi = 1e10;
  for(int i=0 ; i<=n-k ; i++){
    ll mma = h[i+k-1];
    ll mmi = h[i];
    mi = min(mi, mma-mmi);
  }
  cout << mi << endl;
}

int main(){
  cin >> n >> k;
  for(int i=0 ; i<n ; i++){
    cin >> h[i];
  }
  sort(h, h+n);
  solve();
  return 0;
}


Measured memory_bytes: 1024
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])

Measured memory_bytes: 116656
#include <iostream>

using namespace std;
int main() {
  int i, j;
  cin >> i;
  long long int array[i-1], sum, max, min;
  sum = 0;
  for (j = 0; j < i ; j++){
    cin >> array[j];
    sum += array[j];
  }
  min = array[0];
  max = array[0];
  for (j = 0; j < i; j++) {
    if (min > array[j]) {
      min = array[j];
    } else if (max < array[j]) {
      max = array[j];
    }
  }
  cout << min << " " << max << " " << sum << endl;
}   

Measured memory_bytes: 1244
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  bool judge = true;

  for(int j=0;j<2;j++){
    if(!(c[0][j+1]-c[0][j]==c[1][j+1]-c[1][j] 
      && c[1][j+1]-c[1][j]==c[2][j+1]-c[2][j])){
      judge = false;
    }
  }
  if(judge) cout << "Yes" <<endl;
  else cout << "No" <<endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n;
ll x;
ll a[100010];
int main(void){
	cin >> n >> x;
	ll ret = 0;
	rep(i, n){
		cin >> a[i];
		if(a[i] > x){
			ret += a[i] - x;
			a[i] = x;
		}
	}

	rep(i, n - 1){
		if(a[i] + a[i + 1] > x){
			// printf("%d\n", a[i] + a[i + 1]);
			ret += (a[i] + a[i + 1]) - x;
			a[i + 1] -= (a[i] + a[i + 1]) - x;
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
int main(){
    ll n;
    cin>>a>>b>>c>>n;
    if(n%2==0){
        cout<<a-b<<endl;
    }
    else{
        cout<<b-a<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(void)
{

    std::string str;
    std::cin >> str;

    int sum = 0;
    for(int i=0; i<3; i++){
        if(str[i]=='1')sum++;
    };  

    std::cout << sum << std::endl;

    return 0;
}


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

int main(){
    
    string num;
    cin >> num;
    int ans=num.at(0)-'0';
    char op1,op2,op3;
    bool b=false;
    
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                ans=num.at(0)-'0';
                if(i){
                    op1='+';
                    ans+=num.at(1)-'0';
                }
                else{
                    op1='-';
                    ans-=num.at(1)-'0';
                }
                if(j){
                    op2='+';
                    ans+=num.at(2)-'0';
                }
                else{
                    op2='-';
                    ans-=num.at(2)-'0';
                }
                if(k){
                    op3='+';
                    ans+=num.at(3)-'0';
                }
                else{
                    op3='-';
                    ans-=num.at(3)-'0';
                }
                if(ans==7){
                    cout << num.at(0)-'0' << op1 << num.at(1)-'0' << op2 << num.at(2)-'0' << op3 << num.at(3)-'0' << '=' << 7 << endl;
                    b=true;
                }
                if(b) break;
            }
            if(b) break;
        }
        if(b) break;
    }
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<pair<int, int>> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  for(int i=0;i<n;++i) {
    cout << p[i].first << " " << p[i].second << endl;
  }
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<iostream>
#define int long long
const int maxn=1e5+5;
typedef long long ll; 
using namespace std;
string str;
bool check(string s){
	 string tmp=s;
	 reverse(s.begin(),s.end());
	 if(tmp==s){
	 	return true;
	 }
	 else{
	 	return false;
	 }
}
int tmp[3];
signed main(){
    double l;
    cin>>l;
    l/=3;
    double ans;
    ans=l*l*l;
    printf("%.6f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<((int)n);i++)
#define rep1(i,n) for(ll i=1;i<=((int)n);i++)
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
string s;
int n,k;
typedef long long ll;
const ll maxn=100005;
vector<char> change;
vector<int> num;
ll sum[maxn];
int main()
{
    while(cin>>n>>k>>s)
    {
        change.pb(s[0]);
        ll cnt=1;
        //meow(1)
        for(int i=1;i<n;i++)
        {
            if(s[i]!=change.back())
            {
                num.pb(cnt);
                cnt=1;
                change.pb(s[i]);
            }
            else cnt++;
            //meow(2)
        }
        num.pb(cnt);
        //for(auto i:change) cout<<i<<" ";cout<<"\n";
        //for(auto i:num) cout<<i<<" ";cout<<"\n";
        vector<int> pos;

        rep(i,change.size())
        {
            if(change[i]=='0')
            {
                pos.pb(i);
            }
            sum[i+1]=sum[i]+num[i];
            //meow(3)
        }
        //for(auto i:pos) cout<<i<<" ";cout<<"\n";
        //rep(i,change.size()) cout<<sum[i]<<" ";cout<<sum[change.size()]<<"\n";
        if(k>=pos.size())
        {
            cout<<n<<"\n";
            //meow(4)
            return 0;
        }
        ll l=0,r=k-1,ans=0;
        while(r<pos.size())
        {
            ll tmp=sum[pos[r]+1]-sum[pos[l]];
            if(pos[l]-1>=0) tmp+=num[pos[l]-1];
            if(pos[r]+1<num.size()) tmp+=num[pos[r]+1];
            ans=max(ans,tmp);
            //meow(5)
            l++;r++;
        }
        cout<<ans<<"\n";

    }


}


Measured memory_bytes: 2168
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long Q = scan.nextLong();
        long H = scan.nextLong();
        long S = scan.nextLong();
        long D = scan.nextLong();
        long N = scan.nextLong();

        H = Math.min(H, 2*Q);
        S = Math.min(S, 2*H);
        D = Math.min(D, 2*S);

        System.out.println((N/2)*D + (N%2)*S);
    }
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	c := 0
	for _, v := range a[:len(a)-1] {
		if x >= v {
			x -= v
			c++
		}
	}
	if x == a[len(a)-1] {
		c++
	}
	fmt.Println(c)
}


Measured memory_bytes: 1848
import kotlin.math.ceil

fun main() {
    val (n, k) = nextIntList()
    println(ceil(n.minus(1).toDouble().div(k - 1)).toInt())
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 36464
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		UnionFindTree uf = new UnionFindTree(N);
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			uf.union(a, b);
		}
		int ans = 1;
		for (int i = 0; i < N; i++) {
			if (ans < uf.size(i)) {
				ans = uf.size(i);
			}
		}
		System.out.println(ans);
	}

}

class UnionFindTree {

	private int[] parent;

	public UnionFindTree(int size) {
		this.parent = new int[size];
		for (int i = 0; i < size; i++) {
			this.parent[i] = -1;
		}
	}

	public boolean union(int x, int y) {
		int xRoot = root(x);
		int yRoot = root(y);

		if (xRoot == yRoot) {
			return false;
		}
		if (this.parent[xRoot] > this.parent[yRoot]) {
			int tmp = yRoot;
			yRoot = xRoot;
			xRoot = tmp;
		}
		this.parent[xRoot] += this.parent[yRoot];
		this.parent[yRoot] = xRoot;
		return true;
	}

	public int root(int i) {
		if (this.parent[i] >= 0) {
			return this.parent[i] = root(this.parent[i]);
		}
		return i;
	}

	public boolean same(int x, int y) {
		return root(x) == root(y);
	}

	public int size(int x) {
		return - this.parent[root(x)];
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 37804
import sys
input = sys.stdin.readline
S = input().rstrip()
T = input().rstrip()
S_len = len(S)
T_len = len(T)
index = -1
if S_len < T_len:
  print('UNRESTORABLE')
  sys.exit()
for i in range(S_len-T_len+1):
  for j in range(T_len):
    if not(S[i+j] == T[j] or S[i+j] == '?'):
      break
    if j == T_len-1:
      index = max(index,i+j)
if index == -1:
  print('UNRESTORABLE')
  sys.exit()
else:
  ans = ''
  for i in range(S_len):
    if S[i]=='?':
      if index-T_len+1 <= i <= index:
        ans += T[i-index+T_len-1]
      else:
        ans += 'a'
    else:
      ans += S[i]
print(ans)

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	rep(i, n-1){
		if(a[i] == i){
			swap(a[i], a[i+1]);
			ans++;
		}
	}
	if(a[n-1] == n-1) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
         
    int main() {
          int a;
          cin >> a;
          int b1,b2,b3;
      b1 = a % 10;
      b2 = ((a - b1) % 100)/10;
      b3 = a/100;
      cout << b1 + b2 + b3 << endl;
    }

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

int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (char c : s) {
		sum += c - '0';
	}
	if (sum % 9 == 0) {
		cout<<"Yes"<<endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
	
{	
	int a, b;
	char op;
	
	for (int i = 0; i < 10000; i++)
	{
		cin >> a >> op >> b;

		if (op == '?') break;

		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')
			cout << a / b << endl;
	}

	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main () {
    int t[1000] = {};
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for (int i = a; i < b; i++) t[i]++;
    int ans = 0;
    for (int i = c; i < d; i++) {
        if (t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

using T=long long int;
class cht {
	vector<pair<T, T>>ls;
	bool check(const pair<T, T>&l1, const pair<T, T>&l2, const pair<T, T>&l3)const {
		return 1.l*(l2.first - l1.first)*(l3.second - l2.second) >= 1.l*(l2.second - l1.second)*(l3.first - l2.first);
	}
public:
	cht() :ls() {
	}
	cht(vector<pair<T, T>>&vs) :ls() {
		sort(vs.begin(), vs.end());
		for (auto v : vs) {
			add(v);
		}
	}
	void add(const pair<T, T>&p) {
		while (ls.size() >= 2) {
			if (!check(ls[ls.size() - 2], ls[ls.size() - 1], p)) {
				break;
			}
			else {
				ls.pop_back();
			}
		}
		ls.emplace_back(p);
	}
	T f(int k, const T&x)const {
		return ls[k].first*x + ls[k].second;
	}
	T query(const T&x)const {
		int amin = 0;
		int amax = ls.size();
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			if (f(amid - 1, x) <= f(amid, x)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		return f(amin, x);
	}
};
int solve(int M,vector<T>&times) {
	vector<cht>chts(M+1);
	vector<vector<T>>memo(M+1,vector<T>(times.size()+1,-1e9));

	memo[0][0]=0;
	for (int use_bus_num = 0; use_bus_num < M; ++use_bus_num) {

		T sum=0;
		for (int i = 0; i < times.size(); ++i) {
			T t = times[i];
			if (i) {
				int pre_t=times[i-1];
				sum+=(t-pre_t)*i;
			}

			//傾きi (i,
			chts[use_bus_num].add(make_pair(i,memo[use_bus_num][i]+sum-i*t));

			memo[use_bus_num+1][i+1]=chts[use_bus_num].query(t)-sum;
		}
	}

	return -memo[M][times.size()];

}


int main() {
	int S,N,M;cin>>S>>N>>M;
	if (N <= M) {
		cout<<0<<endl;
		return 0;
	}
	vector<int>bus_stops(S);
	vector<T>times;
	for (int i = 0; i < S; ++i) {
		cin>>bus_stops[i];
	}
	for (int i = 0; i < N; ++i) {
		int a,b;cin>>a>>b;b--;
		times.push_back(a-bus_stops[b]);
	}
	sort(times.begin(),times.end());
	int k=times[0];
	for (auto &t : times) {
		t-=k;
	}
	int ans=solve(M,times);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 31832
#include <stdio.h>

int main(void){
    int a[8];
    for(int i=0;i<8;i++)scanf("%d",a+i);
    int s=a[0]*a[4]+a[1]*a[5]+(a[0]/10)*a[6]+(a[1]/20)*a[7];
    int t=a[2]*a[4]+a[3]*a[5]+(a[2]/10)*a[6]+(a[3]/20)*a[7];
    if(s>t) printf("hiroshi\n");
    else if(s<t)printf("kenjiro\n");
    else printf("even\n");
    return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<int> v(201);
    for(int i=1; i<=200; i++){
        v[i] = i * (i + 1) * (i + 2) / 6;
    }

    vector<int> dp1(1000010, 1e9);
    dp1[0] = 0;
    auto dp2 = dp1;

    for(int i=1; i<=200; i++){
        for(int j=0; j<=1000005; j++){
            if(j - v[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v[i]] + 1);

            if(v[i] % 2){
                if(j - v[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v[i]] + 1);
            }
        }
    }

    while(1){
        int n; cin>>n;
        if(n == 0) return 0;

        cout << dp1[n] << " " << dp2[n] << endl;
    }
}


Measured memory_bytes: 10612
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto a = lread();
    auto b = lread();
    writeln(6 - a - b);
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	S := nextBytes()

	if len(S)%2 == 1 {
		fmt.Println("No")
		return
	}

	for i := 0; i < len(S); i = i + 2 {
		if S[i] != 'h' || S[i+1] != 'i' {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

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

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int maxn=5+2e5;
int p[maxn],pf[maxn];
int main(){
	fio;
	int n;
	cin>>n;
	pf[0]=maxn;
	FOR(i,1,n){
		cin>>p[i];
		pf[i]=min(pf[i-1],p[i]);
	}
	int ans=0;
	FOR(i,1,n)
		if(p[i]<=pf[i-1])
			ans++;		
	cout<<ans<<endl;		
}

Measured memory_bytes: 1792
def solve(): # 071B - Not Found
    alphabet = []
    for i in range(26):
        alphabet.append(chr(97 + i))
    s = list(input())

    for j in s:
        if j in alphabet:
            alphabet.remove(j)
        else:
            pass

    if len(alphabet) == 0:
        print("None")
    else:
        print(alphabet[0])


solve()

Measured memory_bytes: 3956
x1, y1, x2, y2 = map(int, input().split())
x = x2 - x1
y = y2 - y1
x3 = x2 - y
y3 = y2 + x
x4 = x3 - x
y4 = y3 - y
print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  string d[100];
  for(int i = 0; i < m; i++) cin >> d[i];
  int W[10010] = {0}, E[10010] = {0};
  for(int i = 0; i < n; i++) {
    if(i) W[i+1] = W[i], E[i+1] = E[i];
    for(int j = 0; j < m; j++) {
      if(d[j][i] == 'W') W[i+1]++;
      else if(d[j][i] == 'E') E[i+1]++;
    }
  }
  int ans = 1<<25, idx = -1;
  for(int i = 0; i <= n; i++) {
    if(E[i]+W[n-1]-W[i] < ans) ans = E[i]+W[n-1]-W[i], idx = i;
  }
  cout << idx << " "<< idx+1 << endl;
  return 0;
}

Measured memory_bytes: 4628
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,w;
  cin>>n>>w;
  map<int,vector<int>> cnt;
  rep(i,n){
    int w,v;
    cin>>w>>v;
    cnt[w].pb(v);
  }
  vector<ll> sum[4];
  ll mn=cnt.begin()->X;
  rep(i,4){
    sum[i].pb(0);
    sort(rall(cnt[mn+i]));
    rep(j,cnt[mn+i].size()) sum[i].pb(sum[i][j]+cnt[mn+i][j]);
  }
  //rep(i,4) out(sum[i],1);
  ll re=0;
  rep(i,sum[0].size())rep(j,sum[1].size())rep(k,sum[2].size()){
    ll l=w-i*mn-j*(mn+1)-k*(mn+2);
    //out(i,j,k,l,1);
    if(l<0) break;
    l/=mn+3;
    MN(l,(ll)sum[3].size()-1);
    MX(re,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
  }
  cout<<re<<Endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    ll n;
    cin >> n;
    ll start_n = n;
    ll ans = 0;
    ll limit_i = (int)sqrt(n) + 1;
    for (int i = 2; i < limit_i; i++) {
        // if(n == 1) break;
        int count = 0;
        while (n % i == 0) {
            n /= i;
            count++;
        }
        int t = 1;
        while (count > 0) {
            count -= t;
            t++;
            if (count >= 0) ans++;;
        }
    }

    if(n > 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

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

		for (int i = 0; i < 3; i++) {
			String s = sc.next();
			System.out.print(s.charAt(i));
		}

		System.out.println();

		sc.close();

	}

}


Measured memory_bytes: 35624