akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] resultArray = str.split(" ");

		int W = Integer.parseInt(resultArray[0]);
		int H = Integer.parseInt(resultArray[1]);
		int x = Integer.parseInt(resultArray[2]);
		int y = Integer.parseInt(resultArray[3]);
		int r = Integer.parseInt(resultArray[4]);

		if ((x - r < 0) || (W < x + r) || (y - r < 0) || (H < y + r)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 24408
n,A,B,C=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
ans=10**9+7
for i in range(4**n):
    k=i
    a=0
    b=0
    c=0
    cnt=[0,0,0]
    for j in range(n):
        if k%4==1:
            a+=l[j]
            cnt[0]+=1
        elif k%4==2:
            b+=l[j]
            cnt[1]+=1
        elif k%4==3:
            c+=l[j]
            cnt[2]+=1
        k=k//4
    if cnt[0]>0 and cnt[1]>0 and cnt[2]:
        mp=abs(A-a)+abs(B-b)+abs(C-c)+max(cnt[0]*10-10,0)+max(cnt[1]*10-10,0)+max(cnt[2]*10-10,0)
        if mp<ans:
            ans=mp
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll MAX_N = 1e5;
constexpr ll INF = 1e18;

unordered_map<ll, ll> G[MAX_N + 1];

vector<ll> dijkstra(ll N, ll K) {
    vector<ll> dist(N + 1, INF);
    dist[K] = 0;

    priority_queue<p> que;
    que.push(p(K, 0));

    while(!que.empty()) {
        auto token = que.top(); que.pop();
        auto node = token.first;
        auto cost = token.second;
        for (auto g : G[node]) {
            auto to = g.first;
            auto c = g.second;
            if (dist[to] > dist[node] + c) {
                dist[to] = dist[node] + c;
                que.push(p(to, dist[to]));
            }
        }
    }

    return dist;
}

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

    ll N;
    cin >> N;

    for (ll i = 0; i < N - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        G[a][b] = c;
        G[b][a] = c;
    }

    ll Q, K;
    cin >> Q >> K;

    auto dist = dijkstra(N, K);

    vector<ll> ans;

    for (ll i = 0; i < Q; i++) {
        ll x, y;
        cin >> x >> y;
        ans.push_back(dist[x] + dist[y]);
    }

    for (auto a : ans) {
        cout << a << endl;
    }

    return 0;
}



