akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 100000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 10000000 ;
// UFTクラスを宣言するときはグローバル変数か、staticをつけて静的変数にすること
class UFT{
public :
	int par[MAX] ;
	int rank[MAX] ;
	int size[MAX] ;
	bool root[MAX] ;
	int tree ;

	void init(int n){
		for(int i=0;i<n;i++){
			par[i] = i ;
			rank[i] = 0 ;
			size[i] = 1 ;
			root[i] = true ;
		}
		tree = n ;
	}

	int find(int x){
		if(par[x]==x) return x ;
		return par[x] = find(par[x]) ;
	}

	void unite(int x,int y){
		x = find(x) ;
		y = find(y) ;
		if(x==y){
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
			return ;
		}
		if(rank[x]<rank[y]){
			par[x] = y ;
			size[y] += size[x] ;
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
		}else{
			par[y] = x ;
			size[x] += size[y] ;
			if(rank[x]==rank[y]) rank[x]++ ;
			if(root[y]){
				root[y] = false ;
				tree-- ;
			}
		}
	}

	bool same(int x,int y){
		return find(x)==find(y) ;
	}
};

int main(){
	ll n,m,k ;
	cin >> n >> m >> k ;
	static UFT uft ;
	uft.init(n) ;
	vll cnt(n,0) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		cnt.at(a)++ ;
		cnt.at(b)++ ;
		uft.unite(a,b) ;
	}
	for(int i=0;i<k;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		if(uft.same(a,b)){
			cnt.at(a)++ ;
			cnt.at(b)++ ;
		}
	}
	for(int i=0;i<n;i++) cout << uft.size[uft.find(i)]-cnt.at(i)-1 << (i==n-1?'\n':' ') ;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int dp[102][100002];
signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<int> v(N);
    rep(i, 102) { 
        rep(j, 100002) {
            dp[i][j] = inf;
        }
    }
    rep(i, N) {
        cin >> w[i] >>v[i];
    }
    dp[0][0] = 0;
    rep(i,N+1) {
        rep(j, 100000+1) {
            if(i==0)continue;
            else {
                if(j-v[i-1]>=0)dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);
                else dp[i][j] = dp[i-1][j];
                //if(j-v[i-1]>=0 && j==10) cout << i<<" " <<j<<" " <<dp[i][j] << endl;
            }
        }
    }
    int ans = 0;
    rep(i, 100001) {
        if(dp[N][i]<=W) {
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}




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

using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	vector<vector<int>> dp(n+1, vector<int>(3, numeric_limits<int>::min()));
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	
	for(int i=1; i <= n; i++) {
		int a,b,c;
		cin >> a >> b >> c;
		
		dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
	}
	
	int maxVal = max({dp[n][0], dp[n][1], dp[n][2]});
	cout << maxVal;

	return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int N;
  scanf("%d", &N);
  vector<long long int> A(N, 0);
  for (int i = 0; i < N; i++){
    scanf("%lld", &(A[i]));
  }
  sort(A.begin(), A.end(), greater<long long int>());
  long long int a = 0;
  long long int b = 0;
  for (int i = 0; i < N-1; i++){
    if (A[i] == A[i+1]){
      if (a == 0){
        a = A[i];
        i++;
      }else{
        b = A[i];
        break;
      }
    }
  }
  printf("%lld", a*b);
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 51
#define MAX_K 101
using namespace std;
typedef long long ll;

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

    ll N, K;
    ll V[MAX_N];    
    cin >> N >> K;
    for (ll i = 0; i < N; i++) cin >> V[i];

    ll ans = 0;
    for(ll i = 0; i < N; i++) {
      ll sum_i = 0;
      vector<ll> v;
      for(ll l = 0; l < i; l++) {
	sum_i += V[l];
	v.push_back(V[l]);
      }

      for(ll j = 0; j <= min(K, N)-i; j++) {
	priority_queue<ll, vector<ll>, greater<ll> > pq;
	for(ll l = 0; l < v.size(); l++) pq.push( v[l] );
	
	ll sum_j = sum_i;
	for(ll l = 0; l < j; l++) {
	  sum_j += V[N - 1 - l];
	  pq.push(V[N - 1 - l]);
	}

	for(ll k = 0; k < (K-i-j); k++) {
	  if ( !pq.empty() ) {
	    if ( pq.top() < 0 ) {
	      sum_j -= pq.top();
	      pq.pop();
	    }
	  }
	}

	ans = max(ans, sum_j);
      }
    }

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


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
const ll M=1e9+7;
const int MaxM=501;



int main()
{ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);

   
   ll n;
   cin>>n;
     
     ll i=1;
     ll pre=0;
     while(1)
     {
        ll num=po(26,i)+pre;
        if(n<=num){n-=pre;break;}
        i++;pre=num;
     }

    
     if(i==1) {char c='a';c+=n-1;cout<<c;return 0;}
      
      string ans="";
      while(1)
      { 
         i--;
         if(i==0)
         {char c='a';c+=n-1;ans+=c;break;}
         fr(k,1,27)
         {
             if(k*po(26,i)>=n)
             { ans+=('a'+k-1);
               n-=(k-1)*po(26,i);
               break;
             }
         }
      }
      cout<<ans<<endl;

   }



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s, t;
  cin >> s >> t;
  int res = 0;
  int n = s.size();
  rep(i, n) {
    char ss = s[i];
    char tt = t[i];
    if (ss != tt) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        final int N = 9;
        String[] name = new String[N];
        int[] hito = new int[N], kane = new int[N];

        for (int i = 0; i < N; i++) {
            name[i] = in.next();
            int a = in.nextInt(), b = in.nextInt();
            hito[i] = a + b;
            kane[i] = a * 200 + b * 300;
        }
        for (int i = 0; i < N; i++) {
            System.out.printf("%s %d %d\n", name[i], hito[i], kane[i]);
        }
    }
}

