akhauriyash/Code-Regression huggingface dataset:
use List::Util qw(max min);
my ($A ,$B, $C, $X, $Y) = split(/ /, <STDIN>);
my @ANS;
$ANS[0] = $A*$X + $B*$Y;
if ($X > $Y) {
        $ANS[1] = $C*2*$Y + $A*($X-$Y);
} else {
        $ANS[1] = $C*2*$X + $B*($Y-$X);
}
$ANS[2] = $C*2*max($X,$Y);
print min(@ANS);

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,s[111111],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=2*n;i++)
	{
		cin>>s[i];
	}
	sort(s+1,s+1+2*n);
	for(int i=2*n-1;i>=1;i-=2)
	{
		ans+=s[i];	
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e3+10;
int a[maxn];
int ans;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i]-1;
	}

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


Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
p a[gets.to_i - 1]


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string.h>

using namespace std;

typedef struct st
{
	int x;
	int y;
	int step;
}state;

int main()
{
	int w,h;
	int hori[31][31];
	int vert[31][31];
	bool visit[30][30];
	int res;
	
	cin >> w >> h;
	while (w+h)
	{
		for (int j=0;j<w-1;++j) cin >> vert[0][j];
		for (int i=0;i<h-1;++i)
		{
			for (int j=0;j<w;++j) cin >> hori[i][j];
			for (int j=0;j<w-1;++j) cin >> vert[i+1][j];
		}
		
		res = 0;
		memset(visit,0,sizeof(visit));
		queue <state> q;
		state s;
		s.x = 0;
		s.y = 0;
		s.step = 1;
		
		visit[0][0] = true;
		q.push(s);
		
		while (!q.empty())
		{
			s = q.front();
			q.pop();
			
			state tmp_state;
			
			if (s.x==w-1&&s.y==h-1) 
			{
				res = s.step;
				break;
			}
			
			if (s.x<w-1&&vert[s.y][s.x]!=1)
			{
				tmp_state.x = s.x + 1;
				tmp_state.y = s.y;
				tmp_state.step = s.step + 1;
				
				if (!visit[tmp_state.y][tmp_state.x]) 
				{
					visit[tmp_state.y][tmp_state.x] = true;
					q.push(tmp_state);
				}
			}
			
			if (s.y<h-1&&hori[s.y][s.x]!=1)
			{
				tmp_state.x = s.x;
				tmp_state.y = s.y + 1;
				tmp_state.step = s.step + 1;
				
				if (!visit[tmp_state.y][tmp_state.x]) 
				{
					visit[tmp_state.y][tmp_state.x] = true;
					q.push(tmp_state);
				}
			}
			
			if (s.x>0&&hori[s.y][s.x-1]!=1)
			{
				tmp_state.x = s.x -1;
				tmp_state.y = s.y;
				tmp_state.step = s.step + 1;
				
				if (!visit[tmp_state.y][tmp_state.x]) 
				{
					visit[tmp_state.y][tmp_state.x] = true;
					q.push(tmp_state);	
				}
			}
			
			if (s.y>0&&hori[s.y-1][s.x]!=1)
			{
				tmp_state.x = s.x;
				tmp_state.y = s.y - 1;
				tmp_state.step = s.step + 1;
				
				if (!visit[tmp_state.y][tmp_state.x]) 
				{
					visit[tmp_state.y][tmp_state.x] = true;
					q.push(tmp_state);
				}
			}
			
		}
		
		cout << res <<endl;
		
		cin >> w >> h;
	}
	
	return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

ll modpow(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1)ans *= x;
		ans %= MOD;
		x *= x;
		x %= MOD;
		y /= 2;
	}
	return ans;
}

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll al = modpow(2, N) - 1;

	ll nCa = 1;
	for (ll i = 1;i <= A;i++) {
		nCa *= (N - i + 1);
		nCa %= MOD;
		nCa *= modpow(i, MOD - 2);
		nCa %= MOD;
	}


	ll nCb = 1;
	for (ll i = 1;i <= B;i++) {
		nCb *= (N - i + 1);
		nCb %= MOD;
		nCb *= modpow(i, MOD - 2);
		nCb %= MOD;
	}

	al -= nCa + nCb;
	al %= MOD;
	if (al < 0)al += MOD;
	cout << al << endl;
}

Measured memory_bytes: 256
import heapq
V, E, root = map(int, input().split())
visited = [False] * V
nodes = [[] for i in range(V)]
cost = [[] for i in range(V)]
for i in range(E):
    s, t, d = map(int, input().split())
    nodes[s].append(t)
    cost[s].append(d)