Measured memory_bytes: 19956
#include <stdio.h>
int main(){
  int S[100000],T[500],S_num,T_num,cnt = 0,tmp = -1;
  scanf("%d",&S_num);
  for(int i = 0; i < S_num; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&T_num);
  for(int i = 0; i < T_num; i++){
    scanf("%d",&T[i]);
  }
  for(int i = 0; i < T_num;i++){
    for(int j  = 0; j < S_num; j++){
      if(T[i] == S[j]){
	if(S[j] != tmp){
	  cnt++;
	  tmp = S[j];
	}
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}



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

int main(){
  int N ;
  cin >> N ; 
  long long A ;
  cin >> A ; 
  long long  ans = A  ;  
  for(int i = 1 ; i < N ; i++){
    long long B ; 
    cin >> B ; 
    ans = lcm(ans,B) ; 
  }
  
  cout << ans << endl ; 
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

int main(void)
{
    char a[100][101],b[100][101];
    int h,w,t,i,j;
    scanf("%d%d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
		strcpy(b[i],a[i]);
	}
    for(i=0;i<h;i++){
        t=0;
        for(j=0;j<w;j++)if(a[i][j]=='#')t=1;
        if(1>t)for(j=0;j<w;j++)b[i][j]='0';
    }
    for(i=0;i<w;i++){
        t=0;
        for(j=0;j<h;j++)if(a[j][i]=='#')t=1;
        if(t==0)for(j=0;j<h;j++)b[j][i]='0';
    }
    for(i=0;i<h;i++){
        t=0;
        for(j=0;j<w;j++){
            if(b[i][j]=='0')continue;
            else if(a[i][j]=='#')t=1;
            printf("%c",a[i][j]);
        }
        if(t>0)puts("");
    }
    return 0;
}

Measured memory_bytes: 128
N,M,C = map(int,input().split())
B =  [0]*M
A = [[0]*M]*N

B = list(map(int,input().split()))

for i in range(N):
    A[i] = list(map(int,input().split()))

cnt =0

for i  in range(N):
    temp =int(0)
    for j in range(M):
        temp += A[i][j] * B[j]
        
    if temp+C  >0:
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; 
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct BellmanFordMax {
	BellmanFordMax() {}
	BellmanFordMax(int n) { init(n); }
	vector<vector<pair<int, int>>> E; int N;
	void init(int n) { N = n; E.resize(0); E.clear(); E.resize(n); }
	void add(int a, int b, int c) { E[a].push_back({ b, c }); }
	vector<ll> solve(int s) {
		vector<ll> res(N, -infl);
		res[s] = 0;

		rep(i, 0, N - 1) {
			rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
				chmax(res[p.first], res[cu] + p.second);
			}
		}

		vector<bool> pos(N);
		rep(i, 0, N) {
			rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
				if (chmax(res[p.first], res[cu] + p.second)) {
					pos[p.first] = true;
				}
				if (pos[cu]) pos[p.first] = true;
			}
		}

		rep(cu, 0, N) if (pos[cu]) res[cu] = infl;

		return res;
	}
};

int N, M, P;
vector<pair<int, int>> E[2500];
//---------------------------------------------------------------------------------------------------
int main() {
	cin >> N >> M >> P;

	BellmanFordMax bf(N);

	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		bf.add(a, b, c - P);
	}

	ll ans = bf.solve(0)[N - 1];

	if (ans == infl) ans = -1;
	else if (ans < 0) ans = 0;

	cout << ans << endl;
}

Measured memory_bytes: 3884
#include <cstdio>

int n;

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


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<ll> h(n);
    for(auto &e: h) cin >> e;

    ll r = 0;
    ll c = 0;
    for(ll i=0; i<n-1; i++) {
        if(h[i] >= h[i+1])
            c++;
        else
            r = max(r, c), c = 0;
    }
    r = max(r, c), c = 0;
    cout << r << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int a[110000];
    cin>>a[0];
    rep2(i,1,n-1){
        char c;cin>>c;
        cin>>a[i];
        if(c=='-')a[i]*=-1;
    }
    ll sum=0,pos=0;
    vector<ll> v;
    while(pos<n){
        while(a[pos]>0&&pos<n){
            sum+=a[pos];
            pos++;
        }
        v.pb(sum);
        if(pos<n) v.pb(a[pos]);
        sum=0;pos++;
    }
    ll m=1e18,temp=0;
    pos=1;
    while(pos*2<=v.size()){
        temp-=v[pos*2-1];
        m=min(m,temp+v[pos*2]);
        pos++;
    }
    rep(i,n){
        sum+=abs(a[i]);
    }
    ll M=0;
    rep(i,v.size()){
        if(i%2) M-=v[i]; 
    }
    m=min(M,m);
    cout<<sum-2*m;
    return 0;
}



Measured memory_bytes: 2804
H,W = map(int,input().split())
mat = []
for i in range(H):
    a = list(input())
    if '#' in a:
        mat.append(a)
answ = []
for i in range(W):
    flag = False
    for j in range(len(mat)):
        if mat[j][i] == '#':
            flag = True
    if flag:
        answ.append(i)
for i in range(len(mat)):
    ans = [mat[i][j] for j in answ]
    print(''.join(ans))
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int num = 0, count = 0, ans = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  
  cin >> a;
  
  if(a >= 82){
    cout << "No" << endl;
  }else{
    for(i = 1; i <= 9; i++){
      for(j = 1; j <= 9; j++){
        b = i * j;
        if(b == a){
          f++;
        }
      }
    }
      if(f == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  } 
  }
}
  


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

