akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline
n,m,l=map(int,input().split())
INF=10**10
graph=[[INF for i in range(n)] for j in range(n)]
fuel=[[INF for i in range(n)] for j in range(n)]
#for i in range(n):
#    graph[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    if c>l:continue
    graph[a][b],graph[b][a]=c,c
for i in range(n):
  for j in range(n):
    for k in range(n):
      graph[j][k]=min(graph[j][k],graph[j][i]+graph[i][k])
for i in range(n):
    for j in range(n):
        if graph[i][j]<=l:
            fuel[i][j]=1
for i in range(n):
  for j in range(n):
    for k in range(n):
      fuel[j][k]=min(fuel[j][k],fuel[j][i]+fuel[i][k])
q=int(input())
for i in range(q):
    s,t=map(int,input().split())
    s-=1;t-=1
    if fuel[s][t]==INF:print(-1)
    else:print(fuel[s][t]-1)

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

int main() {
  char c;
  cin >> c;

  if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' ){
    cout << "vowel" <<endl;
  }
  else{
   cout << "consonant" <<endl;
  } 
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,T; cin>>N>>T;
    vector<int> V(N);
    rep(n,0,N) cin>>V.at(n);

    int64_t ans=0;
    rep(i,1,N){
        int dur=min(T,V.at(i)-V.at(i-1));
        ans+=dur;
    }
    ans+=T;

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n;cin >> n;
  
  double ans=0.000000;
  rep(i, n) {
    ll a; cin>>a;
    ans+=1.0/a;
  }
  
  ans=1.0/ans;
  
  cout << fixed << setprecision(7);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int i, n, k;
    char s[50];
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    s[k-1] = tolower(s[k-1]);
    printf("%s",s);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
