akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

#define ENSYURITU 3.14159265358979323846
#define EPS (1e-7)

#define BUNKATU_NUM 1000

int main(void) {
	int n;
	while(scanf("%d",&n)==1 && n>0) {
		int i,j,k;
		double x[100],y[100];
		int max=0,now;
		for(i=0;i<n;i++)scanf("%lf,%lf",&x[i],&y[i]);
		for(i=0;i<n;i++) {
			for(j=0;j<BUNKATU_NUM;j++) {
				double cx,cy;
				cx=x[i]+cos(2*ENSYURITU*j/BUNKATU_NUM);
				cy=y[i]+sin(2*ENSYURITU*j/BUNKATU_NUM);
				now=0;
				for(k=0;k<n;k++) {
					if((cx-x[k])*(cx-x[k])+(cy-y[k])*(cy-y[k])<1.0+EPS)now++;
				}
				if(now>max)max=now;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 644
#include <stdio.h>
int main()
{
  int N;
  scanf("%d",&N);

  if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
  printf("pon");
  else if(N % 10 == 3)
  printf("bon");
  else
  printf("hon");

  return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>

using namespace std;

int main() {
	
	int a, b;
	
	while(cin >> a >> b) {
		
		double ans = 0;
		ans = a * b / 3.305785;
		cout << fixed << setprecision(6) << ans << "\n";
		
	}
	
	return 0;
}



Measured memory_bytes: 3264
a,b = map(int,input().split())

if a > 0 and b > 0:
    print("Positive")
elif a == 0 or b == 0:
    print("Zero")
elif a < 0 and b > 0:
    print("Zero")
elif a < 0 and b < 0:
    tmp = abs(a-b)
    if tmp % 2 == 0:
        print("Negative")
    else:
        print("Positive")


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

int N,M;
vector< vector<int> > v(60);
int V[60] = {0};
int count = 0;

int  dfs(int n , int k , int l){ //点nから辺(k,l)を使わずに探索
	V[n] = 1;
	count++;
	for(int i=0;i<v[n].size();i++){
		if(V[v[n][i]] != 1 && !(n == k && v[n][i] == l) && !(n == l && v[n][i] == k))
			dfs(v[n][i],k,l);
	}
}

/*bool check(){
	for(int i=1;i<N+1;i++){
		if(V[i] == 0) return false;
	}
	return true;
}
*/
int main(){
	while(cin >> N >> M && N > 1){
		int ans = 0;
		for(int i=1;i<M+1;i++){
			int a,b;
			cin >> a >> b;
			v[a].push_back(b);
			v[b].push_back(a);
		}
		for(int i=1;i<N+1;i++){
			for(int j=0;j<v[i].size();j++){
				dfs(i,i,v[i][j]);
				if(count != N) ans++;
				count = 0;
				for(int u=1;u<N+1;u++) V[u] = 0;
			}
		}
		cout << ans/2 << endl;
		for(int i=1;i<N+1;i++) v[i].clear();
	}
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) - 1 for x in input().split()]
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = b[a[0]]
for i in range(1, n):
	ans += b[a[i]]
	if a[i - 1] + 1 == a[i]:
		ans += c[a[i - 1]]
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int n, m, on = 0;
    cin >> n >> m;
    vector <int> bulb(m);
    loop(i, m) {
        int k; cin >> k;
        loop(j, k) {
            int bit; cin >> bit;
            bulb[i] ^= (1 << (bit - 1));
        }
    }
    loop(i, m) {
        int bit; cin >> bit;
        if (bit)
            on ^= (1 << i);
    }
    int ans = 0;
    loop(mask, (1 << n)) {
        int curon = 0;
        loop(bit, n)
            if (mask & (1 << bit))
                loop(i, m)
                    if (bulb[i] & (1 << bit))
                        curon ^= (1 << i);
        ans += (on == curon);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

using namespace std;

int v[100010];
int main() {
    
    int n,k,q;
    cin >> n >> k >> q;
    for (int i = 1; i <= n; ++i)
        v[i] = k - q;
    while(q--) {
        int x;
        cin >> x;
        v[x]++;
    }
    
    for (int i = 1; i <= n; ++i)
        puts(v[i] > 0 ? "Yes": "No");

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b){
    return a*b/gcd(a, b);
}
int main(){
	long long n, m;
	cin >> n >> m;
    vector<long long> a(n);
    for(long long &i : a){
        cin >> i;
        i /= 2;
    }

    long long l=a[0];
    for(int i=1; i<n; ++i){
        l = lcm(l,a[i]);
    }

    for(int i=0; i<n; ++i){
        if(l/a[i]%2==0){
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans=m/l;
    cout << (ans%2==0 ? ans/2 : (ans+1)/2 ) << endl;

}

Measured memory_bytes: 1024
N, Y =map(int, input().split())
c = 0
for n in range(N+1):
    if c == 1:
        break
    for m in range(N-n+1):
            l = N -n - m
            if Y ==( n*10000 + m *5000 + l *1000) and (n + m + l) == N:
                print(n , m , l)
                c = 1
                break
if c != 1:
    print(-1 , -1 , -1)

Measured memory_bytes: 65536
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-20;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[110000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int ret=0;
	for(int i=0;i<a-1;i++){
		if(in[i]=='O'&&in[i+1]=='X'){
			ret++;i++;
		}else if(in[i]=='X'&&in[i+1]=='O'){
			ret++;i++;
		}
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 2860
n = gets.to_i
p = gets.split(" ").map(&:to_i)
q = gets.split(" ").map(&:to_i)

def fact(n)
  (1..n).to_a.inject(1) { |f, i| f * i }
end

a = 0
z = (1..n).to_a
(0..(n - 2)).each do |i|
  a += z.index(p[i]) * fact(n - i - 1)
  z.delete(p[i])
end

b = 0
z = (1..n).to_a
(0..(n - 2)).each do |i|
  b += z.index(q[i]) * fact(n - i - 1)
  z.delete(q[i])
end

puts (a - b).abs

Measured memory_bytes: 1788
n,k = map(int,input().split())	
s=list(input())
a=0
b=0
c=0
for i in range(n-1):
    if(s[i]=="L" and s[i+1]=="R"):
        a+=1
    elif(s[i]=="R" and s[i+1]=="L"):
        b+=1
    else:
        c+=1
ans=c+min(a,b,k)*2
if( min(a,b,k)<k ):
    q=min(a,b,k)
    a-=q
    b-=q
    if((a==0 and b==1) or (a==1 and b==0)):
        ans+=1
    
print(ans)

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

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	int a, b, c;
	int sum=0;
	int count=0;
	vector <int> v;
	cin >> a >> b;
	for(int i=0; i<a; i++){
		cin >> c;
		sum += c;
		v.push_back(c);
	}
	for(int i=0; i<a; i++){
		if(v[i]>=(float)sum/(4*b)){
			count++;
		}
		if(count==b){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int a, b, x;

  cin>>x>>a>>b;

  cout<<(x - a) % b<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int n, x, i, j, k, m;
    
    for(i=0; ; i++){
        scanf("%d %d", &n, &x);
        if(n==0 && x==0)break;
    
        int c=0;
        for(j=1; j<=n; j++){
            for(k=j+1; k<=n; k++){
                for(m=k+1; m<=n; m++){
                    if(j+k+m==x)c++;
                }
            }
        }
        printf("%d\n", c);
    }
    
    return 0;
}

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

int main(){
	int a, b, c;

	cin >> a;
	cin >> b;
	cin >> c;

	if(a <= b){
		if(b <= c){
			cout << a << " " << b << " " << c << endl;
		}else if(a <= c){
			cout << a << " " << c << " " << b << endl;
		}else{
			cout << c << " " << a << " " << b << endl;
		}
	}else{
		if(b >= c){
			cout << c << " " << b << " " << a << endl;
		}else if(a >= c){
			cout << b << " " << c << " " << a << endl;
		}else{
			cout << b << " " << a << " " << c << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
N, W = map(int, input().split())

items = [list(map(int, input().split())) for _ in range(N)]
v_sum = sum([item[1] for item in items])

inf = float("inf")
dp = [inf for _ in range(v_sum + 1)]

dp[0] = 0
for i in range(N):
    for j in range(v_sum, -1, -1):
        if dp[j] > dp[j - items[i][1]] + items[i][0]:
            dp[j] = dp[j - items[i][1]] + items[i][0]

for i in range(v_sum, -1, -1):
    if dp[i] <= W:
        print(i)
        exit()


Measured memory_bytes: 50080
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;

  ll time = M * 1900 + (N - M) * 100;
  cout << ll(time * pow(2, M)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
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; }
const ll INF = 1e18;


#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

ll n;
vector<ll>a;

ll dp[100010][2];

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    rep(i,n)rep(j,2)dp[i][j]=-INF;
    dp[0][0]=a[0];
    
    for(int i=1;i<n;i++){
        //ひっくり返さない
        chmax(dp[i][0],dp[i-1][0]+a[i]);
        chmax(dp[i][0],dp[i-1][1]+a[i]);
        //ひっくり返す
        chmax(dp[i][1],dp[i-1][0]-a[i-1]*2-a[i]);
        chmax(dp[i][1],dp[i-1][1]+a[i-1]*2-a[i]);
    }
    ll ans = max(dp[n-1][1],dp[n-1][0]);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5608
#include <iostream>


using namespace std;

int n = 16;

struct obstacles {
  bool above;
  bool left;
  int value;
};



int main() {

  int input;
  cin >> input;

  for (int j = 0; j < input; j++) {
    int goalx, goaly;
    cin >> goalx >> goaly;
    
    obstacles grid[goalx + 1][goaly + 1];

    for (int rowi = 0; rowi <= goalx; rowi++) {
      for (int coli = 0; coli <= goaly; coli ++) {
	if (coli == 0) {
	  grid[rowi][coli].above = true;
	} else {
	  grid[rowi][coli].above = false;
	}
	if (rowi == 0) {
	  grid[rowi][coli].left =  true;
	} else {
	  grid[rowi][coli].left = false;
	}
	grid[rowi][coli].value = 0;
      }
    }

    
    int n_matatabi;
    
    cin >> n_matatabi;
    
     for (int m = 0; m < n_matatabi; m++) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      if (x1 == x2) { // vertical link |
	if (y1 > y2) {
	  grid[x1][y1].above = true;
	} else {
	  grid[x1][y2].above = true;
	} 
      }
      if (y1 == y2) { //horizontal link -
	if (x1 > x2) {
	  grid[x1][y1].left = true;
	} else {
	  grid[x2][y1].left = true;
	}
      }
      }

  
    
    for (int x = 0; x <= goalx; ++x) {
      for (int y = 0; y <= goaly; ++y) {
	if (x == 0 && y == 0) {
	  grid[0][0].value = 1;
	  continue;
	}
	int above = 0, left = 0;
	if (grid[x][y].above == false) {
	  above = grid[x][y-1].value;
	}
	if (grid[x][y].left == false) {
	  left = grid[x - 1][y].value;
	}
	grid[x][y].value = above + left;
      }
    }

 
    


    
    if (grid[goalx][goaly].value == 0) {
      cout << "Miserable Hokusai!" << endl;
    } else {
      cout << grid[goalx][goaly].value << endl;
    }
  }
}
  
 


  
  
  
 

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long MOD = 1000000007;

            int H = sc.nextInt();
            int W = sc.nextInt();
            int N = sc.nextInt();

            int M = Math.max(H, W);

            int ans = (N + M - 1) / M;
            System.out.println(ans);
        }
    }

}


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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int>base(m);
  for (int i = 0; i < m; i++){
    cin >> base.at(i);
  }
  vector<vector<int>>code(n,vector<int>(m));
  for (int i =0 ; i < n; i++){
    for (int j = 0; j <m; j++){
      cin >> code.at(i).at(j);
    }
  }
  int ans = 0;
   for (int i =0 ; i < n; i++){
     int  s =0;
    for (int j = 0; j <m; j++){
      s+= code.at(i).at(j)*base.at(j);
      
      }
     
    s+=c;
     if(s > 0)
       ans ++;
    }
   
  cout << ans << endl;
}
        
      
  
      
  
                         
  
      
      
   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,k,tot,head[N],nex[N<<1],to[N<<1],d[N],dep[N],son[N];
bool flag;
ll ans,f[N],invf[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll c(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
void dfs1(int u,int fa,int dis)
{
    for(int i=head[u];i;i=nex[i])
        if(to[i]!=fa)
        dfs1(to[i],u,dis+1),son[u]++;
}
void dfs2(int u,int fa)
{
    if(son[u]==0||flag) return;
    int sum=k-2;
    if(u==1) sum++;
    if(sum<son[u]) {flag=true;return;}
    ans=ans*f[son[u]]%mod*c(sum,son[u])%mod;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        dfs2(v,u);
    }
}
int main()
{
    f[0]=invf[0]=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=max(n,k);i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    dfs1(1,0,1);
    ans=k;
    dfs2(1,0);
    if(flag) printf("0\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 8320
#include <cstdio>
#include <algorithm>
using namespace std;

struct xx
{
	long long x;
	double V;
}a[233];

long long cmp(xx A,xx B)
{
	return A.x*B.V<B.x*A.V;
}

long long n,x,ans;

int main()
{
	//scanf("%lld%d%d%d",&)
	a[1].V=0.25,a[2].V=0.5,a[3].V=1,a[4].V=2;
	for (long long i=1;i<=4;++i)
	  scanf("%lld",&x),a[i].x=x;
	scanf("%lld",&n);
	sort(a+1,a+5,cmp);
	for (long long i=1;i<=4;++i)
	{
		long long tmp=n/a[i].V;
		ans+=tmp*a[i].x;
		n-=tmp*a[i].V;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
	    int a,b,k;
	    cin>>a>>b;
	    k=0;
	    if(a%2==0)
	    k++;
	    if(b%2==0)
	    k++;
	    if(k==0)
	    cout<<"Yes"<<endl;
	    else
	    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int b[7][7]={
    {7,8,18,0,1,2,3},
    {8,9,0,1,10,3,4},
    {18,0,17,2,3,16,5},
    {0,1,2,3,4,5,6},
    {1,10,3,4,11,6,12},
    {2,3,16,5,6,15,14},
    {3,4,5,6,12,14,13}
};

string solve(string s)
{
    set<int> cell;
    rep(i,1<<19)
    {
        int c = 0;
        rep(j,7)
        {
            int v = 0;
            rep(k,7) v |= (i>>b[j][k]&1)<<k;

            c |= (s[v]-'0')<<j;
        }
        cell.insert(c);
    }

    for(const auto &x:cell)
    {
        // dbg(x);
        if((x>>3&1) != (s[x]-'0')) return "no";
    }
    return "yes";
}

int main()
{
    string s;
    while(cin >>s,(s!="#")) cout << solve(s) << '\n';
    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

int main() {
    ll n, k, r, s, p;
    string t;

    cin >> n >> k >> r >> s >> p >> t;
    vector<list<char>> groups(k, list<char>(0));
    map<char, ll> score;
    score.insert(make_pair('r', p));
    score.insert(make_pair('s', r));
    score.insert(make_pair('p', s));
    // cerr << "r =" << r << ", s = " << s << ", p = " << p << endl;
    // cerr << "r =" << score.at('r') << ", s = " << score.at('s') << ", p = " << score.at('p') << endl;
    ll j = 0;
    for (ll i = 0; i < n; ++i) {
        groups[j].push_back(t[i]);
        j = (j + 1) % k;
    }

    //for (ll i = 0; i < k; ++i) {
    //    cerr << i << ": ";
    //    for (auto iter = groups[i].begin(); iter != groups[i].end(); ++iter) {
    //        cerr << *iter;
    //    }
    //    cerr << endl;
    //}

    ll result = 0;
    for (ll i = 0; i < k; ++i) {
        char prev = '*';
        char cur = '*';
        ll count = 0;
        for (auto iter = groups[i].begin(); iter != groups[i].end(); ++iter) {
            cur = *iter;
            if (prev != cur && prev != '*') {
                //cerr << "count is " << count << ", score is " << score.at(prev) << endl;
                //cerr << " ((count /2) + (count % 2)) = " <<  ((count /2) + (count % 2)) << endl;
                result += ((count /2) + (count % 2)) * score.at(prev);
                count = 1;
            } else {
                ++count;
            }
            prev = cur;
        }
        if (cur != '*') {
            // cerr << "count is " << count << ", score is " << score.at(cur) << endl;
            // cerr << " ((count /2) + (count % 2)) = " <<  ((count /2) + (count % 2)) << endl;
            result += ((count /2) + (count % 2)) * score.at(cur);
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 4864
from collections import deque

h, w = map(lambda x: int(x)+2, input().split())
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

# 全通りのstart位置から探索する
start = []
for i in range(h):
    for j in range(w):
        if MAZE[i][j] == ".":
            start.append((i, j))


INF = 10**18


def bfs(start):
    i, j = start
    dist = [[INF] * w for _ in range(h)]
    dist[i][j] = 0
    next_v = deque([start])
    while next_v:
        i, j = next_v.popleft()
        direction = [(-1, 0), (0, 1), (1, 0), (0, -1)]
        for di, dj in direction:
            x, y = i+di, j+dj
            if MAZE[x][y] == "#":
                continue
            if dist[x][y] <= dist[i][j] + 1:
                continue
            dist[x][y] = dist[i][j] + 1
            next_v.append((x, y))
    return dist


ans = 0
for ls1 in start:
    r = bfs(ls1)
    for ls2 in start:
        ans = max(ans, r[ls2[0]][ls2[1]])

print(ans)


Measured memory_bytes: 3316
N=int(input())
A=[int(input()) for i in range(N)]
Max=0
ans=0
for i in range(N):
  if Max+1<A[i]:
    if A[i]%(Max+1):
      ans+=A[i]//(Max+1)
      A[i]=1
    else:
      ans+=A[i]//(Max+1)-1
      A[i]=1
  Max=max(Max,A[i])
  
print(ans)

Measured memory_bytes: 51288
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;

int main(){
	int n,W;
	scanf("%d%d",&n,&W);
	vector<ll> dp(W+1);
	for(int i = 0; i < n; i++){
		int value, weight;
		scanf("%d%d",&weight, &value);

		for(int already_weight = W - weight; already_weight >= 0; already_weight--){
			dp[already_weight + weight] = max(dp[already_weight + weight], dp[already_weight] + value);
		}
	}
	ll ans = 0;
	for(int i = 1; i <= W; i++)
		ans = max(ans, dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int b = k + 1; b <= n; b++) {
		ans += (n / b)*(b - k) + max(0, (n%b) - k + 1);
	}
	if (k == 0) ans -= n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(n-1):
  if l[i]==i+1:
    c+=1
    tmp=l[i+1]
    l[i+1]=l[i]
    l[i]=tmp
if l[-1]==n:
  c+=1
print(c)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
 
using namespace std ;

const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pair<pll,lli>,null_type,less<pair<pll,lli>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 1000005

int main()
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  

    lli a,b,c;
    cin>>a>>b>>c;

    set<lli> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    if(s.size() == 2) cout<<"Yes";
    else cout<<"No";
}
        
 

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

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

int main(){

    int h, n; cin >> h >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        h-=a[i];
    }

    if(h>0) cout << "No" <<endl;
    else cout << "Yes" << endl;
     return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;
vector <point> pl;
 
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}
 
point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

namespace std{
  bool operator < (const point &a,const point &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};

vector<point> andrewScan(vector<point> &t){
  int N=t.size(),C=0;
  vector<point> R(N);
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)C--;
    R[C++]=t[i];
  }
  vector<point> res(C);
  for(int i=0;i<C;i++)res[i]=R[i];
  return res;
}
 
vector<point> ConvexHull2(vector<point> &t){
  sort(t.begin(),t.end());
  vector<point> u=andrewScan(t);
  reverse(t.begin(),t.end());
  vector<point> l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}

vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return ConvexHull2(res);
}
 
double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}
 
 
int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));
 
  int m;
  cin>>m;
  for(int i=0,c,d;i<m;i++){
    cin>>c>>d;
    point a,b;
    a=point(c,d);
    cin>>c>>d;
    b=point(c,d);
    vector<point> res=ConvexCut(pl,a,b);
    printf("%.8f\n",get_area(res));
  }
 
 
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    string s;
    string t;
    cin >> s >> t;
    int ans = 0;
    REP(i,3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import Foundation

func check(t: [[Int]], d: [Bool], x: Int) -> Bool {
  var rst = [Int](repeating: 0, count: t[0].count)
  for i in 0..<t.count {
    if !d[i] { continue }
    for j in 0..<t[i].count {
      rst[j] += t[i][j]
    }
  }
  let ans = rst.contains { x > $0 }
  return !ans
}

func calc(c: [Int], d: [Bool]) -> Int {
  return c.enumerated().reduce(0) { (a, e) in
    return d[e.0] ? a + c[e.0] : a
  }
}

if let s = readLine() {
  let ss = s.split(separator: " ").map { Int($0)! }
  let n = ss[0] // 参考書数
  let m = ss[1] // アルゴリズム数
  let x = ss[2] // 目標理解度
  var c = [Int](repeating: 0, count: n)
  var a = [[Int]](repeating: [Int](repeating: 0, count: m), count: n)
  for i in 0..<n {
    if let aa = readLine() {
      let t = aa.split(separator: " ").map { Int($0)! }
      c[i] = t[0]
      for j in 1..<m+1 {
        a[i][j-1] = t[j]
      }
    }
  }
  
  let max: Int = Int(truncating: NSDecimalNumber(decimal: pow(2, n)))
  var ans: [Int] = []
  for i in 0..<max {
    var b = String(i, radix: 2)
    for _ in 0..<n-b.count {
      b = "0" + b
    }
    let d = b.enumerated().map { $1 == "1" }
    if check(t: a, d: d, x: x) {
      ans.append(calc(c: c, d: d))
    }
  }
  
  if let min = ans.min() {
    print(min)
  } else {
    print(-1)
  }
}


Measured memory_bytes: 13856
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A,B;
    cin >> A >> B;
    int X = __gcd(A,B);
    int Y = X;
    int ans = 1;
    for(int i = 2; i*i <= X; i++) {
        if(Y%i == 0) {
            while(Y%i == 0) {
                Y/=i;
            }
            ans++;
        }
    }
    if(Y != 1) {
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
n,k,*v=map(int,open(0).read().split())
motimono=[]
ans=[]
v*=2
for j in range(1,min(n,k)+1):
    for i in range(n-j,n+1):
        motimono=v[i:i+j]
        ans.append(sum(motimono))
        motimono.sort(reverse=1)
        for i in range(min(k-j,j)):
            del motimono[-1]
            ans.append(sum(motimono))
print(max(ans))


Measured memory_bytes: 4904
import java.util.*;

public class Main {

    public static void dfs(int color, int index, List<Edge> es, ArrayList<Integer> colors,ArrayList<ArrayList<Edge>> nodes){
       if(colors.get(index) != 100)
           return;
       colors.set(index,color);
       ArrayList<Edge> edges = nodes.get(index);
       for(int i = 0;i < edges.size();i++){
           Edge e = edges.get(i);
           if(e == null)
               break;
           if(e.from == index) {
               if (e.weight % 2 == 0){
                   dfs(color, e.to, es, colors,nodes);
               }
               else{
                   dfs(1 - color, e.to,es, colors,nodes);
               }
           }
           else if(e.to == index){
               if(e.weight % 2 == 0){
                   dfs(color,e.from,es,colors,nodes);
               }
               else{
                   dfs(1 - color,e.from,es,colors,nodes);
               }
           }
       }
    }

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Edge> edges = new ArrayList<>();
        ArrayList<ArrayList<Edge>> nodes = new ArrayList<>();

        for(int j = 0;j < N + 1;j++)
            nodes.add(new ArrayList<>());

        for(int i = 0;i < N - 1; i++) {
            int u, v;
            long w;
            u = sc.nextInt() - 1;
            v = sc.nextInt() - 1;
            w = sc.nextLong();

            Edge e = new Edge(u,v,w);
            nodes.get(u).add(e);
            nodes.get(v).add(e);

            edges.add(e);
        }
        ArrayList<Integer> colors = new ArrayList<>(Collections.nCopies(N + 1,100));
        dfs(0,edges.get(0).from,edges,colors,nodes);


        for(int i = 0; i < N;i++)
            System.out.println(colors.get(i));
    }



  public static class Edge{
        int from;
        int to;
        long weight;

        Edge(int f,int t,long w){
            from = f;
            to = t;
            weight = w;
        }
    }






    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}





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

int main() {
    int64_t n, k;
    cin >> n >> k;
    int64_t ans = pow(n / k, 3);
    if (k % 2 == 0) ans += pow((n + k / 2) / k, 3);
    cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define mod 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define dbg(x) cout<<#x<<" = "<<x<<'\n';

ll isPrime(ll x) {ll i, flag = 1; if(x == 0 || x == 1) flag = 0; for(i = 2; i<=sqrt(x); i++) { if(x%i == 0) {flag = 0; break;}} return flag;}
ll power(ll x, ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;

    if(n%x==0)
    cout<<(n/x)*t;
    else
    cout<<((n/x)+1)*t;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int tc=1;
  //cin>>tc;
  while(tc--)
  {
    solve();
  }
  return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli h,w;
	cin>>h>>w;

	if(w==1 || h==1){
		cout<<1<<endl;
		return 0;
	}

	lli aa = ((h+1)/2)*((w+1)/2);
	lli bb = (h/2)*(w/2);

	cout<<aa+bb<<endl;


	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
lst = []
for i in range(h):
    lst.append(list(input()))

R = [[0]*w for _ in range(h)]
L = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        

for i in range(h):
    for j in range(w-1, -1, -1):
        if lst[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1            


for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in range(h-1, -1, -1):
    for j in range(w):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

ans = 0
x = [[0]*w for _ in range(h)]
for i in range (h):
    for j in range(w):
        x[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
    ans = max(ans, max(x[i]))
print(ans) 

Measured memory_bytes: 340872
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n;
	cin>>n;
	int x=n%10;
	if(x==3)cout<<"bon";
	else if(x==0 || x==1 || x==6 || x==8)cout<<"pon";
	else cout<<"hon";	

}

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

Measured memory_bytes: 3604
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop
from collections import defaultdict

x, y, z, k = li()
a = list(li())
b = list(li())
c = list(li())

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

amax = a[0]
bmax = b[0]
cmax = c[0]

acnt = 0
bcnt = 0
ccnt = 0

heap = [(-amax - bmax - cmax, acnt, bcnt, ccnt)]
ans = []

visited = defaultdict(int)
visited[(0,0,0)] = 1

for _ in range(k):
    cur, acnt, bcnt, ccnt = heappop(heap)

    if acnt < len(a)-1:
        if not visited[(acnt+1, bcnt, ccnt)]:
            heappush(heap, (-a[acnt+1]-b[bcnt]-c[ccnt], acnt+1, bcnt, ccnt))
            visited[(acnt+1, bcnt, ccnt)] = 1

    if bcnt < len(b)-1:
        if not visited[(acnt, bcnt+1, ccnt)]:
            heappush(heap, (-a[acnt]-b[bcnt+1]-c[ccnt], acnt, bcnt+1, ccnt))
            visited[(acnt, bcnt+1, ccnt)] = 1

    if ccnt < len(c)-1:
        if not visited[(acnt, bcnt, ccnt+1)]:
            heappush(heap, (-a[acnt]-b[bcnt]-c[ccnt+1], acnt, bcnt, ccnt+1))
            visited[(acnt, bcnt, ccnt+1)] = 1

    ans.append(-cur)

for ansi in ans:
    print(ansi)


Measured memory_bytes: 5244
<?php
$input = fgets(STDIN, 4096);
$numbers = explode(' ', $input);
$prev = 0;
$output = 'Yes';
foreach($numbers as $number) {
    $number = intval($number);
    if ($number <= $prev) {
        $output = 'No';
        break;
    }
    $prev = $number;
}
print($output);
?>

Measured memory_bytes: 15340
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 20
#define MAXM 20
#define MAXS 1049000
#define MO 1000000007
using namespace std;
int opt[MAXN+5][MAXM+5];
int dp[2][MAXN+5][MAXS+5];
int N,M,K;
int main()
{
	memset(opt,-1,sizeof(opt));
	scanf("%d %d %d",&N,&M,&K);
	N--;
	int A,B,C;
	for(int i=1;i<=K;i++)
	{
		scanf("%d %d %d",&A,&B,&C);
		opt[A][B]=C;
	}
	dp[0][N][0]=1;
	int all=(1<<N),id;
	for(int i=1;i<=M;i++)
	{
		id=i%2;
		for(int s=0;s<all;s++)
			dp[id][0][s]=dp[!id][N][s];
		for(int j=1;j<=N;j++)
		{
			for(int s=0;s<all;s++)
			{
				if(((s&(1<<(j-1)))&&opt[i][j]==0)||dp[id][j-1][s]==0)
					continue;
				if(opt[i][j]!=0)
				{
					int ri=s/(1<<(j-1));
					int low=(ri&(-ri));
					int news=s;
					if(ri!=0)
						news-=(low<<(j-1));
					news+=(1<<(j-1));
					dp[id][j][news]=(1LL*dp[id][j][news]+1LL*dp[id][j-1][s])%MO;
				}
				if(opt[i][j]!=1&&((s&(1<<(j-1)))==0))
				{
					int news=s;
					if(s&(1<<(j-1)))
						news-=(1<<(j-1));
					dp[id][j][news]=(1LL*dp[id][j][news]+1LL*dp[id][j-1][s])%MO;
				}
			}
		}
		memset(dp[!id],0,sizeof(dp[!id]));
	}
	int ans=0;
	for(int s=0;s<all;s++)
		ans=(1LL*ans+1LL*dp[M%2][N][s])%MO;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 205056
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();

        for (int a=0; a<=N; a++) {
            for (int b=0; b<=N-a; b++) {
                int c = N - a - b;
                int total = a * 10000 + b * 5000 + c * 1000;
                if (total == Y) {
                    System.out.println(a + " " + b + " " + c);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

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

vector<string> transpose(vector<string> a){

  vector<string> ans(a.at(0).size());
  
  for (int i = 0; i < a.at(0).size(); i++){
    for (int j = 0; j < a.size(); j++){
      ans.at(i).push_back(a.at(j).at(i));
    }
  }

  return ans;
}

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<string> grid(h);
  for (int i = 0; i < h; i++){
    cin >> grid.at(i);
  }
  
  vector<string> temp(0);
  for (int i = 0; i < h; i++){
    if(grid.at(i).find('#')!=string::npos){
      temp.push_back(grid.at(i));
    }
  }

  vector<string> trans(0);
  trans=transpose(temp);

  vector<string> temp2(0);
  for (int i = 0; i < trans.size(); i++){
    if(trans.at(i).find('#')!=string::npos){
      temp2.push_back(trans.at(i));
    }
  }

  vector<string> ans(0);
  ans=transpose(temp2);
  
  for (int i = 0; i < ans.size(); i++){
    cout << ans.at(i) << endl;
  }

}

Measured memory_bytes: 3596
#include<iostream>
#include<queue>
#include<string.h>
#include<vector>
#include<fstream>
using namespace std;

class state{
public:
	int now,cost;
	state(int now,int cost):now(now),cost(cost){}
};

bool operator <(state a,state b){
	return a.cost>b.cost;
}

int n,m,s,g1,g2;

int cost_s[101],cost_g1[101],cost_g2[101];

int edge[101][101];
int edge_rev[101][101];

int main()
{	std::ofstream ofs( "ans.txt" );
	while(cin>>n>>m>>s>>g1>>g2 && n!=0){
		int ans=1000000;
		for(int i=0;i<101;i++){
			cost_s[i]=cost_g1[i]=cost_g2[i]=10000000;
			for(int j=0;j<101;j++){
				edge[i][j]=10000000;
				edge_rev[i][j]=100000000;
			}
		}

		
		for(int i=0;i<m;i++){
			int in,out,c; cin>>in>>out>>c;
			edge[in][out]=c;
			edge_rev[out][in]=c;
		}


		priority_queue<state> Q;
		Q.push(state(s,0));
		while(!Q.empty()){
			state info=Q.top();
			Q.pop();
			if(info.cost>=cost_s[info.now]) continue;
			cost_s[info.now]=info.cost;
			for(int i=0;i<101;i++){
				Q.push(state(i,info.cost+edge[info.now][i]));
			}
		}
		
		Q.push(state(g1,0));
		while(!Q.empty()){
			state info=Q.top();
			Q.pop();
			if(info.cost>=cost_g1[info.now]) continue;
			cost_g1[info.now]=info.cost;
			for(int i=0;i<101;i++){
				Q.push(state(i,info.cost+edge_rev[info.now][i]));
			}
		}

		Q.push(state(g2,0));
		while(!Q.empty()){
			state info=Q.top();
			Q.pop();
			if(info.cost>=cost_g2[info.now]) continue;
			cost_g2[info.now]=info.cost;
			for(int i=0;i<101;i++){
				Q.push(state(i,info.cost+edge_rev[info.now][i]));
			}
		}

		for(int i=0;i<101;i++){
			ans=min(ans,cost_s[i]+cost_g1[i]+cost_g2[i]);
		}
		cout<<ans<<endl;
		ofs<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
# -*- coding: utf-8 -*-
"""
D - Candy Distribution
https://atcoder.jp/contests/abc105/tasks/abc105_d

"""
import sys


from itertools import accumulate

def solve(N, M, candies):
    acc = [0] + list(accumulate(candies))
    d = dict()
    for a in acc:
        d[a%M] = d.get(a%M, 0) + 1

    ans = 0
    for k, v in d.items():
        if v > 1:
            ans += (v-1) * v // 2
    return ans


def main(args):
    N, M = map(int, input().split())
    candies = [int(a) for a in input().split()]
    ans = solve(N, M, candies)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 17748
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a.begin(), a.end());
	int x = a[n / 2 - 1];
	int y = a[n / 2];
	rep(i, n) {
		if (b[i] <= x) {
			cout << y << endl;
		}
		else {
			cout << x << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;


int main()
{
    ciosup;
    string s;
    cin >> s;
    int n = s.size();
    vint dwall;
    vint ans(n,0);
    char now = s[0];
    REP(i, n)
    {
        if (now != s[i]){
            dwall.eb(i - 1);
        }
        now = s[i];
    }
    REP(i,dwall.size()){
        if (i % 2 == 0){
            int len = dwall[i] - (i == 0 ? 0 : dwall[i - 1] + 1) + 1;
            int len2 = (i == dwall.size() - 1 ? n - 1 : dwall[i + 1]) - dwall[i];
            if (len % 2 == 0){
                ans[dwall[i]] += len / 2;
                ans[dwall[i]+1] += len / 2;
            }else
            {
                ans[dwall[i]] += (len / 2) + 1;
                ans[dwall[i] + 1] += len / 2;
            }
            if (len2 % 2 == 0)
            {
                ans[dwall[i]] += len2 / 2;
                ans[dwall[i] + 1] += len2 / 2;
            }
            else
            {
                ans[dwall[i]] += (len2 / 2);
                ans[dwall[i] + 1] += len2 / 2 + 1;
            }
        }
    }
    REP(i,n-1){
        cout << ans[i] << " ";
    }
    cout << ans[n - 1] << endl;
}

Measured memory_bytes: 1480