vector<int> v[N];

int col[N],sz[N];

ll ans[N],cur_size[N];

int dfs_util(int node,int par)
{
	sz[node]=1;

	for(int it:v[node])
	if(it!=par)
	sz[node]+=dfs_util(it,node);

	return sz[node];
}

void dfs(int node,int par)
{
	ll n=cur_size[col[node]];

	ll contribution=0,sum=0;

	contribution = (n-sz[node]+1)*(sz[node]); //paths form up and down or both
 
	for(int it:v[node])
	if(it!=par)
	{
		//make the problem(temporarily) for counting new paths of col[node] 
		//as a new problem for the subtree of it, that is make the size of graph as sz[it],
		// not the original 'n'.

		cur_size[col[node]] = sz[it];

		dfs(it,node);

		contribution += sum*sz[it]; //paths from subtree to subtree

		sum+=sz[it];
	}

	ans[col[node]] += contribution;

	//now never take paths entering the subtree of node for col[node],
	//as we have considered all such paths.
	
	cur_size[col[node]] =  n-sz[node];
}

int main()
{
	int n;

	scn(n);

	rep(i,1,n+1)
	scn(col[i]),cur_size[i]=n;

	rep(i,0,n-1)
	{
		int a,b;

		scn(a); scn(b);

		v[a].pb(b); v[b].pb(a);
	}

	dfs_util(1,-1);

	dfs(1,-1);

	rep(i,1,n+1)
	lpriln(ans[i]);

    return 0;
}

Measured memory_bytes: 41104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  int ans1 = b * (n / a), ans2 = d * (n / c);
  if(n % a != 0) ans1 += b;
  if(n % c != 0) ans2 += d;
  cout << min(ans1, ans2) << endl;
  return 0;
}




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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
//#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  998244353;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}


int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,k;
    cin>>n>>k;
    ll h[100005] = {0};

    for(int i=1;i<=n;i++)cin>>h[i];
    ll dp[100005] = {0};
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
    	dp[i] = INF;
    	for(int j=1;j<=k && i-j>=1;j++)
    	{
    		dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
    	}
    }

    cout << dp[n] << "\n";
	return 0;
}

Measured memory_bytes: 1792
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    sort(all(s));
    int ans = 1;
    for(int i = 0;i < n-1;i++){
        if(s[i] != s[i+1]){
            ans ++;
        }
    }
    cout << ans;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, d, x;
  cin >> n >> d >> x;
  int ans = x;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    ans += (d-1)/a + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' << endl;
  }
  else if(b=='T'){
    cout << 'A' << endl;
  }
  else if(b=='G'){
    cout << 'C' << endl;
  }
  else {
    cout << 'G' << endl;
  }
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

#include<bits/stdc++.h>
/*
std::vector<bool> sieve;
std::vector<int> primes;

void eratosthenes(int maximum){
	sieve = std::vector<bool>(maximum+1);
	sieve[0]=sieve[1]=false;
	for(int i=2; i<sieve.size(); i++) sieve[i]=true;
	for(int j=4; j<sieve.size(); j+=2) sieve[j]=false;
	for(int i=3; 2*i<sieve.size(); i++){
		if(!sieve[i]) continue;
		for(int j=2*i; j<sieve.size(); j+=i) sieve[j] = false;
	}
}

void get_primes(int maximum){
	if(sieve.size() < maximum) eratosthenes(maximum);
	for(int i=2; i<sieve.size(); i++){
		if(sieve[i]) primes.push_back(i);
	}
}

std::map<long long, int> get_factors(long long x){
	std::map<long long, int> factors;
	for(int p: primes){
		if(p*p>x) break;
		while(x%p==0){
			factors[p]++;
			x /= p;
		}
	}
	if(x>1) factors[x]++;
	return factors;
}
*/