int main()
{
	int cnt = 0;
	while (true)
	{
		std::string str;
		std::cin >> str;
		if (std::cin.eof())
		{
			break;
		}
		if (str.length() == 1)
		{
			cnt++;
		}
		else
		{
			bool is_ok = true;
			for (int i = 0; i <= str.size() - 1 - i; i++)
			{
				if (str[i] != str[str.size() - 1 - i])
				{
					is_ok = false;
					break;
				}
			}
			if (is_ok)
			{
				cnt++;
			}
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

namespace ABC163
{
    class C
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var ans = new long[N];

            for (int i = 0; i < N - 1; i++)
            {
                ans[A[i] - 1]++;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 45192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000000 + 7;
#define endl '\n'
#define scan(s) scanf("\n%[^\n]", s);
#define rep(a) cout<<#a<<"-> ";for(int i=0;i<a.size();i++) cout<<i<<":"<<a[i]<<" ";cout<<endl;
#define val(a) cout<<#a<<"-> "<<a<<endl;
#define ok cout<<"ok"<<endl;
#define clock cout<<(double)clock()/CLOCKS_PER_SEC<<endl;
void solve()
{
	int a[5];
	memset(a,0,sizeof a);
	int ans;
	for(int i=0;i<5;i++){
		int x;
		cin>>x;
		a[i]=x;
		if(x==0){
			ans=i+1;
		}
	}
	cout<<ans<<endl;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


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

int main(){ 
    int n;
    int a=0;
    cin >> n;
    vector<vector<int>> data(2, vector<int>(n));
  for (int i = 0; i <2 ; i++) {
    for (int j = 0; j <n; j++) {
      cin >> data.at(i).at(j);
    }
  }
  for(int i=0;i<n;i++){
      if(data.at(0).at(i)>data.at(1).at(i)){
          a=a+data.at(0).at(i)-data.at(1).at(i);
      }
  }
  cout<<a;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;

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;
}

// const ll INF = 1LL << 60;

int N;
ll a[100000][3];
ll dp[100000][3];

int main()
{
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < 3; i++)
  {
    dp[0][i] = a[0][i];
  }

  for (int i = 1; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if (j == k)
          continue;
        chmax(dp[i][j], dp[i - 1][k] + a[i][j]);
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++)
  {
    chmax(ans, dp[N - 1][i]);
  }

  cout << ans << endl;
}

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

int main(){

    int k, s;
    cin >> k >> s;
    
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        for(int j = 0; j <= k; ++j){
            if(s-i-j >= 0 && s-i-j <= k)++ans;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<math.h>
#include<cstring>

#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(ll i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vc vector<char>
#define vop vector<pll>
#define vov vector<vector<ll>>
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool fs(ll x,ll y){return x>y;}
bool cmp(ll x ,ll y){
    return abs(x)<abs(y);
}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll x,ll  y){return x>y?y:x;}

ll ow(ll a, ll b, ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}
ll sum(vll v){
    ll sm=0;
    fo(i,0,v.size())sm=sm+v[i];
    return sm;
}
bool isComposite(ll n) {
    if (n <= 3)return false;
    if (n % 2 == 0 || n % 3 == 0)return true;
    for (ll i = 5; i * i <= n; i = i + 6) {
        if (n % i == 0 || n % (i + 2) == 0)return true;
    }
    return false;
}
ll fac[1000001];
void fact(){
    fac[0]=1;
    fo(i,1,1000001){
        fac[i]=i*fac[i-1];
    }
}
int main() {
    ll h,w,n;
    cin>>h;
    cin>>w;
    cin>>n;
    if(h>w){
        if(n%h==0)cout<<(n/h)<<endl;
        else cout<<(n/h)+1<<endl;
    }
    else if(h<=w){
        if(n%w==0)cout<<(n/w)<<endl;
        else cout<<(n/w)+1<<endl;
    }
    return 0;
}


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

int main()
{
	int h, m, s;
	
	scanf("%d", &s);
	
	h = s / 3600;
	
	m = (s - h * 3600) / 60;
	
	s = s - (h * 3600 + m * 60);
	
	printf("%d:%d:%d\n", h, m, s);
	
	return (0);
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> count(10,vector<int>(10,0));
    for(int i=1; i<=N; i++){
        int m=i;
        vector<int> keta;
        while(m!=0){
            keta.push_back(m%10);
            m/=10;
        }
        int a,b;
        a=keta.at(0);
        b=keta.back();
        count.at(a).at(b)++;
    }
    ll ans=0;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            ans += count.at(i).at(j) * count.at(j).at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,n,x,ans=-1e9;
	cin>>a>>b>>n;
	if(b>n)x=n;
	if(b<=n)x=b-1;
	ans=(a*x)/b;
	cout<<ans;
	return 0;
}

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

const int INF = 1e9;

class min_cost_flow {
	using pii = pair<int, int>;
	struct edge {
		int to, cap, cost, rev;
		edge(int to_, int cap_, int cost_, int rev_)
			: to(to_), cap(cap_), cost(cost_), rev(rev_) {}
	};
	int V;
	vector<vector<edge>> G;
	vector<int> h, dist, prevv, preve;
public:
	min_cost_flow(int _V) : V(_V), G(_V), h(_V), dist(_V), prevv(_V), preve(_V) {}
	void add(int from, int to, int cap, int cost) {
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}
	int calc(int s, int t, int f) {
		int res = 0;
		fill(h.begin(), h.end(), 0);
		while (f > 0) {
			priority_queue<pii, vector<pii>, greater<pii>> que;
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			que.push(pii(0, s));
			while (!que.empty()) {
				pii p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				for (size_t i = 0; i < G[v].size(); i++) {
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(pii(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == INF) return -1;
			for (int v = 0; v < V; v++)
				h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> A(N), B(N), xs;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		xs.push_back(A[i]);
		xs.push_back(B[i]);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	int V = xs.size();
	min_cost_flow mcf(N + V + 2);
	int s = N + V, t = N + V + 1;
	mcf.add(s, t, INF, 0);
	for (int i = 0; i < N; i++) {
		mcf.add(s, i, 1, 0);
	}
	for (int i = 0; i < N; i++) {
		int a = lower_bound(xs.begin(), xs.end(), A[i]) - xs.begin();
		int b = lower_bound(xs.begin(), xs.end(), B[i]) - xs.begin();
		mcf.add(i, N + a, 1, -B[i]);
		mcf.add(i, N + b, 1, -A[i]);
	}
	for (int i = 0; i < V; i++) {
		mcf.add(N + i, t, 1, 0);
	}
	cout << -mcf.calc(s, t, INF) << endl;
	return 0;
}



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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
  }
  auto v2 = v;
  ll ans = inf;
  REP(i,-100,101){
    ll sum = 0;
    rep(j,n){
      sum += (v[j] - i ) * (v[j] - i);
    }
    ans = min(sum,ans);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N, M, K;
	int  count[31] = { 0 };

	scanf("%d %d", &N, &M);
	for (int i = 0;i < N;i++)
	{
		scanf("%d", &K);
		for (int j=0;j < K;j++)
		{
			int A;
			scanf("%d", &A);
			A--;
			count[A]++;//j番目の食べ物が好きならcount[j]を+1する
		}
	}
	int ans = 0;
	for (int i = 0;i < M;i++)
	{
		if (count[i] == N)ans++;/*全員i番目の食べ物が好き,つまり
		count[i]==Nならansを+1*/
	}
	printf("%d\n",ans);
	return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vvi v(n, vi(4));
  rep(i,0,n) cin >> v[i][1] >> v[i][2] >> v[i][3];

  vvi dp(n+1, vi(4, -1));
  dp[0][0] = 0;
  rep(i,0,n) {
    rep(j,0,4) {
      rep(k,1,4) {
        if (j==k) continue;
        ckmax(dp[i+1][k], dp[i][j] + v[i][k]);
      }
    }
  }

  cout << *max_element(all(dp[n])) << '\n';
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
 
int main() {
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<vector<int>> ans(h,vector<int>(w,0));

    rep(i,b){
        rep(j,a){
            ans[i][j]=1;
        }
    }

    for(int i=b;i<h;i++){
        for(int j=a;j<w;j++){
            ans[i][j]=1;
        }
    }

    rep(i,h){
        rep(j,w) cout<<ans[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j;
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = k; i < n; i++) {
        // cout << i << " " << i - k << endl;
        if (a[i - k] < a[i]) {
            cout << "Yes" << endl;
        } else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 5200
N = int(input())
B = list(map(int,input().split()))
A = ['a']*N

if N ==  2:
  print(B[0]*2)

else:
  for i,v in enumerate(B):
    if i != N-2:
      if B[i] <= B[i+1]:
        if A[i] == 'a':
          A[i] = B[i]
        if A[i+1] == 'a':
          A[i+1] = B[i]
      else:
        if A[i] == 'a':
          A[i] = B[i]
    else:
      if A[i] == 'a':
        A[i] = B[i]
      if A[i+1] == 'a':
        A[i+1] = B[i]
  print(sum(A))


Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n, x;
	cin >> n >> x;
	int m[100];
	rep(i, n) cin >> m[i];
	sort(m, m + n);
	int sum = 0;
	int ans = 0;
	rep(i, n) sum += m[i];
	if (x - sum == 0) ans = n;
	else ans = (x - sum) / m[0] +n;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	int r;
    	cin>>r;
    	float x=(44.0/7.0)*(r*1.0);
    	cout<<fixed << setprecision(10)<<x;
    }}
    	


Measured memory_bytes: 3800
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     string s;
     cin>>s;
     s[5]=' ';
     s[13]=' ';
     cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = 1;

		for(int i = 0; i < n; i++) {
			if(ans > k) {
				ans += k;
			} else {
				ans *= 2;
			}
		}


		System.out.println(ans);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string a,b,c; cin >> a >> b >> c;

    cout << char(toupper(a[0]));
    cout << char(toupper(b[0]));
    cout << char(toupper(c[0]));

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int x;
	cin >> x;
	
	if(x >= 30) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int M, D;
int ANS = 0;
int main() {
	cin >> M >> D;
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= D; j++) {
			int d1 = j % 10;
			int d10 = j / 10;
			int m = i;
			if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
				ANS++;
			}
		}
	}
	cout << ANS << endl;
	return 0;
}

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

int main(){
    int n,a,b;
    cin >> n;
    vector<int> x(n);
    for(int i=0;i<n;i++) cin >> x[i];
    vector<int> v=x;
    sort(v.begin(),v.end());
    a=v[n/2];b=v[n/2-1];
    for(auto iter=x.begin();iter!=x.end();iter++){
        if(a==b) cout << a << endl;
        else{
            if(*iter<=b) cout << a << endl;
            else cout << b << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void) {
    int n, flag = 0;
    scanf("%d", &n);
    int h[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    for(int i = 1; i < n; i++) {
        if(h[i-1] < h[i]) {
            h[i]--;
        }
    }
    for(int i = 1; i < n; i++) {
        if(h[i-1] > h[i]) {
            flag = 1;
            break;
        }
    }
    if(flag == 1) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 512
from heapq import heappush,heappop
n,k=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in a:
  heappush(q,-i)
for _ in range(k):
  i=heappop(q)
  i=-i//2
  heappush(q,-i)
print(-sum(q))

Measured memory_bytes: 92020
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b , c;
    cin >> a >> b >> c ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( b / a < c ){
        cout << b / a << endl;
    } else {
        cout << c << endl;
    }
    //*/
    
    //cout << a / b << endl;

    return 0; 
}


Measured memory_bytes: 3604
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A.sort()
B = np.cumsum(A)

cnt = 1
for i in range(N-1):
    if B[i]*2 >= A[i+1]:
        cnt += 1
    else:
        cnt = 1

print(cnt)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  if(n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  n /=2;
  while(n){
    n /= 5;
    ans += n;
  }
  cout << ans << endl;
  return 0;
}

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

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

map<string,int> cnt;

int main(){
    int N=read();
    for(int i=1;i<=N;i++){
        string str;
        cin>>str;
        sort(str.begin(),str.end());
        cnt[str]++;
    }
    long long Ans=0;
    for(map<string,int>::iterator it=cnt.begin();it!=cnt.end();++it)
        Ans+=(long long)it->second*(it->second-1)/2;
    printf("%lld",Ans);
}


Measured memory_bytes: 11136
#include<stdio.h>
#define MAX 100
#define INFTY 2000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i=0 ; i<n ; i++)
  {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i=0 ; i<n ; i++)
    {
      if(minv > d[i] && color[i] != BLACK){
        u=i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0 ; v<n ; v++)
    {
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(i=0 ; i<n ; i++)
  {
    if(p[i] != -1) sum += M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&e);
      if(e == -1) M[i][j] = INFTY;
      else M[i][j] = e;
    }
  }

  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const int INF = 1001001001;
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; }

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);

mint f(int n, int k) {
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}

mint ans;
int k;
vector<vector<int>> to;

void dfs(int v,int p=-1){
  for(int u: to[v]){
    if(u==p) continue;
    dfs(u,v);
  }
  int a = (p==-1) ? k : k-2;
  int b = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ans *= f(a,b);

}

int main(){
  int n;
  cin >> n >> k;
  to.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout << ans.x << endl;
  return 0;
}

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

int main() {
  int n,max=0,c=0,d=0;
  
  cin >>n;
  
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x;
    if(i==0){
      y=x;
      continue;
      }
    if(x<=y) c++;
    else{d=c;
        c=0;
        }
    if(i==n-1)d=c;
    if(d>max){
      max=d;
      d=0;
    }
    y=x;
  }
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	cout<<n*n*n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int n[101]={};

    int mode=0;
    while (true) {
        int a;
        if (scanf("%d", &a) == EOF)
            break;

        ++n[a];
        if (mode < n[a])
            mode = n[a];
    }

    for (size_t i=1; i<=100; ++i)
        if (n[i] == mode)
            printf("%zd\n", i);

    return 0;
}

Measured memory_bytes: 2672
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
/*
int solve(vector<int> cost, vector<vector<int>> effect, vector<int> skill, int x, int n, int m, int sum) {
    //条件を満たしていれば終了
    bool clear = true;
    REP(i, m) {
        if(skill[i]<x) {
            clear = false;
            break;
        }
    }
    if(clear) return sum;
    
    //どれか一つ選んで購入
    
}*/

int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> effect(n, vector<int>(m));
    REP(i, n) {
        cin >> cost[i];
        REP(j, m) cin >> effect[i][j];
    }
    //solve(cost, effect, skill, x, n, m);
    int min_price = MOD;
    for(int s=1; s<(1<<n); s++) { //2^nパターンを試す
        int price = 0;
        vector<int> skill(m, 0);
        for(int p=0; p<n; p++) {//どの本に注目するか
            if(s & (1<<p)) { //p bit目が立っている
                REP(i, m) {
                    skill[i] += effect[p][i];
                }
                price += cost[p];
            }
        }
        bool clear = true;
        REP(i, m) {
            if(skill[i]<x) {
                clear = false;
                break;
            }
        }
        if(clear) {
            min_price = min(min_price, price);
        }
    }
    if(min_price == MOD) {
        cout << -1 << endl;
    }else {
        cout << min_price << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(long long N, std::vector<long long> H){
  int max_count=0;
  int count=0;
  for(long long i=1;i<N;i++){
    if(H[i-1]>=H[i]){
      count++;
      max_count=max(max_count,count);
    }else{
      count=0;
    }
  }
  cout<<max_count<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 1024
mod = int(1e9+7)
n = int(input())
arr = list(map(int, input().split()))
arr.sort()

s = 0
for e in arr:
    s += e
    s %= mod

total = s*pow(2, n-1, mod) % mod

def fn(x):
    if x == 0:
        return 0
    return (x*pow(2, x-1, mod)) % mod

for i in range(n):
    total += fn(n-i-1) * pow(2, i, mod) % mod * arr[i] % mod
    total %= mod
    #print(i, fn(n-i-1), pow(2, i, mod), arr[i])

print(total*pow(2, n, mod)%mod)


Measured memory_bytes: 87628
s = input()

for i in range(2**3):
  f = s[0]
  for j in range(3):
    if ((i>>j)&1):
      f += '+'
    else:
      f += '-'
    f += s[j+1]
  ans = eval(f)
  if ans == 7:
    print(f + '=7')
    break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 100001
ll n,a[N],b[N],ans=0;

int main(){
	cin>>n;
	FOR(i,1,n+1){
		cin>>a[i]>>b[i];
	}
	for(ll i=n;i>=1;i--){
		if((a[i]+ans)%b[i]){
			ans+=b[i]-(a[i]+ans)%b[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int gcd(int x, int y)
{
  int d, tmp;


  if(x < y){            //数字の入れ替え
    tmp = x;
    x = y;
    y = tmp;
  }
  d = x % y;

  while(d != 0){      //ユークリッドの互除法を使用
    x = y;
    y = d;
    d = x % y;
  }
  return y;
}

int main(void)
{
  int x, y;

  scanf("%d %d", &x, &y);

  printf("%d\n", gcd(x, y));

  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,k; cin >>n >>k;
  double ans=0;
  for(int i=1; i<=n; i++){
    double t=1.0/n; int x=i;
    while(x<k){x*=2; t/=2;}
    ans+=t;
  }
  cout <<setprecision(15)<<ans;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

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

void END(){
  cout<<-1<<endl;
  exit(0);
}

int a[1<<21],n;
bool used[1<<21];
bool usd2[1<<21];
int sum;

int dfs(int S){
  if(used[S])return 0;
  int res=0;
  used[S]=1;
  r(i,n){
    if(!(S&(1<<i)))continue;
    if(a[S]==0 &&  a[S-(1<<i)])END();
    else dfs(S-(1<<i));
  }
  return 0;
}
int dfs2(int S){
  if(used[S])return 0;
  int res=0,res2=0;
  used[S]=1;
  r(i,n){
    if(!(S&(1<<i)))continue;
    if(a[S-(1<<i)]==0)res++;
    res2++;
    dfs2(S-(1<<i));
  }

  if(res==res2 && a[S])sum++;
  
  return 0;
}

int main(){
  cin>>n;
  r(i,1<<n)cin>>a[i];
  dfs((1<<n)-1);
  memset(used,0,sizeof(used));
  dfs2((1<<n)-1);
  cout<< sum <<endl;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        ll x;
        cin>>x;
        sum +=x;
    }
    if(sum<=n)
    {
        cout<<n-sum<<endl;
    }
    else cout<<-1<<endl;
    return 0;
}




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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<(w/2)*h<<" ";
	if (x==w/2 && y==h/2) cout<<1<<endl;
	else cout<<0<<endl;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    if((A&B) % 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0;i<H;i++){
    cin>>a[i];
  }
  map<char,int>k;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      k[a[i][j]]++;
    }
  }
  int cnt4=0,cnt2=0,cnt1=0;
  for(auto c:k){
    auto key=c.first;
    auto v=c.second;
    int a4=v/4;
    int a2=(v/2*2-a4*4)/2;
    int a1=v-a4*4-a2*2;
    cnt4+=a4,cnt2+=a2,cnt1+=a1;
  }
  if(H%2==0&&W%2==0){
    if(cnt4*4==H*W){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
  else if(H%2!=0&&W%2!=0){
    if(cnt1==1&&cnt2<=(H+W-2)/2){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
  else{
    if(H%2!=0){
      if(cnt2<=W/2&&cnt1==0){cout<<"Yes"<<endl;}
      else{cout<<"No"<<endl;}
    }
    else{
      if(cnt2<=H/2&&cnt1==0){cout<<"Yes"<<endl;}
      else{cout<<"No"<<endl;}
    }
  }
  return 0;  
}

Measured memory_bytes: 3640
d , g = map(int, input().split())
pc = [list(map(int, input().split()))for i in range(d)]
x=[]
y=[0]*d
ac=[0]*d
for i in range(d):
    ac[i]=pc[i][0]*(i+1)*100+pc[i][1]

def dfs(n,m,y,now):
    if now==n:
        z=y.copy()
        x.append(z)
        return
    for i in range(m):
        y[now]=i
        dfs(n,m,y,now+1)
dfs(d,3,y,0)
mi = 1000
for i in x:
    sum = 0
    cost = 0
    stock = []
    sum2 = 0
    cost2 = 0
    for j in range(d):
        if i[j]==1:
            sum+=ac[j]
            cost+=pc[j][0]
            sum2+=ac[j]
            cost2+=pc[j][0]
        if i[j]==2:
            stock+=[(j+1)*100]*pc[j][0]
            sum2+=pc[j][0]*(j+1)*100
            cost2+=pc[j][0]
    if sum2<g:
        continue
    stock.sort()
    if abs(sum2-g)>abs(sum-g):
        while sum<g and stock:
            sum+=stock.pop()
            cost+=1
        if sum>=g:
            mi=min(mi,cost)
    else:
        while sum2>g and stock:
            sum2-=stock.pop()
            cost2-=1
        cost+=1
        mi=min(mi,cost2)

print(mi)


Measured memory_bytes: 14708
#include<bits/stdc++.h>
using namespace std;
int dp[50][50][50][50],a[50][50],n,m,px,py,ret=0x3f3f3f3f;
char s[50][50];
int g(int x1,int y1,int x2,int y2){
	x1--,x2--,y1--,y2--;
	return a[x2][y2]-a[x2][y1]-a[x1][y2]+a[x1][y1];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='#');
			if(s[i][j]=='P')px=i,py=j;
		}
	memset(dp,0x3f,sizeof(dp)),dp[1][1][n+1][m+1]=0;
	for(int w=n;w>=1;--w)
		for(int h=m;h>=1;--h)
			for(int i=1;i+w<=n+1;i++)if(i<=px&&px<i+w)
				for(int j=1;j+h<=m+1;j++)if(j<=py&&py<j+h){
					int& ans=dp[i][j][i+w][j+h];
					for(int _w=w;_w<=n+1;++_w)
						for(int _h=h;_h<=m+1;++_h)if(_w!=w||_h!=h){
							ans=min(ans,dp[i][j][i+_w][j+_h]+g(i+w,j,i+_w,j+h)+g(i,j+h,i+w,j+_h));
							if(j+h-_h>=1)ans=min(ans,dp[i][j+h-_h][i+_w][j+h]+g(i,j+h-_h,i+w,j)+g(i+w,j,i+_w,j+h));
							if(i+w-_w>=1)ans=min(ans,dp[i+w-_w][j][i+w][j+_h]+g(i+w-_w,j,i,j+h)+g(i,j+h,i+w,j+_h));
							if(j+h-_h>=1&&i+w-_w>=1)ans=min(ans,dp[i+w-_w][j+h-_h][i+w][j+h]+g(i,j+h-_h,i+w,j)+g(i+w-_w,j,i,j+h));
						}
					if(i<=px&&px<i+w&&j<=py&&py<j+h){
						ret=min(ret,ans+g(i,j,px+1,py+1));
						ret=min(ret,ans+g(px,py,i+w,j+h));
						ret=min(ret,ans+g(i,py,px+1,j+h));
						ret=min(ret,ans+g(px,j,i+w,py+1));
					}
				}
	printf("%d",ret);
}

Measured memory_bytes: 24704
#include <iostream>
#include <vector>

int main(){
  long long N;
  std::cin >> N;
  std::vector<long long> A(N);
  for(int i = 1 ; i < (int)A.size() ; i++){
    std::cin >> A[i];
  }
  std::vector<long long> n_young(N);

  for(int i = 1 ; i < (int)A.size(); i++){
    n_young[A[i] - 1] += 1;
  }

  for(auto && r : n_young){
    std::cout << r << std::endl;
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > c(10, vector<int>(10, 0));
    for (int i = 1; i <= n; i++) {
        string num = to_string(i);
        int r0 = num[0] - '0';
        int r1 = num[num.size() - 1] - '0';
        c[r0][r1]++;
    }
    int sum = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            sum += c[i][j] * c[j][i];
        }
    }
    cout << sum << endl;
    return 0;
}

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

Measured memory_bytes: 23232
#include<stdio.h>
long long int gcm(long long int p,long long int q){
	while(p*q!=0){
		if(p>q){
			p=p%q;
		}else{
			q=q%p;
		}
	}
	return (p>q)?p:q;
}
long long int lcm(long long int p,long long int q){
	return (p*q/gcm(p,q));
}
int main(void){
	long long int a[3],m[3],x,y,z,count[3];
	scanf("%lld%lld%lld%lld%lld%lld",&a[0],&m[0],&a[1],&m[1],&a[2],&m[2]);
	while( a[0]!=0 || m[0]!=0 || a[1]!=0 || m[1]!=0 || a[2]!=0 || m[2]!=0){
		x=1;	
		y=1;
		z=1;
		count[0]=0;
		count[1]=0;
		count[2]=0;
		a[0]%=m[0];
		a[1]%=m[1];
		a[2]%=m[2];
		do{
			x=(a[0]*x)%m[0];
			count[0]++;
		}while( x!=1 );
		do{
			y=(a[1]*y)%m[1];
			count[1]++;
		}while( y!=1 );
		do{
			z=(a[2]*z)%m[2];
			count[2]++;
		}while( z!=1 );
		printf("%lld\n",lcm(lcm(count[0],count[1]),count[2]));
		scanf("%lld%lld%lld%lld%lld%lld",&a[0],&m[0],&a[1],&m[1],&a[2],&m[2]);
	}
}

Measured memory_bytes: 600
from collections import deque

def getStart(field):
    search_field = field[1:]     # cut the first [H,W,N] for min_path matrix
    for y in range(len(search_field)):
        for x in range(len(search_field[0])):
            if search_field[y][x] == "S":
                return x,y+1


def bfs(field,start_x,start_y,goal_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    gotten_cheese = 1
    distance = 0
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * field[0][1] for i in range(field[0][0])]
    min_path[start_y-1][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < field[0][1] and 1 <= ny < field[0][0]+1 and field[ny][nx] != "X" and min_path[ny-1][nx] == INF:
                min_path[ny-1][nx] = min_path[current[1]-1][current[0]] + 1
                if field[ny][nx] == gotten_cheese: # at the same cheese-power number
                    distance += min_path[ny-1][nx]
                    if field[ny][nx] == goal_N: # goal
                        print(distance)
                        return
                    else: # not goal, but could eat cheese
                        que = []
                        que.append([nx,ny])
                        gotten_cheese += 1
                        min_path = [[INF] * field[0][1] for i in range(field[0][0])]
                        min_path[ny-1][nx] = 0
                        break
                else:
                    que.append([nx,ny])


def main(field):
    sx,sy = getStart(field)
    bfs(field,sx,sy,field[0][2])

# field = [[10,10,9],
# [".","X",".",".",".","X",".","S",".","X"],
# [6,".",".",5,"X",".",".","X",1,"X"],
# [".",".",".","X","X","X","X",".",".","X"],
# ["X",".",".",9,"X",".",".",".","X","."],
# [8,".","X",2,"X",".",".","X",3,"X"],
# [".",".",".","X","X",".","X",4,".","."],
# ["X","X",".",".",".",".",7,"X",".","."],
# ["X",".",".","X",".",".","X","X",".","."],
# ["X",".",".",".","X",".","X","X",".","."],
# [".",".","X",".",".",".",".",".",".","."]]
#
# main(field)

matrix = []
while True:
    row = input().rstrip().split()
    if len(row) == 3:
        re_row = []
        for i in row:
            re_row.append(int(i))
        matrix.append(re_row)
    else:
        re_row = []
        for char in row[0]:
            if char.isdigit():
                re_row.append(int(char))
            else:
                re_row.append(char)
        matrix.append(re_row)
    if len(matrix) == int(matrix[0][0]) + 1:
        main(matrix)
        break

Measured memory_bytes: 44392
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	long long ans = 1, y = 1e18;
	double tmp = 1;
	for (int i = 1; i <= n; i++) {
		long long x;
		scanf("%lld", &x);
		ans = ans * x;
		tmp = tmp * x;
	}
	if (ans > y || tmp > y) puts("-1");
	else printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3224
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;
typedef pair<pair<int, int>, int> P;

#define INF 1000000000

#define SZ 90

bool visited[SZ*2+5][SZ*2+5];

bool isin(int x, int y){
    return x>=0 && x<=SZ*2 && y>=0 && y<=SZ*2;
}

int main(){
    int n,t;
    while(cin>>t>>n, t|n){
        fill(visited[0], visited[SZ*2+5], false);
        rep(i,n){
            int x,y;
            cin>>x>>y;
            visited[x+SZ][y+SZ]=true;
        }
        int sx,sy;
        cin>>sx>>sy;

        queue<P> q; //<<x,y>, turn>
        q.push(mp(mp(sx+SZ, sy+SZ), 0));
        visited[sx+SZ][sy+SZ]=true;
        int res=1;
        while (!q.empty()){
            int dx[] = {1,1,0,-1,-1,0};
            int dy[] = {0,1,1,0,-1,-1};

            P p = q.front(); q.pop();
            if(p.second>=t) continue;
            int x = p.first.first, y=p.first.second;
            rep(i,6){
                int nx = x+dx[i], ny=y+dy[i];
                if(isin(nx,ny) && visited[nx][ny]==false){
                    visited[nx][ny]=true;
                    q.push(mp(mp(nx,ny), p.second+1));
                    res++;
//                    cout<<nx-SZ<<","<<ny-SZ<<endl;
                }
            }
        }
        cout<<res<<endl;

    }

    return 0;
}

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

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

  rep(i,n+1){
    if(i>n) break;

    rep(j,n+1){
      if(i+j>n) break;

      int k = n - i - j;

      if(i*10000+j*5000+k*1000==y){
        printf("%d %d %d\n",i,j,k);
        return 0;
      }

    }

  }

  printf("-1 -1 -1\n");

  return 0;
}

Measured memory_bytes: 3656
n, a, b = map(int, input().split())
 
mod = 10 ** 9 + 7
 
if n == 2:
   print(0)
   exit()
                
S = pow(2, n, mod) - 1

x1 = 1
y1 = 1
for i in range(a):
  x1 = x1 * (n-i) % mod
  y1 = y1 * (i+1) % mod
A = (x1 * pow(y1, mod - 2, mod)) % mod

for i in range(a, b):
  x1 = x1 * (n-i) % mod
  y1 = y1 * (i+1) % mod
B = (x1 * pow(y1, mod - 2, mod)) % mod

print((S - A - B) % mod)

Measured memory_bytes: 3064