Measured memory_bytes: 25920
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll a, b, x; cin >> a >> b >> x;
	if (a == 0) {
		cout << (b / x) + 1 << endl;
		return;
	}
	cout << (b / x) - ((a - 1) / x) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include "math.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

int h, w, k;
int c[6][6];

int main()
{
	cin >> h >> w >> k;
	char ch;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> ch;
			if (ch == '.')
			{
				c[i][j] = 0;
			}
			else {
				c[i][j] = 1;
			}
		}
	}

	int count = 0;
	for (int i = 0; i < pow(2, h); i++)
	{
		for (int j = 0; j < pow(2, w); j++)
		{
			int black = 0;
			for (int k = 0; k < h; k++)
			{
				for (int l = 0; l < w; l++)
				{
					if ((i&(1<<k))&&(j&(1<<l)))
					{
						if (c[k][l]==1)
						{
							black += 1;
						}
					}
				}

			}
			if (black==k)
			{
				count += 1;
			}
		}

	}
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N), b(N), c(M), d(M);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> c.at(i) >> d.at(i);
  }
  for (int i = 0; i < N; i++) {
    long long e = 10000000000, f, g;
    for (int j = 0; j < M; j++) {
      int h = a.at(i) - c.at(j), k = b.at(i) - d.at(j);
      if (h < 0) {h *= -1;}
      if (k < 0) {k *= -1;}
      f = h + k;
      if (e > f) {
        e = f;
        g = j + 1;
      }
    }
    cout << g << endl;
  }
}

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

#define ll long long int
const int N=100010;
vector<int> adj[N], dp(N, 0), vis(N, 0);

void dfs(int x) {
    if (vis[x]) return;
    vis[x]=1;
    for (auto v: adj[x]) {
        if (!vis[v]) {
            dfs(v);
            dp[x] = max(dp[x], dp[v]+1);
            
        }
        else {
            dp[x] = max(dp[x], dp[v]+1);
        }
        
    }
    
}

int calc(int n) {
    for (int i=1; i<=n; i++) 
        if (!vis[i]) 
        dfs(i);
    //for (int i=1;i<=n;i++)cout<<dp[i]<<" ";
    int m=0;
    for (int i=1;i<=n;i++)m=max(m, dp[i]);
    return m;
}