struct Prime {
	std::vector<bool> sieve;
	std::vector<int> list;

	// Keep primes up to n_max
	Prime(int n_max) {
		sieve = std::vector<bool>(n_max+1, true);
		sieve[0] = sieve[1] = false;
		for(int i=4; i<sieve.size(); i+=2) sieve[i] = false;
		for(int i=3; 2*i<sieve.size(); i++){
			if(!sieve[i]) continue;
			for(int j=2*i; j<sieve.size(); j+=i) sieve[j] = false;
		}
		for(int i=2; i<sieve.size(); i++){
			if(sieve[i]) list.push_back(i);
		}
	}

	std::map<long long, int> factors(long long x) {
		std::map<long long, int> fs;
		for(int p: list){
			if(p*p>x) break;
			while(x%p==0){
				fs[p]++;
				x /= p;
			}
		}
		if(x>1) fs[x]++;
		return fs;
	}

	bool is_prime(int n){
		return sieve[n];
	}
};


/*
int _main(){
	using namespace std;
	get_primes(10000000);
	for(int i=0; i<20; i++) cout << primes[primes.size()-1-i] << endl;
	for(auto p: get_factors(9999995)) cout << p.first << " " << p.second << endl;
	return 0;
}
*/

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	Prime pr(10000005);
	int n; cin >> n;

	ll ans = 0;
	for(ll i=1; i<=n; i++){
		ll k = n/i;
		dbg(i, k, i*k*(k+1)/2);
		ans += i * k * (k+1) / 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8580
#include<stdio.h>
int main()
{
	int N,x,y,b,p,sum[365];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		sum[i] = x * b + y * p;
		if(b >= 5 && p >= 2)
			sum[i] = sum[i] * 0.8;
		if(b < 5 && p >= 2 && (x*5 + y*p)*0.8 < sum[i] )
			sum[i] = (x*5 + y*p)*0.8;
		else if(b >= 5 && p < 2 && (x*b + y*2)*0.8 < sum[i])
			sum[i] = (x*b + y*2)*0.8;
	}
	for(int i=0;i<N;i++)
		printf("%d\n",sum[i]);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) +(ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int x, y;

int main() {
    ios::sync_with_stdio(false);
    x = read(), y = read();
    cout << x + y / 2 << endl;
    return 0;
}


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

long double dist(long double a, long double b) {
    long double x = sqrt(a*a + b*b);
    return x;
}
 
int main(){
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double x1, x2, y1, y2, x, y, ans;
    long double PI = M_PI;
	x1 = a*sin((h+m/60)*(PI/6));
	x2 = b*sin(m*PI/30);
    y1 = a*cos((h+m/60)*(PI/6));
	y2 = b*cos(m*PI/30);
	x = x1 - x2;
	y = y1 - y2;
	ans = dist(x, y);
	cout << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 4168
n = int(input())

l = list(map(int, input().split()))
c = 0
for i in range(1, n-1):
    if l[i] < l[i-1] and l[i] >= l[i+1] or  l[i] < l[i+1] and l[i] >= l[i-1]:
        c += 1
print(c)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

ll fp(ll b, ll e) {
  if (e == 0) {
    return 1;
  } else if (e == 1) {
    return b;
  }
  ll ans = fp(b, e/2);
  ans *= ans;
  if (e % 2) ans *= b;
  return ans;
}

ll solve(string s) {
  int sz = s.size();
  ll pw = 1;
  for (int i = 0; i < sz-1; i++) {
    pw *= 2ll;
  }
  reverse(s.begin(), s.end());
  ll ans = 0;
  ll last = 0;
  vector<ll> pwr; pwr.push_back(pw);
  for (int i = 0; i < s.size(); i++) {
    ll cur = s[i] - '0';
    for (int j = 0; j < i+1; j++) {
      ans += cur * fp(10, j) * pwr[j];
      if (i == j) {
        pwr[j] /= 2;
        pwr.push_back(pwr[j]);
      }
    }
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  cout << solve(s) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

const int MaxN = 4e5;
using namespace std;

int n, A, B;
int sta[MaxN + 5], tail;
int main() 
{
	while(~scanf("%d%d%d", &n, &A, &B)) {
		tail = 0; bool ok = 1;
		if(n < A) ok = 0;
		else {
			for (int i = A; i >= 1; i--) sta[++tail] = i;
			int last = n - A;
			if(B > last + 1) ok = 0;
			else {
				if(B != 1) {
					int Bolck = last / (B - 1), t = last % (B - 1); 
					if((Bolck + (t == 0 ? 0 : 1)) > A) ok = 0;
					for (int i = 1; i <= Bolck; i++) {
						int now = n - i * (B - 1) + 1;
						for (int j = 0; j < B - 1; j++) sta[++tail] = j + now;
					}
					for (int i = A + 1; i <= A + t; i++) sta[++tail] = i;
				}
				else if(A != n) ok = 0;
			}
		}
		if(!ok) printf("-1\n");
		else {
			for (int i = tail; i >= 1; i--) {
				if(i != 1) printf("%d ", sta[i]);
				else printf("%d\n", sta[i]);
			}
		}
	}
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),D=in(),X=in();
	auto A=vecin(N);
	int sum = 0;
	REP(j,N){
		for(int i=1;i<=D;i+=A[j]){
			sum++;
		}
	}
	out(sum+X);

	return 0;
}


Measured memory_bytes: 256
// ABC 146-A
// 2019.11.24 bal4u

#include <stdio.h>
#include <string.h>

char *s[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
 
int main()
{
	int i;
	char S[10];
	
	scanf("%s", S);
	for (i = 6; i >= 0; i--) {
		if (strcmp(S, s[i]) == 0) break;
	}
	printf("%d\n", 7-i);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
 
int main(){
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U)
  {
    cout << A-1 << ' ' << B << endl;
  }
  else
  {
    cout << A << ' ' << B-1 << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] A = new int[n + 1][n + 1];
    int[] vst = new int[n + 1];
    int min;
    vst[1] = 1;

    for(int i = 1;i <= n;i++){
      for(int j = 1;j <= n;j++){
        A[i][j] = sc.nextInt();/*隣接行列の要素 */
      }
    }
    int cnt = 0;
    //vst[0] = 1;
    int d;
      for(int k = 0;k < n;k++){
        min = 2000;
        d = -1;
    for(int i = 1;i <= n;i++){
      if(vst[i] == 1){
      for(int j = 1;j <= n;j++){
        if(A[i][j] < min && A[i][j] > -1 && vst[j] == 0){
          //cnt+=A[i][j];
          min = A[i][j];
          d = j;
        }
      }
    }
  }
    if(d != -1){
      vst[d] = 1;
      cnt+=min;
    }
    if(n == n - 1) break;
  }
   System.out.println(cnt);
 }
}


Measured memory_bytes: 41196
#include <bits/stdc++.h>
#define mem(a, i) memset(a, i, sizeof(a))
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
int k;
struct Node {
    int u, d;
    bool operator < (const Node& e) const {
        return d > e.d;
    }
};
priority_queue<Node> Q;
bool vis[maxn];
int d[maxn];

int dijkstra() {
    mem(vis, 0);
    fill(d, d + k, INF);
    while(!Q.empty()) Q.pop();
    d[1] = 1;
    Q.push((Node){1, 1});
    while(!Q.empty()) {
        Node x = Q.top();
        Q.pop();
        int u = x.u;
        if(u == 0) return x.d;
        if(vis[u]) continue;
        vis[u] = 1;
        for(int i = 0; i < 7; ++i) {
            int v = (u * 10) % k;
            if(vis[v]) continue;
            if(d[v] > d[u]) {
                d[v] = d[u];
                Q.push((Node){v, d[v]});
            }
        }
        if(d[(u + 1) % k] > d[u] + 1) {
            d[(u + 1) % k] = d[u] + 1;
            if(!vis[(u + 1) % k]) {
                Q.push((Node){(u + 1) % k, d[(u + 1) % k]});
            }
        }
    }
    return -1;
}

int main() {
    while(~scanf("%d", &k)) {
        int ans = dijkstra();
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
string to_string(string s)
{
	return '"' + s + '"';
}

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

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

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

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


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

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(x...) ;
#endif
const long long mod = 1000000007 ;
void solve() {
	int n ;
	cin >> n ;
	vector<int> arr(n) ;
	for (int i = 0 ; i < n ; ++i) {
		cin >> arr[i] ;
	}
	long long ans = 0 ;
	vector<long long> prefix(n) ;
	prefix[0] = arr[0] ;
	for (int i = 1 ; i < n ; ++i)
		prefix[i] = (prefix[i - 1] + arr[i]) % mod ;
	for (int i = 0 ; i < n ; ++i)
		ans += (arr[i] % mod * (prefix[n - 1]  - prefix[i] + mod) % mod ) % mod ;

	cout << ans % mod ;

}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin) ;
#endif
	int T = 1 ;
	while (T--) {
		solve() ;
	}
}

Measured memory_bytes: 5564
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 for(;;){
  int n=ir.nextInt();
  if(n==0) break;
  int acnt=0,bcnt=0;
  while(n-->0){
   int a=ir.nextInt();
   int b=ir.nextInt();
   if(a>b) acnt+=a+b;
   else if(a==b){
    acnt+=a;
    bcnt+=b;
   }
   else bcnt+=a+b;
  }
  out.println(acnt+" "+bcnt);
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}

 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
}
}

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1001;
char a[N][N];
int dp[N][N];
int m,n;

int helper(int x,int y)
{
	if(x==0 and y==0)
	return 1;
	if(x<0 or y<0)
	return 0;
	if(dp[x][y]!=-1)
	return dp[x][y];
	if(a[x][y]=='#')
	return dp[x][y]=0;
	return dp[x][y]=(helper(x-1,y)%MOD+helper(x,y-1)%MOD)%MOD;
}

void solve()
{
	int i,j;
	cin>>m>>n;
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>a[i][j];
	mem(dp,-1);
	cout<<helper(m-1,n-1)<<endl;
}

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

Measured memory_bytes: 9216
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,x,y;cin >> n >> x >> y;
    vvi v(n);
    rep(i,n-1) v[i].pb(i+1);
    rep1(i, n-1) v[i].pb(i-1);
    x--;y--;
    v[x].pb(y);
    v[y].pb(x);
    vi answer(n,1);
    rep(i, n) { 
        int count=0;
        queue<int> que;
        vi ans(n,inf);
        vb bo(n,false);
        que.push(i);
        ans[i]=0;
        bo[i]=true;
        while(!que.empty()) {
            x=que.front();que.pop();
            for(auto p:v[x]) {
                if(bo[p])continue;
                bo[p]=true;
                ans[p]=ans[x]+1;
                answer[ans[p]]++;
                que.push(p);
            }
        }
    }
    /*rep(i, n) {
        for(auto p:v[i])cout << p+1 << ' ';
        cout << endl;
    }*/
    rep1(i, n-1)cout << answer[i]/2 << endl;
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, k, s;

	cin>> n >> k >> s;

	for (int i = 0;i < n;i++) {
		if (i < k) cout << s << " ";
		else if(s!=1000000000) cout << "1000000000 ";
		else cout << "999999999 ";
	}

}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef int Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
    color[v] = 1;
    for (auto e: g[v]) {
        if (color[e.dst] == 2) continue;
        if (color[e.dst] == 1) return false;
        if (!visit(g, e.dst, order, color)) return false;
    }
    order.push_back(v);
    color[v] = 2;
    return true;
}