dist = [float('inf')] * V
dist[root] = 0

h = [(0, root)]
while h:
    c, v = heapq.heappop(h)
    if visited[v]:
        continue
    visited[v] = True
    for i in range(len(nodes[v])):
        t = nodes[v][i]
        if dist[t] > c + cost[v][i]:
            dist[t] = c + cost[v][i]
            heapq.heappush(h, (c + cost[v][i], t))

for i in range(V):
    if dist[i] == float('inf'):
        print('INF')
    else:
        print(dist[i])

Measured memory_bytes: 77156
S = input()
T = input()
n = len(T)

if S.count(T) > 0:
    print(0)
    exit()

ans = n
for i in range(len(S) - n + 1):
    s = S[i:i+n]
    tmp = 0
    for j in range(n):
        if s[j] == T[j]:
            tmp += 1
    ans = min(ans, n - tmp)
print(ans)


Measured memory_bytes: 8964
#include <cstdio>
const int MAXN=220000;
char s[MAXN];
int n, k, p, f;
void solve(int k)
{
	p=1, f=0;
	for (int i=1; i<=k; i++)
		if (f^s[p]=='A') s[p]=f?'A':'B';
		else f^=1, p=p==n?1:p+1;
}
int main()
{
//	freopen("D.in", "r", stdin);
//	freopen("D.out", "w", stdout);
	scanf("%d%d%s", &n, &k, s+1);
	if (k<=2*n)
	{
		solve(k);
		for (int i=p, j=1; j<=n; i=i==n?1:i+1, j++)
		if (!f) putchar(s[i]);
		else putchar(s[i]=='A'?'B':'A');
	}
	else
	{
		solve(2*n);
		if (n%2==0)
			for (int i=1, f=0; i<=n; i++, f^=1) putchar(f?'A':'B');
		else if (s[p]=='A'^(k-2*n)%2==0)
			for (int i=1, f=1; i<=n; i++, f^=1) putchar(f?'A':'B');
		else
		{
			putchar('B');
			for (int i=2, f=0; i<=n; i++, f^=1) putchar(f?'A':'B');
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
int main(){

  int n;
  cin>>n;
  int x= n / 2;
  if(n % 2 != 0)x++;
  cout<<x<<endl;  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){

	int n, r;
	while(cin >> n >> r, n|r){

		vector<int> now(100), next(100);

		for(int i=0; i<n; i++){
			now[n-1-i] = i+1;
		}

		for(int i=0; i<r; i++){
			int p, c; cin >> p >> c;
			for(int j=0; j<n; j++){	
				if(j<c){
					next[j] = now[p-1+j];
				}else if(j<c+p-1){
					next[j] = now[j-c];
				}else{
					next[j] = now[j];
				}
			}
			now = next;
		}
		cout << now[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 3084
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=last[a];i;i=next[i])
using namespace std;

int read() {
    char ch;
    for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
    int x=ch-'0';
    for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
void write(int x) {
    if (!x) {puts("0");return;}
    char ch[20];int tot=0;
    for(;x;x/=10) ch[++tot]=x%10+'0';
    fd(i,tot,1) putchar(ch[i]);
    puts("");
}

const int N=5*1e5+5;
set<int> s;
int n,k,p[N],q[N],deg[N],tr[N<<2];
int last[N],next[N*2],t[N*2],l;
void build(int v,int l,int r) {
    tr[v]=n+1;
    if (l==r) return;
    int m=l+r>>1;
    build(v<<1,l,m);
    build(v<<1|1,m+1,r);
}
void modify(int v,int l,int r,int x,int y) {
    if (l==r) {tr[v]=y;return;}
    int m=l+r>>1;
    if (x<=m) modify(v<<1,l,m,x,y);
    else modify(v<<1|1,m+1,r,x,y);
    tr[v]=(tr[v<<1]<tr[v<<1|1])?tr[v<<1]:tr[v<<1|1];
}
int find(int v,int l,int r,int x,int y) {
    if (l==x&&r==y) return tr[v];
    int m=l+r>>1;
    if (y<=m) return find(v<<1,l,m,x,y);
    else if (x>m) return find(v<<1|1,m+1,r,x,y);
    else {
        int a=find(v<<1,l,m,x,m),b=find(v<<1|1,m+1,r,m+1,y);
        return (a<b)?a:b;
    }
}

void add(int x,int y) {
    t[++l]=y;deg[y]++;next[l]=last[x];last[x]=l;
}

void init() {
    n=read();k=read();
    fo(i,1,n) p[i]=read(),q[p[i]]=i;
}

void solve() {
    build(1,1,n);
    fd(i,n,1) {
        int x;
        x=find(1,1,n,max(q[i]-k+1,1),q[i]);
        if (x<=n) add(q[i],q[x]);
        x=find(1,1,n,q[i],min(q[i]+k-1,n));
        if (x<=n) add(q[i],q[x]);
        modify(1,1,n,q[i],i);
    }
    fo(i,1,n) if (!deg[i]) s.insert(i);
    fo(i,1,n) {
        int x=q[i]=*s.begin();s.erase(s.begin());
        rep(i,x) if (!(--deg[t[i]])) s.insert(t[i]);
    }
    fo(i,1,n) p[q[i]]=i;
    fo(i,1,n) write(p[i]);
}
int main() {

    init();solve();
    return 0;
}

Measured memory_bytes: 38144
def main():
    n = int(input())
    A1 = [int(e) for e in input().split()]
    A2 = [int(e) for e in input().split()]

    ans = 0
    for i in range(n):
        s = sum([A1[a1i] for a1i in range(i + 1)]) + sum([A2[n - a2i - 1] for a2i in range(n - i)])
        ans = max(s, ans)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1000000000
ll d,n,t[300],a[300],b[300],c[300];
ll dp[300][200];
int main(){
   cin >> d >> n;

  REP(i,d)
      cin >> t[i];
  REP(i,n)
      cin >> a[i] >> b[i] >> c[i];

 REP(i,101)
      dp[0][i] = -INF;

  REP(i,n)
      if(a[i] <= t[0] && t[0] <= b[i])
          dp[0][c[i]] = 0;

  REP(i,d-1){
      REP(j,101)
          dp[i + 1][j] = -INF;
      REP(j,101){
          if(dp[i][j] < 0)
              continue;

          REP(k,n){
              if(a[k] <= t[i + 1] && t[i + 1] <= b[k]){
                  dp[i + 1][c[k]] = max(dp[i + 1][c[k]],dp[i][j] + abs(j - c[k]));
              }
          }
      }
  }
  ll ans = 0;
  REP(i,101)
      ans = max(ans,dp[d - 1][i]);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359

const int INF = 1e9 + 7;

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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;
  }
};
 
// nのpow_num乗を返す 
mint mint_choose(int n, int pow_num){
  // 分子
  mint nume = mint(1); 
  rep(i, pow_num){
    nume *= (n - i);
  }

  // 分母
  mint deno = 1;
  rep(i, pow_num){
    deno *= (pow_num-i);
  }
  
  return nume/deno;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;

  mint ans = mint(2).pow(n);
  ans -= mint(1);
  ans -= mint(mint_choose(n, a));
  ans -= mint(mint_choose(n, b));

  cout << ans.x << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int datas[] = new int[10];
        for(int i = 0;i < 10;i++){
            datas[i] =  Integer.parseInt(br.readLine());
        }
        Arrays.sort(datas);
        for(int i = 1;i <= 3;i++){
            System.out.println(datas[10 - i]);
        }
    }
}

Measured memory_bytes: 24300
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


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

int main(){
  int p,q,r,ans = 0;
  cin >> p >> q >> r;
  ans = min(p,min(q,r));
  if(ans == p)ans += min(q,r);
  else if(ans == q) ans += min(p,r);
  else ans += min(p,q);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define LL long long
#define P pair<int, int>
#define LP pair<int,int>
string S;
LL ans;
int main() {
	cin >> S;
	S += "B";
	int l = 0, r = S.size() - 1;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'B') {
			l = i;
			break;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'W') {
			r = i;
			break;
		}
	}
	vector<LL> d;
	LL sum = 1;
	for (; l <= r; l++) {
		if (S[l] != S[l + 1]) {
			d.push_back(sum);
			sum = 0;
		}
		sum++;
	}
	LL B = 0;
	for (int i = 0; i < d.size() ; i++) {
		if (i % 2 == 0) {
			B += d[i];
		}
		else {
			ans += B * d[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  int A_B = B - A;
  if (A_B >= K-1) {
    cout << "OK" << endl;
  } else {
    int A_divided = A % K;
    int B_divided = B % K;
    if (A_divided == 0 || B_divided == 0) {
      cout << "OK" << endl;
    } else if (A_divided <= B_divided) {
      cout << "NG" << endl;
    } else {
      cout << "OK" << endl;
    }
  }
}


Measured memory_bytes: 3636
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(n); rep(i, n)cin >> a[i];
	sort(all(a), greater<ll>());
	ll res = a[0];
	for (int i = 2; i < n; ++i)res += a[i / 2];
	cout << res << endl;
}

Measured memory_bytes: 4740
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		int a = reader.ni();
		int b = reader.ni();
		int c = reader.ni();

		int t = a;
		a = b;
		b = t;

		t = a;
		a = c;
		c = t;

		System.out.println(a + " " + b + " " + c);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


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

int main(){
	int n;
    cin >> n;
  	double arr[n];
    for(int i = 0; i < n; i++)cin >> arr[i];
    sort(arr, arr+n);
    double ans = arr[0];
    for(int i = 1; i < n; i++){
        ans = (ans + arr[i])/2;
    }
    printf("%.6f", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=100;

int n;
vii m(N,vi(N));
vi d(N,inf);

void dijkstra();

int main(){
	int i,j;
	cin>>n;
	int u,k,v,c;
	loop(i,0,n){
		loop(j,0,n){
			m[i][j]=inf;
		}
	}
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v>>c;
			m[u][v]=c;
		}
	}
	dijkstra();
	loop(i,0,n){
		cout<<i<<" "<<d[i]<<endl;
	}
}

void dijkstra(){
	int i;
	d[0]=0;
	vi color(n,WHITE);
	color[0]=BLACK;
	int u=0;
	while(1){
		int minv=inf,v=-1;
		loop(i,0,n){
			if(color[i]!=BLACK){
				d[i]=min(d[i],d[u]+m[u][i]);
				if(minv>d[i]){
					minv=d[i];
					v=i;
				}
			}
		}
		if(v==-1){
			break;
		}
		color[v]=BLACK;
		u=v;
	}
	
}

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

const int N = 100 + 10;
const int C = 1e5 + 10;

struct data {
    int weight, value;
} a[N];

int n, c;
long long dp[N][C];

// int f(int n, int c) {
//   if (n == 0 or c == 0) return 0;
//   if (w[n] > c) return f(n - 1, c);
//   return max(a[n] + f(n - 1, c - w[n]), f(n - 1, c));
// }

long long f(int i, int w) {
    if (dp[i][w] == -1) {
        if (i <= 0 or w <= 0) dp[i][w] = 0;
        else if (a[i].weight > w) {
            dp[i][w] = f(i - 1, w);
        } else {
            dp[i][w] = max(a[i].value + f(i - 1, w - a[i].weight), f(i - 1, w));
        }
    }
    return dp[i][w];
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cin >> n >> c;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].weight >> a[i].value;
    }
    memset(dp, -1, sizeof dp);
    f(n, c);
    cout << dp[n][c] << '\n';
}

Measured memory_bytes: 86272
#include<stdio.h>
#include<math.h>
int main(){
  double a,b,C;
  double S,L,h;
  double PI = acos(-1);
  double rad;
  double c;
  
  scanf("%lf%lf%lf",&a,&b,&C);
  
  rad = C * PI / 180;

  S = a * b * sin(rad) / 2;

  c = sqrt(a * a + b * b - 2 * a * b * cos(rad));

  L = a + b + c;

  h = 2 * S / a;

  printf("%lf\n%lf\n%lf\n",S,L,h);
  

  return 0;
}

  
  



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
   // 500 yen coin - 1000pts.
    // 5 yen coins - 5pts.
    // we find the number a, b. a is the number of 500 yen he has,
    // 5 is the number of 5 yen he has.
    int a = 0, b =0;
    long int sum = 0;
    a = n/500;
    int left = n - a*500;
    b = left/5;
    sum = a*1000 + b*5;
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int sum = 0;
		for(int i = 0;i < N;i++) {
			int A = sc.nextInt();
			for(int k = 0;k < D;k++) {
				if(k * A + 1 <= D)sum += 1;
				else continue;
			}
		}
		
		sum = sum + X;
		System.out.println(sum);
	}

}


Measured memory_bytes: 21972
x,k,d=map(int,input().split())
ans=0

if abs(x)<d :
    if k%2==0 :
        ans=abs(x)
    else :
        x1,x2=x-d,x+d
        ans=abs(x2)
        if abs(x1)<abs(x2) :
            ans=abs(x1)

else :
    if x>0 :
        X=x%d
        K=k-(x//d)
        if K%2==0 and K>0 :
            ans=abs(X)
        elif K%2==1 and K>0 :
            x3,x4=X-d,X+d
            ans=abs(x4)
            if abs(x3)<x4 :
                ans=abs(x3)
        else :
            ans=abs(x-k*d)

    else :
        Y=abs(x)%d
        K=k-(abs(x)//d)
        if K%2==0 and K>0 :
            ans=abs(-Y)
        elif K%2==1 and K>0 :
            y1,y2=-Y+d,-Y-d
            ans=abs(y1)
            if abs(y2)<y1 :
                ans=abs(y2)
        else :
            ans=abs(x+k*d)

print(ans)

Measured memory_bytes: 9136
/*
	Bubble Sort
*/

#include <stdio.h>

/*---x??¨y???????????\????????????---*/
void swap(int *x, int *y)
{
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}

int main(void)
{
	int A[100], N, i, j, n = 0;

	scanf("%d", &N);		//????´?????????°N???????????????
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);		//????´????????????????

	for (i = 0; i < N; i++) {		//bubble sort
		for (j = N - 1; j > i; j--)
			if (A[j] < A[j - 1]) {
				swap(&A[j], &A[j - 1]);
				n++;
			}
	}

	for (i = 0; i < N; i++)		//???????????????????´??????????
		printf("%d%c", A[i], i == N - 1 ? '\n' : ' ');

	printf("%d\n", n);		//??\?????????????????°n?????????

	return 0;
}

Measured memory_bytes: 600
S = input()

if S == 'SUN':
    print('7')

elif S == 'MON':
    print('6')

elif S == 'TUE':
    print('5')

elif S == 'WED':
    print('4')

elif S == 'THU':
    print('3')

elif S == 'FRI':
    print('2')

elif S == 'SAT':
    print('1')

Measured memory_bytes: 8964
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(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 PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

constexpr int MX = 1e5+5;
vector<int> dist(MX, INF);
vector<int> G[MX];
vector<int> par(MX, 0);
vector<bool> Fens(MX, true);
int n;

void dfs(int i, int cur) {
    dist[i] = cur;
    for(int &e: G[i]) {
        if(dist[e] == INF) {
            par[e] = i;
            dfs(e, cur+1);
        }
    }
}


void dfs2(int i) {
    for(int &e: G[i]) { 
        if(dist[e] == INF) {
            if(!Fens[i]) Fens[e] = false;
            dist[e] = 0;
            dfs2(e);
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    rep(i,n-1) {
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(1, 0);

    int back = (dist[n]-1)/2;
    // cout << back << endl;
    // FOR(i,1,n) cout << par[i] << " ";
    Fens[n] = false;
    int cur = n;
    while(back) {
        cur = par[cur];
        Fens[cur] = false;
        back--;
    }

    dist.assign(MX, INF);
    dist[1] = 0;
    dfs2(1);

    int ans = 0;
    FOR(i,1,n) if(!Fens[i]) ans++;
    // cout << ans << endl;

    if(ans < n-ans) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}


Measured memory_bytes: 17176
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC2
    {
        static void Main(string[] args)
        {
            var mod = (long)1e9 + 7;
            var n = long.Parse(Console.ReadLine());

            var a = new long[n];
            var b = new long[n + 1];
            var inputs = Console.ReadLine().Split(" ");
            for (var i = 0; i < n; i++)
            {
                a[i] = long.Parse(inputs[i]);
                b[i + 1] = b[i] + a[i];
            }

            var result = 0L;

            for (var i = 0; i < n; i++)
            {
                var sum = (b[n] - b[i + 1]) % mod;
                result += a[i] * sum;
                result %= mod;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 52672
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int	n;
	int i,j,k;
	
	int box[1001][4];
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			cin>>box[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<3-1;j++){
			for(k=j+1;k<3;k++){
				if(box[i][j]>box[i][k]){
					int wk=box[i][j];
						box[i][j]=box[i][k];
						box[i][k]=wk;
				}
			}
		}
	}
	int cnt=0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i==j) continue;
			if(box[i][0]==box[j][0]&&
			   box[i][1]==box[j][1]&&
			   box[i][2]==box[j][2]&&
			   box[i][0]!=0&&
			   box[i][1]!=0&&
			   box[i][2]!=0
			   ){
				   box[j][0]=0;
				    box[j][1]=0;
					 box[j][2]=0;
				   cnt++;
			   }
		}
	
	}
	cout<<cnt<<endl;
	return 0;
}
			   
			   
			
					
	
		



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b, c, n;
    cin >> a >> b >> c >> n;
    vector<ll> x(n), y(n), z(n);
    REP(i, n) cin >> x[i] >> y[i] >> z[i];

    ll ret = 0;
    // x,y を固定
    {
        ll idx = 0;
        map<PII,ll> mp;
        vector<vector<ll>> v(n, vector<ll>(1, -1));
        REP(i, n) {
            if(mp.find({x[i],y[i]}) == mp.end()) {
                mp[{x[i], y[i]}] = idx++;
            }
            ll num = mp[{x[i], y[i]}];
            v[num].push_back(z[i]);
        }
        REP(i, idx) {
            sort(ALL(v[i]));
            REP(j, v[i].size()) {
                if(j==(ll)v[i].size()-1 && v[i][j]!=c-1) ret += 2;
                if(j<(ll)v[i].size()-1 && v[i][j]+1 != v[i][j+1]) ret += 2;
            }
        }
        ret += (a*b-idx)*2;
    }
    dump(ret);
    // x,z を固定
    {
        ll idx = 0;
        map<PII,ll> mp;
        vector<vector<ll>> v(n, vector<ll>(1, -1));
        REP(i, n) {
            if(mp.find({x[i],z[i]}) == mp.end()) {
                mp[{x[i], z[i]}] = idx++;
            }
            ll num = mp[{x[i], z[i]}];
            v[num].push_back(y[i]);
        }
        REP(i, idx) {
            sort(ALL(v[i]));
            REP(j, v[i].size()) {
                if(j==(ll)v[i].size()-1 && v[i][j]!=b-1) ret += 2;
                if(j<(ll)v[i].size()-1 && v[i][j]+1 != v[i][j+1]) ret += 2;
            }
        }
        ret += (a*c-idx)*2;
    }
    dump(ret);
    // y,z を固定
    {
        ll idx = 0;
        map<PII,ll> mp;
        vector<vector<ll>> v(n, vector<ll>(1, -1));
        REP(i, n) {
            if(mp.find({z[i],y[i]}) == mp.end()) {
                mp[{z[i], y[i]}] = idx++;
            }
            ll num = mp[{z[i], y[i]}];
            v[num].push_back(x[i]);
        }
        REP(i, idx) {
            sort(ALL(v[i]));
            REP(j, v[i].size()) {
                if(j==(ll)v[i].size()-1 && v[i][j]!=a-1) ret += 2;
                if(j<(ll)v[i].size()-1 && v[i][j]+1 != v[i][j+1]) ret += 2;
            }
        }
        ret += (c*b-idx)*2;
    }
    dump(ret);

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3336
#include <stdio.h>

int main(void) {
	int a[1000], n, v;
	int i, j, k;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (k = 0; k < n; k++) {
		printf("%d", a[k]);
		if (k != n - 1) {
			putchar(' ');
		}
	}
	putchar('\n');
	for (i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (k = 0; k < n; k++) {
			printf("%d", a[k]);
			if (k != n - 1) {
				putchar(' ');
			}
		}
		putchar('\n');
	}

	return 0;
}



Measured memory_bytes: 2048
import java.io.*;
import java.util.*;

public class Main
{
	static Scanner scan = new Scanner(System.in);
	public static void solve() throws Exception
	{
		//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer tk = new StringTokenizer(in.readLine());
		String s = scan.next();
	    if(Character.isUpperCase(s.charAt(0)))
	       System.out.println('A');
	    else
	       System.out.println('a');
	}
	public static void main(String[] args) throws Exception
	{
		if(scan.hasNext())
		{
			//int t= scan.nextInt();
			int t= 1;
			while(t-->0)
			{	
				solve();
			}
		}
	}
}

Measured memory_bytes: 35732
/*************/
/* Tree Walk */
/*************/
#include <stdio.h>
#define MAX 25
#define NIL -1

/* Struct Declaration */
typedef struct node {
  int parent;
  int left;
  int right;
}Node;

/* Prototype Declaration */
void printPreorder(int);
void printInorder(int);
void printPostorder(int);

/* Global Variables */
Node U[MAX];
int n;

int main() {
  int id, data, r;
  int i, j;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    U[i].parent = NIL;
    U[i].left = NIL;
    U[i].right = NIL;
  }

  for ( i = 0; i < n; i++ ) {
    scanf("%d", &id);
    for ( j = 0; j < 2; j++) {
      scanf("%d", &data);
      if ( j == 0 ) U[id].left = data;
      else U[id].right = data;
      U[data].parent = id;
    }
  }

    for ( i = 0; i < n; i++ )
      if ( U[i].parent == NIL )
        r = i;

    printf("Preorder\n");
    printPreorder(r);
    printf("\n");
    printf("Inorder\n");
    printInorder(r);
    printf("\n");
    printf("Postorder\n");
    printPostorder(r);
    printf("\n");

  return 0;
}

/* Preorder Walk */
void printPreorder(int u) {
  if ( u == NIL ) return;

  printf(" %d", u);
  printPreorder(U[u].left);
  printPreorder(U[u].right);
}

/* Inorder Walk */
void printInorder(int u) {
  if ( u == NIL ) return;

  printInorder(U[u].left);
  printf(" %d", u);
  printInorder(U[u].right);
}

/* Postorder Walk */
void printPostorder(int u) {
  if ( u == NIL ) return;

  printPostorder(U[u].left);
  printPostorder(U[u].right);
  printf(" %d", u);
}

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

using P = pair<int, int>;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> map(H);
  for (int y = 0; y < H; y++) {
    cin >> map[y];
  }
  queue<P> que;
  que.push(P(0, 0));
  int count_path = 0;
  int kyori[H][W];
  for(int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      kyori[y][x] = -1;
      if (map[y][x] == '.') count_path++;
    }
  }
  kyori[0][0] = 0;
  
  int y[4] = {1, 0, -1, 0};
  int x[4] = {0, 1, 0, -1};
  
  while (!que.empty()) {
    P p = que.front(); que.pop();
    if (p.first == H-1 && p.second == W-1) break;
    for (int i = 0; i < 4; i++) {
      int ny = p.first + y[i];
      int nx = p.second + x[i];
      if (ny >= 0 && ny < H && nx >= 0 && nx < W &&
           map[ny][nx] == '.' && kyori[ny][nx] == -1) {
        que.push(P(ny, nx));
        kyori[ny][nx] = kyori[p.first][p.second] + 1;
      }
    }
  }
  
  if (kyori[H-1][W-1] == -1) {
    cout << -1 << endl;
  }
  else {
    cout << count_path - 1 - kyori[H-1][W-1] << endl;
  }
}
    
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF = LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    if(s2.length()!=s1.length()+1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int f=0;
     for(int i=0;i<s1.length();i++)
     {
         if(s1[i]!=s2[i]){f=1;break;}
     }
     if(f==0)
     {
         cout<<"Yes"<<endl;
         return 0;
     }
     else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;
double a[1005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);

	double sum=(a[0]+a[1])*1.0/2.0;

	for(int i=2;i<n;i++){
		sum=(sum+a[i])*1.0/2.0;
	}
	cout<<sum;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,L,diff=INF,ans,sum;
  cin>>N>>L;
  vector<int> taste(N);
  for(int i=0;i<N;i++)taste[i]=L+i;

  sum=accumulate(ALL(taste),0);
  for(int i=0;i<N;i++){
    int sum2=0;
    for(int j=0;j<N;j++){
      if(i==j)continue;
      sum2+=taste[j];
    }
    if(abs(sum2-sum)<diff){
      diff = abs(sum2-sum);
      ans=sum2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
S = input()
S = S[:-1]
def judge_odd(S):
    # print(S)
    temp_len = len(S)/2
    temp_a = S[:int(len(S)/2)]
    temp_b = S[int(len(S)/2):]
    # print("temp_a={}".format(temp_a))
    # print("temp_b={}".format(temp_b))
    if temp_a == temp_b:
        return False
    else:
        return True
judge = True
if len(S)%2 != 0:
    S = S[:-1]
while judge:
    judge = judge_odd(S)
    if judge:
        S = S[:-2]
print(len(S))


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = Console.ReadLine().Split(' ');
            var list = new List<int>();
            foreach (var item in n)
            {
                list.Add(int.Parse(item));
            }
            list.Sort();
            var x = string.Join(",",list);
            if(x == "1,4,7,9")
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {

	int[] cubes = new int[60];
	int[] tetras = new int[100];

	void run(){
		Scanner in = new Scanner(System.in);
		init();
		for(int n = in.nextInt(); n>0; n = in.nextInt()){
			System.out.println(solve(n));
		}
	}

	void init(){
		for(int i=0; i<60; i++) cubes[i] = i*i*i;
		for(int i=0; i<100; i++) tetras[i] = i*(i+1)*(i+2)/6;
	}

	int solve(int n){
		int ret = 0;
		for(int i=0; i<60; i++)for(int j=0; j<100; j++){
			if(cubes[i] + tetras[j] <= n && ret < cubes[i] + tetras[j]){
				ret = cubes[i] + tetras[j];
			}
		}
		return ret;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 12000
def get_cnt(mat, i, j, h, w):
    cnt = 0
    for ii in range(i-1, i+2):
        if ii < 0 or ii > h-1:
            continue
        for jj in range(j-1, j+2):
            if jj < 0 or jj > w-1:
                continue
            if mat[ii][jj] == '#':
                cnt += 1
    return cnt


def main():
    h, w = map(int, input().split())
    mat1 = [[c for c in input()] for _ in range(h)]
    mat2 = [[None for _ in range(w)] for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if mat1[i][j] == '.':
                cnt = get_cnt(mat1, i, j, h, w)
                mat2[i][j] = cnt
            else:
                mat2[i][j] = '#'

    print('\n'.join([''.join([str(c) for c in  mat2[i]]) for i in range(h)]))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;


int main() {

  int N;
  cin >> N;
  vector<int> h(N);

  for (int i = 0; i < N; i++) cin >> h[i];

  int ans = 0;
  for (int l = 0; l < N; l++) {
    while(h[l] != 0) {
      int r;
      for (r = l+1; r < N; r++) {
        if (h[r] == 0) break;
      }

      for (int j = l; j < r; j++) h[j]--;
      ans++;

    }
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
   ll h;
   cin>>h;
   ll ans=0;
   queue<pair<ll,ll>> q;
   pair<ll,ll> h1;
   h1.ft=h;
   h1.sd=1;
   q.push(h1);
   while(!q.empty()){
       pair<ll,ll> r=q.front();
       q.pop();
       if(r.first==0) break;
       ans+=(ll)r.sd;
       r.sd*=2;;
       r.ft/=2;
       q.push(r);
       
      
   }
   cout<<ans<<endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  int64_t ans = 0;
  for (int64_t i = 1; i <= n; i++) {
    if (1 <= i && i <= 9) {
      ans++;
    } else if (100 <= i && i <= 999) {
      ans++;
    } else if (10000 <= i && i <= 99999) {
      ans++;
    } else if (1000000 <= i && i <= 9999999) {
      ans++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

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

  int heights[10];
  for (int i = 0; i < 10; i ++) {
    cin >> heights[i];
  }
  sort(begin(heights), end(heights), greater<>());
  for (int i = 0; i < 3; i ++) {
    cout << heights[i] << endl;
  }
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define N 100005
using namespace std;

typedef long long ll;
struct st {
	ll a, b, c;
} d[N];
ll x, y, z, n, mx = -1e18, sum, g[N], s[N];
priority_queue<ll, vector<ll>, greater<ll> > qu;

bool cmp(st p, st q) {
	return p.a - p.b > q.a - q.b;
}

int main()
{
	ll i;
	cin >> x >> y >> z;
	n = x + y + z;
	for (i = 1; i <= n; i++) scanf("%lld %lld %lld", &d[i].a, &d[i].b, &d[i].c), sum += d[i].c;
	sort(d + 1, d + n + 1, cmp);
	for (i = 1; i <= n; i++) {
		qu.push(d[i].a - d[i].c);
		g[i] = g[i - 1] + d[i].a - d[i].c;
		if (i > x) g[i] -= qu.top(), qu.pop();
	}
	while (!qu.empty()) qu.pop();
	for (i = n; i > 0; i--) {
		qu.push(d[i].b - d[i].c);
		s[i] = s[i + 1] + d[i].b - d[i].c;
		if (i <= n - y) s[i] -= qu.top(), qu.pop();
	}
	for (i = x; i <= n - y; i++) mx = max(mx, g[i] + s[i + 1]);
    cout << mx + sum << endl;
    return 0;
}

Measured memory_bytes: 4984
def main():

    S = input()
    T = "AKIHABARA"

    cur = set([""])
    for i in range(len(T)):
        temp = set()
        for s in cur:
            temp.add(s + T[i])
            if T[i] == "A":
                temp.add(s)
        cur = temp
    if S in cur:
        return "YES"
    return "NO"


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
  for(i=0;i<a;i++){
    scanf("%d", &b);
    A[b-1]=i+1;
  }
  for(i=0;i<a;i++){
    printf("%d ",A[i]);
  }
  printf("\n");
   
  
return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
long long ans=0;
char s[100];
int a[100];
int n;
long long cal(char s[]){
	int last=0;
	long long tot=0;
	for (int i=0;i<n;i++){
		if (a[i]){
			long long now=0;
			for (;last<=i;last++){
				now=now*10+s[last]-'0';
			}
			tot+=now;
		}
	}
	return tot;
}
void dfs(int now){
	if (now==n-1){
		ans+=cal(s);
		return;
	}
	a[now]=0;
	dfs(now+1);
	a[now]=1;
	dfs(now+1);
}
int main(void){
	scanf("%s",s);
	n=strlen(s);
	a[n-1]=1;
	dfs(0);
	printf("%lld",ans);
}

Measured memory_bytes: 128