int main () {
    int n,m,x,y;
    cin>>n>>m;
    for (int i=0; i<m; i++) {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    cout<<calc(n);
    
    
    return 0;
}

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

#define precise(n,k) fixed<<setprecision(k)<<n

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int solve(vector<int> &v, int i) {
    int ans = 0;
    
    while (v[i] % 2 == 0) {
        v[i] /= 2;
        ans++;
    }
    
    return ans;
}
 
int main() {
    int n;
	cin >> n;
    
    int ans = 0;
    
    vector<int> data(n+1);
    
	for (int i = 1; i <= n; i++) {
		cin >> data[i];
		ans += solve(data, i);
	}
	cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
 
using namespace std;
 
int main() 
{ 
    //char c = 'A', i;
    string s;
    int n, asc, i, temp;
    cin >> n >> s;
    //cout << s.length();
    for(i=0; i < s.length(); i++){
        asc = int(s[i]);
        if(asc + n > 90){
            temp = asc + n - 26;
            //s[i] = (char)temp;
            //cout << temp<< endl;
            
        }else{
            temp = asc + n;
        }
        s[i] = (char)temp;
        
    }
    cout << s;
    
    //asc = int('A'); 
    //cout << asc;
    
    //for(i=0; i < )
    
    return 0; 
} 

Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int main(){
    int N,K;
    cin>>N>>K;
    if((N-2)*(N-1)/2<K) cout<<-1<<endl;
    else{
        int sum=N-1+((N-1)*(N-2)/2-K);
        cout<<sum<<endl;
        for(int i=2;i<=N;i++){
            cout<<1<<" "<<i<<endl;
        }
        int count=N-1;
        for(int i=2;i<=N;i++){
            for(int j=i+1;j<=N;j++){
                if(count==sum) return 0;
                count++;
                cout<<i<<" "<<j<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;


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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    //! all Pizza A or B
    int ans = a * x + b * y;

    //! all Pizza AB
    int tmp = c * 2 * max(x, y);
    ans = min(ans, tmp);

    //! all Pizza A from Pizza AB the rest from Pizza B
    tmp = c * 2 * x;
    if (x < y) {
        tmp += b * (y-x);
    }
    ans = min(ans, tmp);

    //! all Pizza B from Pizza AB the rest from Pizza A
    tmp = c * 2 * y;
    if (y < x) {
        tmp += a * (x-y);
    }
    ans = min(ans, tmp);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
from collections import defaultdict
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            for j in range(2*i, N, i):
                sieve[j] = 0
            P.append(i)
    return P

P = set(primes(32000))
D = defaultdict(list)
C = set()
for a in A:
    removes = []
    for p in P:
        cnt = 0
        while a%p==0:
            cnt += 1
            a //= p
        if cnt:
            D[p].append(cnt)
        else:
            if p in C:
                removes.append(p)
            else:
                C.add(p)
    P = P - set(removes)
    if a > 1:
        D[a].append(1)

D = {k:[0]*(len(v) == N-1) + sorted(v) for k, v in D.items() if len(v) >= N-1}

ori = 1
for k, v in D.items():
    ori *= k**v[0]

ans = max(ori, 1)
for a in A:
    tmp = 1 * ori
    for p in D.keys():
        cnt = 0
        while a%p==0:
            cnt += 1
            a //= p
        if cnt == D[p][0]:
            tmp *= p**(D[p][1] - D[p][0])
    ans = max(ans, tmp)
print(ans)
            

Measured memory_bytes: 73452
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

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

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   vector<int> a(n);
   for(int&x : a) {
      cin >> x;
      if(x % 2 == 0){
         if(x % 3 != 0 && x % 5 != 0){
            cout << "DENIED\n";
            return 0;
         }
      }
   }
   cout << "APPROVED\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	N %= 10;
	string S;
	if (N == 3) {
		S = "bon";
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) {
		S = "pon";
	}
	else {
		S = "hon";
	}
	cout << S << endl;
}

Measured memory_bytes: 3628
import numpy as np
import itertools
import math

def l2_norm(node1,node2):
    x1 = node1[0]
    y1 = node1[1]
    x2 = node2[0]
    y2 = node2[1]
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

def pmt(n):
    result = 1
    for i in range(1,n + 1):
        result = result * i
    return result
node_num = int(input())

node_list = []
dist_list = []

# for i in itertools.permutations([i for i in range(3)]):
for i in range(node_num):
    a, b =  map(float,input().split())
    node_list.append((a,b))
for i in itertools.combinations([i for i in range(node_num)],2):
    node1 = node_list[i[0]]
    node2 = node_list[i[1]]
    dist_list.append(l2_norm(node1, node2))

tmp_list = []
for i in itertools.permutations([i for i in range(node_num)]):
    tmp_list.append("".join(map(str, i)))

count = 0
for i in tmp_list:
    if i.find("01") >= 0:
        count = count + 1
    if i.find("10") >= 0:
        count = count + 1

dist = np.asarray(dist_list)
dist = dist * count
dist = dist.sum()
dist = dist / pmt(node_num)
print(dist)

Measured memory_bytes: 15108
q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())*4
l = [q,h/2,s/4,d/8]
v = [1,2,4,8]
cost = 0
while n:
  now = l.index(min(l))
  cost += n//v[now] * r[now]
  n %= v[now]
  v.pop(now)
  r.pop(now)
  l.pop(now)
print(cost)

Measured memory_bytes: 3064
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var s string
  fmt.Scan(&s)
  m, _ := strconv.Atoi(s[5:7])
  d, _ := strconv.Atoi(s[8:10])
  result := "Heisei"
  if 430 < m*100+d {
    result = "TBD"
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	string s; cin >> s;
	int ans = 0;
	int a = 0, bc = 0;
	rep(i, s.size()) {
		if (s[i] == 'A') {
			ans += a * bc;
			a++; bc = 0;
		}
		else if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
			bc++; i++;
		}
		else {
			ans += a * bc;
			a = 0, bc = 0;
		}
	}
	cout << ans + a * bc << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;

int main(){
  ll N;
  cin>>N;
  vector<string> s(N);
  vector<ll> inc(N,0);
  ll la=0;
  ll fb=0;
  ll kk =0;
  for(ll i=0;i<N;i++)cin>>s[i];

  for(ll i=0;i<N;i++){
    for(ll j=0;j<s[i].size();j++){
      if(s[i][j-1]=='A'&&s[i][j]=='B'){
        inc[i]++;
      }
    }
    ll jj = s[i].size();
    if(s[i][jj-1]=='A'&&s[i][0]=='B')
    kk++;
    if(s[i][0]=='B')
    fb++;
    if(s[i][jj-1]=='A')
    la++;
  }

  fb-=kk;
  la-=kk;

ll ans=0;
  if(kk>0){
    ans+=kk-1;
    if(fb>0){
      ans++;
      fb--;
    }
    if(la>0){
      ans++;
      la--;
    }
      ll num = min(la,fb);
  ans+=num;


  }
  else{
    ll num = min(la,fb);
  ans+=num;
  }
for(ll i=0;i<N;i++)ans+=inc[i];

//cout<<la<<fb<<num<<endl;

cout<<ans<<endl;


}

/*

 if(s[i][0]=='B'){
        fb++;
      }
      ll kk = s[i].size();
      if(s[i][kk-1]=='A'){
        la++;
      }
*/
  


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=10010;

int n,oo;
ll a[N],b[N];

int ss[N];
bool bz[N];

inline ll gcd(ll a,ll b)
{return (b==0)?a:(gcd(b,a%b));}

int main()
{
	scanf("%d",&n);
	ll gg=0;
	fd(i,n,0)scanf("%lld",&a[i]),gg=gcd(gg,(a[i]>0)?(a[i]):(-a[i]));
	fo(i,2,n){
		if(!bz[i])ss[++oo]=i;
		fo(j,1,oo)if(i*ss[j]<=n){
			bz[i*ss[j]]=true;
			if(i%ss[j]==0)break;
		}else break;
	}
	fo(i,1,oo)if(a[0]%ss[i]==0){
		int t=ss[i]-1,mo=ss[i];
		fo(l,0,n-1)b[l]=a[l+1]%mo;
		fd(l,n-1,t)b[l-t]=(b[l-t]+b[l])%mo;
		int ok=1;
		fo(l,0,t-1)ok=ok&(b[l]==0)%mo;
		if(ok)printf("%d\n",mo);
	}
	int sr=sqrt(gg);
	int lef=gg;
	fo(i,2,sr)if(lef%i==0){
		while(lef%i==0)lef/=i;
		if(i>n)printf("%d\n",i);
	}
	if(lef>n&&lef>1)printf("%d\n",lef);
}

Measured memory_bytes: 384
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
t = []
for i in range(D):
    t.append(int(input()))

last = [0]*26
    
ans = 0
for day in range(D):
    #満足度プラス計算
    ans += s[day][t[day]-1]
    for j in range(26):
        last[j] += 1
    last[t[day]-1] = 0
    #満足度マイナス計算
    minus = 0
    for j in range(26):
        minus += c[j] * (last[j])
    ans -= minus
    print(ans)

Measured memory_bytes: 9284
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,m;
	cin>>n>>m;
	ll ans=1;
	vector<int> flag(n*m,0);
	for(int i = 0; i < n; i++){
		int a;
		cin>>a;
		a--;
		if(flag[a]>0){
			ans=0;
		}
		flag[a]=1;
	}
	for(int i = 0; i < m; i++){
		int b;
		cin>>b;
		b--;
		if(flag[b]>=2){
			ans=0;
		}
		if(flag[b]>0) flag[b]=3;
		else{
			flag[b]=2;
		}
	}

	int j=-1,k=-1;
	for(int i = n*m-1; i >= 0 ; i--){
		if(flag[i]==3){
			j++;
			k++;
		}else if(flag[i]==2){
			ans*=j+1;
			ans%=mod;
			k++;
		}else if(flag[i]==1){
			ans*=k+1;
			ans%=mod;
			j++;
		}else{
			ans*=((j+1)*(k+1)-(n*m-(i+1)));
			ans%=mod;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4096
S=int(input())
if (S%100>12 and 0<S//100<=12) or (0<S//100<=12 and S%100==0):
    print('MMYY')
elif (S//100>12 and 0<S%100<=12) or (S//100==0 and 0<S%100<=12):
    print('YYMM')
elif 0<S%100<=12 and 0<S//100<=12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3060
A,B,C = map(int,input().split())
L = sorted([A,B,C])
a,b = L[2]-L[0],L[2]-L[1]
ans = 0
if a%2 == b%2:
    ans = (a+b)//2
else:
    ans = (a+b+3)//2
print(ans)

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

int main(){
    int K,A,B;
    cin>>K>>A>>B;
    bool a=false;
    for(int i=0; i<=B-A; i++){
    if((i+A)%K==0){
    a=true;
    break;
    }
    }
if(a==true){
cout<<"OK"<<endl;
}
else
{
cout<<"NG"<<endl;
}

}

Measured memory_bytes: 3640
l = [int(input()) for i in range(5)]

if l[0] < 0:
    print((0 - l[0]) * l[2] + l[3] + l[1] * l[4])

elif l[0] == 0:
     print(l[3] + l[1] * l[4])

else:
    print((l[1]-l[0]) * l[4])



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

int main(){
  long N;
  cin >> N;
  if(N<10){
    cout << N << endl;
  }else if(N<100){
    cout << 9 << endl;
  }else if(N<1000){
    cout << 9+(N-99) << endl;
  }else if(N<10000){
    cout << 909 << endl;
  }else if(N<100000){
    cout << 909+(N-9999);
  }else{
    cout << 90909 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    vector<bool> visited(b);
    for(int i = a % b; !visited[i]; i = (i + a) % b){
        visited[i] = true;
    }

    cout << (visited[c] ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


pair<int, int> E[200001];
int H[100001];
int kotae[100001];
char Vis[100001];
void sagasu(int P, char D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	for (int i = 1; i < 2 * M; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		putint(kotae[i]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    int r = a % b;
    if(r == 0) return b;
    else return gcd(b, r);
}

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

    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    
    if(A[n - 1] < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    int g = A[0];
    for(int i = 1; i < n; i++){
        g = gcd(g, A[i]);
    }

    if(k % g) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<math.h>
#define ll long long
using namespace std;
int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    ll a[m];
    ll left=0, right=0;
    for(ll i=0; i<m; i++){
        cin >> a[i];
    }
    for(ll i=0;i<m;i++)
    {
        if(a[i]<x)left++;
        else right++;
    }
    if(left<right) cout << left;
    else cout << right;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];

    rep(j, w) {
        bool all_dot = true;
        rep(i, h) if (s[i][j] == '#') all_dot = false;
        if (all_dot) {
            rep(i, h) s[i].erase(s[i].begin() + j);
            j--, w--;
        }
    }

    string t = "";
    rep(i, w) t.push_back('.');
    rep(i, h) if (s[i] != t) cout << s[i] << endl;

    return 0;
}



Measured memory_bytes: 256
def left_empty(bench):
    return bench.index('#') 

def a_sit(bench):
    bench[left_empty(bench)] = 'A'
def right_empty(bench):
    for i in reversed(range(len(bench))):
        if bench[i] == '#':
            yield i

def a_next(bench, i):
    if i + 1 < len(bench) and bench[i + 1] == 'A':
        return True
    if 0 <= i - 1 and bench[i - 1] == 'A':
        return True
    return False
            
def b_sit(bench):
    for i in right_empty(bench):
        if not a_next(bench,i):
            bench[i] = 'B'
            return
    bench[left_empty(bench)] = 'B'
def no_people(bench):
    for bi in bench:
        if bi != '#':
            return False
    return True

def not_empty(bench):
    for i in range(len(bench)):
        if bench[i] != '#':
            yield i

def c_sit(bench):
    if no_people(bench):
        bench[len(bench) // 2] = 'C'
        return
    for i in not_empty(bench):
        if i + 1 < len(bench) and bench[i + 1] == '#':
            bench[i + 1] = 'C'
            return
        if 0 <= i - 1 and bench[i - 1] == '#':
            bench[i - 1] = 'C'
            return
def d_sit(bench):
    if no_people(bench):
        bench[0] = 'D'
        return
    tmp = bench[:]
    
    dist = float('inf')
    for i in range(len(tmp)):
        if tmp[i] == '#':
            dist += 1
        else:
            dist = 0
        tmp[i] = dist
    dist = float('inf')
    for i in reversed(range(len(tmp))):
        if tmp[i] != 0:
            dist += 1
        else:
            dist = 0
        tmp[i] = min(tmp[i], dist)
    bench[tmp.index(max(tmp))] = 'D'

import sys
f = sys.stdin


sit = {'A':a_sit,'B':b_sit,'C':c_sit,'D':d_sit}
while True:
    m, n = map(int, f.readline().split())
    if n == 0:
        break
    bench = ['#'] * m
    for i in range(n):
        sit[f.readline().strip()](bench)
    print(''.join(bench))

Measured memory_bytes: 6836
//Name: The Great Summer Contest
//Level: 3
//Category: 数学,Math,場合分け
//Note:

/*
 * MathとDP、GreedyとGraph、GeometryとOtherはそれぞれあらかじめ合計したものについて考えてよい。
 * このとき、1&#12316;3の各セットについては、最大でfloor(そのカテゴリの問題数 / 3)個のコンテストが作れる。
 * このようにして可能な限りコンテストを作った後、残った問題数のパターンは
 * (0,0,0), (0,0,1), (0,0,2), (0,1,1), (0,1,2), (0,2,2), (1,1,1), (1,1,2), (1,2,2), (2,2,2)
 * の10通りになる。
 *
 * 上記のパターンのうち、合計が3に満たないものは明らかに最適な配分をしている。
 * 合計が3以上になるもののうち、(0,1,2)と(0,2,2)以外はパターン4のセットを作ることによって最適な配分になる。
 * (0,1,2)の場合は、「どれかのカテゴリに3を足す」「全カテゴリから1を引く」の繰り返しのみでは、mod 3で(0,1,2)以外のパターンを作れないため、これが最適である。
 * (0,2,2)の場合は、0になっているカテゴリに3問以上の問題が存在していた場合は、(3,2,2)としてからパターン4を2つ作ることで最適になる。
 *
 * オーダーは O(1)。
 */
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

bool solve() {
    array<int,3> ns;
    fill(begin(ns), end(ns), 0);

    for(int i = 0; i < 6; ++i) {
        int v;
        cin >> v;
        ns[i % 3] += v;
    }
    if(all_of(begin(ns), end(ns), [](int a){return a==0;})) return false;

    int ans = ns[0] / 3 + ns[1] / 3 + ns[2] / 3;
    const int mod_sum = ns[0] % 3 + ns[1] % 3 + ns[2] % 3;
    const int mod_pat = (1 << (ns[0]%3)) | (1 << (ns[1]%3)) | (1 << (ns[2]%3));
    if(mod_sum >= 3) {
        if(mod_pat == 0x07) { // (0,1,2)
            // Nothing to do
        } else if(mod_pat == 0x05) { // (0,2,2)
            if((ns[0] % 3 == 0 && ns[0] >= 3) || (ns[1] % 3 == 0 && ns[1] >= 3) || (ns[2] % 3 == 0 && ns[2] >= 3)) {
                ++ans;
            }
        } else {
            ans += mod_sum / 3;
        }
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;

    return 0;
}

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

int main()
{
  string s;
  while (cin >> s) {
    vector<int> prev;
    for (unsigned int i = 0; i < s.size(); ++i)
      prev.push_back(s[i]-'0');

    while (prev.size() != 1) {
      vector<int> next;
      for (unsigned int i = 1; i < prev.size(); ++i)
	next.push_back((prev[i-1]+prev[i])%10);
      prev = next;
    }

    cout << prev[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N1, N2, N3, N4;
    cin >> N1 >> N2 >> N3 >> N4;

    map<int, int> mp;

    mp[N1]++;
    mp[N2]++;
    mp[N3]++;
    mp[N4]++;

    if(mp[1]==1 && mp[9]==1 && mp[7]==1 && mp[4]==1){
        p_yes();
    }else{
        p_no();
    }

    return 0;
}

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

int main(){
    int n;
    double ans;
    std::vector<double> v;

    std::cin >> n;
    for(int a = 0; a < n; a++){
        double b;
        std::cin >> b;
        v.push_back(b);
    }

    std::sort(v.begin(), v.end());

    ans = ( v[0] + v[1] ) / 2;
    
    for(int a = 2; a < n; a++){
        ans = (ans + v[a]) / 2;
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] arr = {
            11, 31, 41, 61, 71, 101, 131, 151, 181, 
            191, 211, 241, 251, 271, 281, 311, 331, 
            401, 421, 431, 461, 491, 521, 541, 571, 
            601, 631, 641, 661, 691, 701, 751, 761, 
            811, 821, 881, 911, 941, 971, 991, 1021, 
            1031, 1051, 1061, 1091, 1151, 1171, 1181, 
            1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451};
        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            System.out.print(i==0 ? arr[i] : " " + arr[i]);
        }
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
#define int long long
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e6;
const int N = 2e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
    ios_base::sync_with_stdio(false);                                      
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    string res;
    FOR(i, 0, 2) res += s[i];
    cout << res;
    
}


Measured memory_bytes: 3644
from itertools import product


X, Y, Z, K = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_B = list(map(int, input().split()))
lst_C = list(map(int, input().split()))
lst_A.sort(reverse=True)
lst_B.sort(reverse=True)
lst_C.sort(reverse=True)

lst_C_K = lst_C[:K]


lst_AB = sorted([a+b for a, b in product(lst_A, lst_B)], reverse=True)
lst_AB_K = lst_AB[:K]

lst_ABC = sorted([ab+c for ab, c in product(lst_AB_K, lst_C_K)], reverse=True)
lst_ABC_K = lst_ABC[:K]

print(*lst_ABC_K, sep="\n")


Measured memory_bytes: 237628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans;cin>>N;ll A[N+4];
  REP(i,N)cin>>A[i];
  REP(i,4)A[N+i]=0;
  sort(A,A+N+4);reverse(A,A+N+4);
  i=0;
  while(A[i]!=A[i+1])i++;
  ans=A[i];i+=2;
  while(A[i]!=A[i+1])i++;
  ans*=A[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, y;
  cin >> n >> y;
  rep(i, n+1)rep(j, n+1){
    ll k = n-i-j;
    if(0 <= k && k <= n && y == 10000*i+5000*j+1000*k){
      print(i, j, k);
      return 0;
    }
  }
  print(-1, -1, -1);
}


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

int main(){
	string s;
	cin >> s;
	int a[4];
	rep(i,4) a[i] = s[i] - '0';
	
	rep(i,8) {
		int result = a[0];
		rep(j,3) {
			result += pow(-1,i>>j&1)*a[j+1];
		}

		if (result == 7) {
			cout << a[0];
			rep(j,3) {
				if (!(i>>j&1)) cout << '+';
				else cout << '-';
				cout << a[j+1];
			}
			cout << "=7" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    int n, x; cin >> n >> x;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }

    int count = 1;
    int current = 0;
    for(int i = 0; i < n; i++){
        if(current+l[i] <= x){
            current += l[i];
            count++;
        } else {
            break;
        }
    }
    cout << count << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S;
  cin >> S;
  LL K;
  cin >> K;
  REP(i, 0,  K) {
    cerr<<S[i]<<endl;
    if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int u = scan.nextInt();
			ten[] map = new ten[u];
			Map<Integer,ArrayList<Integer>>D = new TreeMap<Integer,ArrayList<Integer>>();
			
			for(int i = 0;i<u;i++) {
				map[i] = new ten(scan.nextInt());
				D.put(map[i].num, new ArrayList<Integer>());
				int k = scan.nextInt();
				for(int j = 0;j<k;j++) {
					D.get(map[i].num).add(scan.nextInt());
				}
				
			}
			
			
			
			Deque<ten> dec = new ArrayDeque<ten>();
			dec.addFirst(map[0]);
			map[0].kyori = 0;
			map[0].se = true;
			
			while(!dec.isEmpty()) {
				ten p = dec.removeLast();
				ArrayList<Integer>P = D.get(p.num);
				for(Integer t:P) {
					if(map[t-1].se ==false) {
						dec.addFirst(map[t-1]);
						map[t-1].se = true;
						map[t-1].kyori = p.kyori+1;
						
					}
				}
			}
			
			for(int i = 0;i<u;i++) {
				System.out.print(map[i].num);
				System.out.print(" ");
				System.out.print(map[i].kyori);
				System.out.println();
			}
			
			
		}
		
		
	}
	
	
	
	static class ten{
		int num;
		boolean se;
		int kyori = -1;
		ten(int n){
			num = n;
		}
	}
		

}



Measured memory_bytes: 28404
#include <iostream>
using namespace std;
int n,a,total=0,kisuusaisyou=101;
int main(){
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>n;
		if(kisuusaisyou>n&&n%2==1)kisuusaisyou=n;
		total+=n;
	}
		if(total%2==1){cout<<(total-kisuusaisyou)/2<<endl;
	}else{
		cout<<total/2<<endl;
	}
    return 0;
}


Measured memory_bytes: 3120
import copy

N = int(input())
w  = [['a']]
for n in range(1,N):
    nw = [[] for _ in range(n+1)]
    for i in range(n):
        nw[i] += [''.join([x, chr(97+j)]) for j in range(i+1) for x in w[i]]
        nw[i+1] += [''.join([x, chr(97+i+1)]) for x in w[i]]
    w = copy.deepcopy(nw)

ans = []
for i in range(N):
    ans += [x for x in w[i]]
for x in sorted(ans):
    print(x)

Measured memory_bytes: 16596