bool topologicalSort(const Graph &g, vector<int> &order) {
    int n = g.size();
    vector<int> color(n);
    rep(u, n) if (!color[u] && !visit(g, u, order, color))
            return false;
    reverse(order.begin(), order.end());
    return true;
}

typedef pair<Weight, int> Result;

Result visit(int p, int v, const Graph &g) {
    Result r(0, v);
    for (auto e: g[v])
        if (e.dst != p) {
            Result t = visit(v, e.dst, g);
            t.first += e.weight;
            if (r.first < t.first) r = t;
        }
    return r;
}

Weight diameter(const Graph &g) {
    Result r = visit(-1, 0, g);
    Result t = visit(-1, r.second, g);
    return t.first; // (r.second, t.second) is farthest pair
}

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

    Graph g(n);

    rep(i, n - 1) {
        int s, t, w;
        cin >> s >> t >> w;
        Edge edge1(s, t, w);
        Edge edge2(t, s, w);
        g[s].push_back(edge1);
        g[t].push_back(edge2);
    }

    int ans = diameter(g);

    cout << ans << endl;

}



Measured memory_bytes: 17496
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    def f(x):
        cnt = 0
        i = 1
        while i <= x:
            if x % i == 0:
                cnt += 1
            i += 1
        return cnt
    cnt = 0
    n = I()
    for i in range(1,n+1,2):
        if f(i) == 8:cnt += 1
    print(cnt)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans;
  
  if(b > a*c) ans = c;
  else ans = b/a;
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;

void dfs(char[] s, char mx, uint n) {
	if (s.length >= n) {
		writeln(s);
		return;
	}

	for (char c = 'a';c <= mx + 1;++c) {
		auto t = s.dup;
		t ~= c;
		dfs(t, max(mx, c), n);
	}
}

void main() {
	uint n;

	readf(" %s", &n);

	dfs("".dup, 'a' - 1, n);
}


Measured memory_bytes: 2556
na, nb, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
min = a.min + b.min
m.times do
  x, y, c = gets.split.map(&:to_i)
  min = [min, a[x-1]+b[y-1]-c].min
end
puts min

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

using ll=long long;
const ll z=0;

int main() {
  int N;
  cin >> N;
  vector<string> str(N);
  int ans=1;
  for(int i=0;i<N;i++){
    cin >> str[i];
  }
  for(int i=0;i<N-1;i++){
    string a=str[i];
    int k=a.size();
    string b=str[i+1];
    if(a[k-1]!=b[0]){
      ans=0;
    }
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(str[i]==str[j]){
        ans=0;
      }
    }
  }
    
    if(ans==0){
      cout << "No" << endl;
    }
    else
      cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  long int X,A,B,PB,Psum,Nsum,y,i,j;
  scanf("%ld",&X);
  for(i=1;i<150;i++){
    y=i*i*i*i*i;
    for(j=0;j<i+1;j++){
      PB=j*j*j*j*j;
      Psum=y+PB;
      Nsum=y-PB;
      if(Psum==X){
        A=i;
        B=j*(-1);
        break;
      }
      else if(Nsum==X){
        A=i;
        B=j;
        break;
      }
    }
  }
  printf("%d %d",A,B);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char sir[1005][1005];
int n, m, viz[1005][1005], nra;
queue<pair<int, int>> q;
struct directie{
    int x,y;
}d[5]={{-1,0},{0,1},{1, 0},{0,-1}};
int main()
{
    int i, j;
    cin>>n>>m;
    for(i=1; i<=n; i++)
        for(j=1; j<=m; j++){
           cin>>sir[i][j];
           if(sir[i][j]=='#'){
              viz[i][j]=1;
              q.push({i, j});
           }
        }
    for(i=0; i<=n+1; i++){
        viz[i][0]=-1;
        viz[i][m+1]=-1;
    }
    for(j=0; j<=m+1; j++){
        viz[0][j]=-1;
        viz[n+1][j]=-1;
    }
    while(!q.empty()){
        int x,y;
        x=q.front().first;
        y=q.front().second;
        q.pop();
        for(i=0; i<4; i++)
        if((!viz[d[i].x+x][d[i].y+y])&&(sir[d[i].x+x][d[i].y+y]=='.')){
            viz[d[i].x+x][d[i].y+y]=viz[x][y]+1;
            q.push({d[i].x+x,d[i].y+y});
        }
    }
    int maxi=0;
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++)
            maxi=max(maxi, viz[i][j]);
            //cout<<viz[i][j]<<' ';
        //cout<<"\n";
    }
    cout<<max(0,maxi-1);
    return 0;
}



Measured memory_bytes: 13328
#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 rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    ll x, y;
    cin >> x >> y;

    int cnt = 0;
    while(y >= x){
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] num = new int[n+1];
        long ans = 0;
        long[][][] dp = new long[n+1][n+1][n*a+1];


        num[0] = 1000000007;
        for (int i = 1; i <= n; i++) {
            num[i] = sc.nextInt();
        }

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                for (int k = 0; k <= n*a; k++) {
                    if (i == 0 && j == 0 && k == 0) {
                        dp[i][j][k] = 1;
                    }else if(i >= 1 && k < num[i]){
                        dp[i][j][k] = dp[i-1][j][k];
                    }else if(i >= 1 && j >= 1 && k >= num[i]){
                        dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-num[i]];
                    }else{
                        dp[i][j][k] = 0;
                    }
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            ans += dp[n][i][i*a];
        }
        System.out.println(ans);

        sc.close();
    }

}

Measured memory_bytes: 83360
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n, k;
	cin >> n >> k;
	cout << n - k + 1;
	return 0;
}

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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin>>n;
    cout<<setprecision(6)<<double((n+1)/2)/n<<"\n";
    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++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__)
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, multiset<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////
int n;
vector<vector<int> > g;

int dfs(int s) {
    dump(s);
    if (g[s].empty()) return 0;
    vector<int> v;
    for (int x : g[s]) v.push_back(dfs(x));
    sort(all(v));
    int m = v.size();
    rep (i,m) v[i] += m-i;
    return max(m, *max_element(all(v)));
}

int32_t main() {
    cin >> n;
    g.resize(n);
    vector<int> a(n-1); cin >> a;
    rep (i,n-1) g[a[i]-1].push_back(i+1);
    cout << dfs(0) << "\n";
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = (int)S.size();
    string SS(S);
    reverse(all(SS));
    rep(i, 0, N) {
        if (SS[i] == 'b') {
            SS[i] = 'd';
        }
        else if (SS[i] == 'd') {
            SS[i] = 'b';
        }
        else if (SS[i] == 'p') {
            SS[i] = 'q';
        }
        else {
            SS[i] = 'p';
        }
    }
    if (S == SS) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
from operator import mul
from functools import reduce

N, P = map(int, input().split())
a = list(map(int, input().split()))

def com(n, k):
    if n == 0 or k == 0 or n == k:
        return 1
    return int(reduce(mul, range(1, n + 1)) / (reduce(mul, range(1, k + 1)) * reduce(mul, range(1, n - k + 1))))


odd_num = 0
for a_i in a:
    if a_i % 2 == 1:
        odd_num += 1

ans_odd = 0
for i in range(1, odd_num + 1, 2):
    ans_odd += com(odd_num, i)

ans_odd *= 2**(N - odd_num)
if P == 1:
    print(ans_odd)
else:
    print(2**N - ans_odd)

Measured memory_bytes: 3572