akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

void calc_dp(const int start, const vector<double>& p, vector<double>& dp){
  if(start==p.size()-1){
    dp[0] = 1.0-p[start];
    dp[1] = p[start];
    return;
  }
  calc_dp(start+1, p, dp);
  dp[p.size()-start] = dp[p.size()-start-1]*p[start];
  for(int i=p.size()-start-1; i>0; --i){
    dp[i] = dp[i]*(1.0-p[start]) + dp[i-1]*p[start];
  }
  dp[0] = dp[0]*(1.0-p[start]);
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  // ans 1
  /* 
  vector<double> p(N);
  rep(i, 0, N){
    cin >> p[i];
  }
  vector<double> dp(N+1, 0.0);
  calc_dp(0, p, dp);
  */

  //ans 2
  vector<double> dp(N/2+2, 0.0);
  double tmp;
  cin >> tmp;
  dp[0] = tmp;
  dp[1] = 1.0-tmp;
  rep(i, 1, N/2+1){
    cin >> tmp;
    dp[i+1] = dp[i]*(1.0-tmp);
    for(int j=i; j>0; --j){
      dp[j] = dp[j]*tmp + dp[j-1]*(1.0-tmp);
    }
    dp[0] = dp[0]*tmp;
  }
  rep(i, N/2+1, N){
    cin >> tmp;
    for(int j=N/2; j>0; --j){
      dp[j] = dp[j]*tmp + dp[j-1]*(1.0-tmp);
    }
    dp[0] = dp[0]*tmp;
  }

  double ans=0.0;
  rep(i, 0, N/2+1){
    ans += dp[i];
  }

  printf("%.10lf\n", ans);

  return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)

for i in range(m):
    max_item = heapq.heappop(a) * -1
    heapq.heappush(a, (max_item // 2) * -1)

print(sum(a) * -1)


Measured memory_bytes: 14180
d = {"DUMMY": 0}
n = int(input())
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

n = int(input())
for i in range(n):
  s = input()
  d[s] = d.get(s, 0) - 1

print(max(d.values()))

Measured memory_bytes: 9168
#pragma comment(linker,"/STACK:102400000,102400000")
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
using namespace std;


int main(){	
	int A,B,C,X,Y;
	int x1,x2,x3,ans=0x3f3f3f3f;
	scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
	int maxm=max(X,Y); 
	for(int i=0;i/2<=maxm;i+=2){
		x1=X-i/2,x2=Y-i/2;
		x1=x1<0?0:x1;
		x2=x2<0?0:x2;
		ans=min(ans,x1*A+x2*B+i*C);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> num(n); for (auto& a : num) std::cin >> a;
	std::priority_queue<int> queue;
	for (const auto a : num) queue.push(a);
	const auto comparator = [](const std::pair<int, int> a, const std::pair<int, int> b) {return a.second < b.second; };
	std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(comparator)> pair(comparator);
	for (auto i = 0; i < m; ++i) {
		int b, c; std::cin >> b >> c;
		pair.emplace(b, c);
	}
	int rest = n;
	long long int result = 0;
	while (rest > 0) {
		if (queue.empty() || (!pair.empty() && pair.top().second > queue.top())) {
			const auto p = pair.top(); pair.pop();
			const auto use = std::min(rest, p.first);
			rest -= use;
			result += use * (long long int)p.second;
		}
		else {
			--rest;
			result += queue.top(); queue.pop();
		}
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int n, m;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
char a[55][55];

int check(int i, int j)
{
    if (i <= 0 || i > n)
        return 0;
    if (j <= 0 || j > m)
        return 0;
    if (a[i][j] == '#')
        return 1;
    return 0;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n ; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> a[i][j];

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (a[i][j] == '#')
            {
                int count = 0;
                for (int k = 0; k < 4; ++k)
                    count += check(i + dx[k], j + dy[k]);

                if (!count)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#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)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    int ans=0;
    rep(i,N-1) A[i+1]+=A[i];
    rep(i,N-1) B[i+1]+=B[i];
    rep(i,N){
        if(!i) chmax(ans,A[i]+B[N-1]);
        else chmax(ans,A[i]+B[N-1]-B[i-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//have fun
#include <bits/stdc++.h>
using namespace std;
#define mod 		1000000007
#define ll 		long long
#define mp 		make_pair
#define pb 		push_back
#define forn(i,n) 	for(int i=0;i<n;i++)
#define for1(i,n) 	for(int i=1;i<n;i++)
#define ford(i,n) 	for(int i=n-1;i>=0;i--)
#define vi 		vector<int>
#define vl 		vector<ll>
#define pii 		pair<int,int>
#define pll 		pair<ll,ll>
#define vpi 		vector<pair<int,int> >
#define vpl		vector<pair<ll,ll> >
#define vvi 		vector<vector<int> >
#define vvl 		vector<vector<ll> >
#define ull 		unsigned long long
#define IOS 		ios_base::sync_with_stdio(false);
#define PI 		3.1415926535897932384626
#define ff 		first
#define ss 		second
#define char2Int(c) 	(c-'0')
#define FOREACH(i,t) 	for (auto i=t.begin(); i!=t.end(); i++)
#define clr(a,x) 	memset(a,x,sizeof(a)) //set elements of array to some value
#define all(x)		(x).begin(),(x).end()//cout<<"Case #"<<zzz<<": ";
int main()
{
    IOS;cin.tie(NULL);
    int zz=1;
    for(int zzz=1;zzz<=zz;zzz++)
    {
        ll h,w;cin>>h>>w;
        vvi mat(h,vi(w));
        forn(i,h)forn(j,w){char temp;cin>>temp;if(temp=='.')mat[i][j]=1;else mat[i][j]=0;}
        vvi dp(h,vi(w,0));
        dp[h-1][w-1]=1;
        ford(i,h)
        {
            ford(j,w)
            {
                if(i!=h-1)
                {
                    dp[i][j]=(dp[i][j]+dp[i+1][j])%mod;
                }
                if(j!=w-1)
                {
                    dp[i][j]=(dp[i][j]+dp[i][j+1])%mod;
                }
                dp[i][j]*=mat[i][j];
            }
        }
        cout<<dp[0][0]<<endl;
        //cout<<diff<<endl;
    }
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[2][605][605];
int n,a[605];
bool bad[605],in[605];
int C;
int main(){
	cin>>n;
	for(int i=1;i<=2*n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		int x = a[2*i-1];
		int y = a[2*i];
		if(x == -1 && y == -1){C++; continue;}
		if(x>=0 && y>=0){
			bad[x] = 1; bad[y] = 1;
		}
		else{
			int k = max(x,y);
			assert(k>=0);
			in[k] = 1;
		}
	}
	dp[0][0][0] = 1;
	int cur = 0, nxt = 1;
	for(int i=2*n;i>=1;i--){
		if(bad[i]) continue;
		for(int j=0;j<=n;j++) for(int k=0;k<=n-j;k++) dp[nxt][j][k] = 0;
		for(int j=0;j<=n;j++) for(int k=0;k<=n-j;k++){
			if(dp[cur][j][k]==0) continue;
			if(!in[i] && j){
				dp[nxt][j-1][k] += dp[cur][j][k]*1LL*j%mod;
				if(dp[nxt][j-1][k]>=mod)dp[nxt][j-1][k]-=mod;
			}
			if(k){
			    dp[nxt][j][k-1] += dp[cur][j][k];
				if(dp[nxt][j][k-1]>=mod) dp[nxt][j][k-1]-=mod;
			}
			if(j+k+1 <= n){
				int add = (int)(in[i]); //cout<<add<<endl;
				dp[nxt][j+add][k+1-add] += dp[cur][j][k];
				if(dp[nxt][j+add][k+1-add]>=mod) dp[nxt][j+add][k+1-add]-=mod;
			}
		}
		swap(cur,nxt);
	}
	ll ans = dp[cur][0][0];
	for(int j=C;j>=1;j--)ans=(ans*1LL*j)%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    for(int i = 1;i < S.length();i++){
        if(S[i] == S[i-1]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }
    for(int i = 2;i < S.length();i++){
        if(S[i] == S[i-2]){
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
  int a[10],b[10],i,j,tmp,sum1=0,sum2=0;
  for(i=0;i<10;i++)
    scanf("%d",&a[i]);
  for(i=0;i<10;i++)
    scanf("%d",&b[i]);
  for(i=0;i<9;i++){
    for(j=i+1;j<10; j++){
      if(a[i] < a[j]) {
	tmp=a[i];
	a[i]=a[j];
	a[j]=tmp;
      }
      if(b[i] < b[j]) {
	tmp=b[i];
	b[i]=b[j];
	b[j]=tmp;
      }
    }
  }
  for(i=0;i<3;i++){
    sum1=sum1+a[i];
    sum2=sum2+b[i];
  }
  printf("%d %d\n",sum1,sum2);
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;

int main() {
  Int n, m;
  cin >> n >> m;
  Int x = 1;
  x = x << m;
  // dump(x);
  Int res = (n - m) * 100 * x + (1900 * m) * x;
  dump(res);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	int n, a[105];

	cin >> n;
	REP(i, n) {
		cin >> a[i];
	}

	sort(a, a + n);

	int alice = 0, bob = 0, f = 1;
	for(int i = n - 1; i >= 0; i--){
		if (f) {
			alice += a[i];
			f = 0;
		}
		else {
			bob += a[i];
			f = 1;
		}
	}

	cout << alice - bob << endl;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long cnt;
    long N = lread();
    long m = long.min;
    foreach (_; 0 .. N)
    {
        long p = lread();
        m.maxAssign(p);
        cnt += p;
    }
    cnt -= m / 2;
    writeln(cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  for(int i=1;i<10;i++){
    if(A%i==0 && A/i<10){
      cout << "Yes" << endl;
      return 0;
    }
  }
      cout << "No" << endl;
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 998244353;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;


bool solve(){
	ll n;cin>>n;
	vector<ll>v(n);
	ll k;cin>>k;
	rep(i,n)cin>>v[i];sort(all(v));
	ll ans=0;
	rep(i,k)ans+=v[i];
	cout<<ans<<endl;
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll n;

void dfs(ll now,int bit,ll &counter) {
    if(now > n) return;
    if(bit == 7) counter++;
    dfs(now*10+3,bit|1,counter);
    dfs(now*10+5,bit|2,counter);
    dfs(now*10+7,bit|4,counter);
}

int main () {
    cin>>n;
    ll ans = 0;
    dfs(0,0,ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  a*=10;
  a+=b;
  a*=10;
  a+=c;
  if(a%4==0)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K, X, Y, ans int
	fmt.Scan(&N, &K, &X, &Y)

	if K < N {
		ans = K*X + (N-K)*Y
	} else {
		ans = N * X
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool solve(ll x, ll base) {
	vector<ll> a(8);
	a[0] = 1;
	for (int i = 1; i < 8; i++) {
		a[i] = a[i - 1] * base;
		// cout << a[i] << endl;
	}
	vector<ll> b(8);
	int N = 0;
	for (int i = 7; i >= 0; i--) {
		ll k = x / a[i]; x %= a[i];
		b[i] = k;
		if (k) N = max(N, i + 1);
	}
	rep(i, N) if (!b[i]) return false;
	string s = "FESTIVAL";
	string unko = "LAVITSEF";
	rep(i, N) rep(t, b[i] - 1) s.pb(unko[i]);
	for (int i = N - 2; i >= 0; i--)
		rep(t, base)
			s.pb(unko[i]);
	cout << s  << endl;
	return true;
}

int main() {
	ll x; cin >> x;
	random_device rd;
	mt19937 mt(rd());
	for (;;) {
		int base = 256 + mt() % 5;
		if (solve(x, base)) break;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { 
    return 1;
  }
  else { 
    return 0;
  }
}

int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<vector<int>> vec(M, vector<int>(2));
  for(int i=0; i<M; i++){
    cin >> vec.at(i).at(0) >> vec.at(i).at(1);
  }
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0; i<M; i++){
    a.at(i) = vec.at(i).at(0);
    b.at(i) = vec.at(i).at(1);
  }
  int p = 0;
  for(int i=0; i<1000; i++){
    int k = 0;
    if(i == 0){
      k = 1;
    }
    else{
      while(i>=std::pow(10, k)){
        k++;
      }
    }
    if(k == N){
      int t = 0;
      for(int j=0; j<M; j++){
        int h = i/std::pow(10, k-a.at(j));
        if(h % 10 == b.at(j)){
          t++;
        }
      }
      if(t == M){
        cout << i << endl;
        p++;
        break;
      }
    }
  }
  if(p == 0){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A,B)<<" "<<max(0,A+B-N)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    if ( H%A==0){
      System.out.println( H/A );}
    else{
      int i = H%A;
      System.out.println( (H-i)/A+1 );}
  }
}

Measured memory_bytes: 21972
from collections import Counter
N=int(input())
C=sorted(Counter([input() for i in range(N)]).items(),key=lambda x:-x[1])
tmp=C[0][1]
ans = []
for i,j in C:
    if j==tmp:
        ans.append(i)
    else:
        break
for i in sorted(ans):
    print(i)

Measured memory_bytes: 43476
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(x,y) lower_bound(ALL(x), y) - x.begin() - 1;
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first 
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111



int main(void) {
  ll a, b;
  vll edge[10], path;
  cin >> n >> m;
  FOR(i, 2, n + 1) path.pb(i);
  FOR(i, 0, m) {
	cin >> a >> b;
	edge[a].pb(b);
	edge[b].pb(a);
  }

  do {
	cnt = 0; tmp = 1;
	FOR(i, 0, n - 1) {
	  flag = false;
	  FOR(j, 0, edge[tmp].size()) if (edge[tmp][j] == path[i]) flag = true;
	  if (!flag) break;
	  tmp = path[i];
	  cnt++;
	}
	if (cnt == n - 1) ans++;
  } while (next_permutation(ALL(path)));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def main():
    N = input()
    N = int(N)

    k = 1
    s = []
    #lst = list(range(1,N+1))
    primes = prime(N+1)
    num = len(primes)

    # N=1
    lst = [0] * N
    if N ==1:
        print(1)
        exit()

    # N>=2
    for i in range(2,N+1):
        b =[]
        b = bunkai(i)
        for i in b:
            lst[primes.index(i)] += 1

    ans = 1
    for i in lst:
        if i is not 0:
            ans = ans * (i+1)
    print(ans%1000000007)


def prime(n):
    primes = []
    for i in range(2,n):
        flag = True
        for j in range(2,i):
            if i%j == 0:
                flag = False
        if flag:
            primes.append(i)
    return primes

def bunkai(i):
    bunkai =[]
    s =0
    while s ==0:
        for j in range(2,i+1):
            if i % j ==0:
                bunkai.append(j)
                i = int(i/j)
                if i ==1:
                   s=1
                break
    return bunkai

if __name__ == "__main__":
        main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	char S[4];
	int a;
	int p=0;
	for(a=0;a<4;a++){
		scanf("%c",&S[a]);
		if(S[a]=='+'){
			p++;
		}else{
			p--;
		}
	}
	printf("%d",p);
return 0;
}

Measured memory_bytes: 256
// atcoder/abc126/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

bool yymm(string s)
{
  string t;
  t += s[2];
  t += s[3];

  set<string> mm;
  for (int i = 1; i <= 12; ++i) {
    char buff[10];
    sprintf(buff, "%02d", i);
    mm.insert(string(buff));
  }
  return mm.count(t);
}

bool mmyy(string s)
{
  string t;
  t += s[0];
  t += s[1];

  set<string> mm;
  for (int i = 1; i <= 12; ++i) {
    char buff[10];
    sprintf(buff, "%02d", i);
    mm.insert(string(buff));
  }
  return mm.count(t);
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    if (mmyy(s) && yymm(s)) cout << "AMBIGUOUS" << endl;
    else if (mmyy(s)) cout << "MMYY" << endl;
    else if (yymm(s)) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }

  return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ld N, K; cin >> N >> K;
    ld ans = 0;
    for (ld i = 1; i <= N; i++) {
        ld c = 0;
        if (i < K) {
            c = ceil(log2l(K / i));
        }
        ans += 1 / (N * pow(2, c));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3876
#!/usr/bin/ruby

require 'pp'

N = gets.chomp.to_i

queue = []
table = [nil]*(N)
1.upto(N-1){|e|

u,v,w = gets.chomp.split(" ").map(&:to_i)
   if table[u] == nil
        table[u] = {color: -1, neibours: [] }
   end

   if table[v] == nil
        table[v] = {color: -1, neibours: [] }
   end

   table[u][:neibours] << [v,w]
   table[v][:neibours] << [u,w]

   if e == 1
      queue << u
      table[u][:color] = 0
   end
}



while !queue.empty? do
    i = queue.shift
    c = table[i][:color]
    table[i][:neibours].each{|node|
       if table[ node[0] ][:color] == -1
          table[ node[0] ][:color] = (node[1]%2 == 0 ? c : c^1)
          queue << node[0]
       end
    }
end


1.upto(N){|n|
  puts table[n][:color]
}

Measured memory_bytes: 52220
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll K,Q; cin>>K>>Q;
    vector<ll> d(K);
    rep(i,K) cin>>d[i];
    while(Q--){
        ll n,x,m; cin>>n>>x>>m;
        vector<ll> dd(K+1,0);
        vector<ll> ctt(K+1,0);
        ll sumd=0;
        dd[0]=0;
        ctt[0]=0;
        ll ct=0;
        rep(i,K) {
            dd[i+1]=d[i]%m+dd[i];
            if(d[i]%m==0) ++ct;
            ctt[i+1]=ct;
        }
        sumd=dd[K];
        ll sd=x%m;
        ll ed=sd+sumd*((n-1)/K);
        ll ansct=ct*((n-1)/K)+ctt[(n-1)%K];
        ed+=dd[(n-1)%K];
        ll ans=n-1-(ed/m+ansct);
        cout<< ans <<"\n";

    }


}

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


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
    ll n; cin >> n;
    ll s = 0, m = INF, M = - INF;
    REP(i, n){
        ll a; cin >> a;
        s += a; chmin(m, a); chmax(M, a);
    }
    printf("%lld %lld %lld\n", m, M, s);
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  map<int, int> c;
  rep(i, n) c[a[i]]++;

  int ans = 0;
  rep(i, n) {
    if (c[a[i]] < a[i]) {
      ans += c[a[i]];
      c[a[i]] = 0;
    }
    else {
      ans += c[a[i]] - a[i];
      c[a[i]] = a[i];
    }
  }
  cout << ans << endl;


  
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)

typedef vector< int > Ary;
typedef vector< Ary > Mat;

struct Edge { int to, c; };

void maxUpdate(int& a, int b) { a = max(a, b); }

void mul(Mat& res, Mat& a, Mat& b) {
	int N = a.size();
	res = a;
	
	for_(i,0,N) for_(j,0,N) for_(k,0,N) {
		if (a[i][k] >= 0 && b[k][j] >= 0) maxUpdate(res[i][j], a[i][k] + b[k][j]);
	}
}

int V, K, E, dp[110][155], prv[110][155];
vector< vector< Edge > > adj;

void restore(int step, int v) {
	int c = step;
	vector< int > path;
	
	while (v != -1) {
		path.push_back(v);
		v = prv[c--][v];
	}
	
	reverse(path.begin(), path.end());
	for_(i,0,step+1) cout << path[i] << (i < step ? " " : "\n");
}

bool shortPhase() {
	memset(dp, -1, sizeof(dp));
	memset(prv, -1, sizeof(prv));
	
	for_(v,0,V) dp[0][v] = 0;
	
	int max_score = -1, step = -1, terminal = -1;
	
	for_(i,0,100) {
		for_(v,0,V) {
			if (dp[i][v] == -1) continue;
		
			for (Edge e : adj[v]) {
				if (dp[i + 1][e.to] < dp[i][v] + e.c) {
					dp[i + 1][e.to] = dp[i][v] + e.c;
					prv[i + 1][e.to] = v;
					
					if (max_score < dp[i + 1][e.to]) {
						max_score = dp[i + 1][e.to];
						terminal = e.to;
					}
				}
			
			}
		}
		
		if (max_score >= K) {
			step = i + 1;
			break;
		}
	}
	
	if (max_score >= K) {
		cout << step << endl;
		restore(step, terminal);
		return true;
	}
	
	return false;
}

int calcMinStep() {
	Mat mat[20], ini(V, Ary(V, -1));
	
	for_(v,0,V) for (Edge e : adj[v]) {
		maxUpdate(ini[v][e.to], e.c);
	}
	
	mat[0] = ini;
	for_(i,0,19) mul(mat[i + 1], mat[i], mat[i]);
	
	int res = 0;
	
	Mat x(V, Ary(V, -1)), nx;
	for_(v,0,V) x[v][v] = 0;
	
	for_rev(h,19,0) {
		mul(nx, x, mat[h]);
		
		int max_score = 0;
		for_(u,0,V) for_(v,0,V) maxUpdate(max_score, nx[u][v]);
		
		if (max_score < K) {
			x = nx;
			res += 1 << h;
		}
	}
	
	return res + 1;
}

void solve() {
	if (!shortPhase()) {
		int ans = calcMinStep();
		cout << (ans > (int)1e6 ? -1 : ans) << endl;
	}
}

int main() {
	cin >> V >> E >> K;
	
	adj.assign(V, vector< Edge >());
	
	for_(i,0,E) {
		int u, v, c;
		cin >> u >> v >> c;
		adj[u].push_back(Edge{v, c});
	}
	
	solve();
}

Measured memory_bytes: 5344
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,r=1;
	cin>>N;
	for(int i=2;pow(i,2)<=1000;i++)
		for(int j=2;pow(i,j)<=1000;j++)
		{
			if(pow(i,j)<=N)
				r=max(r,(int)pow(i,j));
		}
	cout<<r<<endl;
}


Measured memory_bytes: 256
import itertools
import numpy as np

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:m+1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

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

int main(){
  
  int n, m, d, v, s, x[1081]={};

  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>m>>d>>v>>s;
    int y=(m-1)*30+d+360;
    for(int k=1;k<=1080;k++){
      if(k<y){
	x[k]=max(x[k],s-(y-k));
      }else if(y<=k&&k<=y+v-1){
	x[k]=max(x[k],s);
      }else if(y+v-1<k){
	x[k]=max(x[k],max(0,s-(k-(y+v-1))));
      }
    }
  }

  //for(int i=1;i<=360;i++) cout<<x[i]<<" ";

  int mi=360;
  for(int i=1;i<=360;i++) mi=min(mi,max(x[i],max(x[i+360],x[i+720])));

  cout<<mi<<endl;
  
  return 0;
}

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

using namespace std;

int n, d;
int x[11][11];
int sq[1000001];

int main(){
	scanf("%d%d", &n, &d);

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= d; j++){
			scanf("%d", &x[i][j]);
		}
	}

	for(int i = 1; i * i <= 1000000; i++) sq[i * i] = i;

	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			int len = 0;
			for(int k = 1; k <= d; k++){
				len += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}

			if(sq[len]) ans++;
		}
	}

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

Measured memory_bytes: 3200
# Aiでソートしてあげたほうがいいね？
n,m = map(int,input().split())
drink = []
for i in range(n):
    a,b = map(int,input().split())
    drink.append([a,b])
drink = sorted(drink,key = lambda x:x[0])
#print(drink)
total = 0
cnt = 0
for price,num in drink:
    if cnt == m:
        break
    if cnt + num <= m:
        cnt += num
        total += num * price
    else:
        nya = max(abs(m - (cnt)),0)
        #print(nya)
        #print("?",abs(m - (num+cnt)),num,cnt)
        cnt += nya
        total += nya * price
print(total)


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

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

    ll N; cin >> N;
    ll A[200005],B[200005];

    vector<P> lis,lis2;
    
    for (int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
        lis.push_back(P(A[i],B[i]));
        lis2.push_back(P(B[i],A[i]));
    }

    sort(lis.begin(),lis.end());
    sort(lis2.begin(),lis2.end());
    reverse(lis2.begin(),lis2.end());

    ll ans;

    if(N%2 == 0){
        ll from = lis[N/2].first+lis[N/2-1].first;
        ll to = lis2[N/2].first+lis2[N/2-1].first;
        ans = to-from+1;
        //cout << from << " " <<  to << endl;
    }else{
        ll from = lis[N/2].first;
        ll to = lis2[N/2].first;
        ans = to-from+1;
    }


    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 12916
#include <algorithm>
#include <climits>
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <utility>
#include <vector>

using namespace std;

const int cap = 3001;
int dp[cap][cap];
string s, t;

int main() {
    cin >> s >> t;
    int M = s.size(), N = t.size();
    fill(&dp[0][0], &dp[0][0] + cap * cap, 0);
    for (int i = 1; i <= M; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    char lcs[dp[M][N]];
    for (int i = M, j = N; i && j;) {
        if (s[i - 1] == t[j - 1]) {
            lcs[dp[i][j] - 1] = s[i - 1];
            --i;
            --j;
        }
        else if (dp[i - 1][j] >= dp[i][j - 1]) {
            --i;
        }
        else {
            --j;
        }
    }
    for (char c : lcs)
        printf("%c", c);
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> ma;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ma[a]++;
    }

    vector<int> c_count(n + 1);
    for (auto x:ma)c_count[x.second]++;
    for (int i = 1; i <= n; i++)c_count[i] += c_count[i - 1];

    vector<int> v(n + 1);
    for (auto x:ma)v[x.second] += x.second;
    for (int i = 1; i <= n; i++)v[i] += v[i - 1];

    for (int i = 1; i <= n; i++) {
        int ok = 0;
        int ng = n / i + 1;
        while (abs(ok - ng) > 1) {
            int mid = ng + (ok - ng) / 2;

            int sum = (c_count[n] - c_count[mid]) * mid + v[mid];

            if (sum >= mid * i)ok = mid;
            else ng = mid;
        }

        cout << ok << endl;
    }

    return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#define ll long long
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
inline int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
inline ll gl(){
	ll sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int a[2];
int main(){
	int i,j,n,m,k,now=0;
	a[0]=gi();a[1]=gi();k=gi();
	while(k--){
		if(a[now]&1)a[now]--;
		a[now^1]+=a[now]/2;a[now]/=2;
		now^=1;
	}
	printf("%d %d\n",a[0],a[1]);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		int H,W;
		do{
			H = scan.nextInt();
			W = scan.nextInt();
			if(H == 0 && W == 0){break;} // H = 0 W = 0 ??§??????
			for(int i = 0;i < H;i++){
				for(int j = 0;j < W;j++){
					if(i == 0 || i == H - 1|| j == 0 || j == W - 1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
				}
					System.out.print("\n");
			}
			System.out.print("\n");	
		}while(true);
	}
}

Measured memory_bytes: 37236
# https://atcoder.jp/contests/abc083/submissions/1917434
# i i+1 が異なる場所は中間から探すだけでいい
s=input()
a=s[(len(s)-1)//2::-1]
b=s[len(s)//2:]
if a[0]!=b[0]:
    print(len(s)//2)
else:
    c=str(1-int(a[0]))
    m = (a+c).find(c)
    n = (b+c).find(c)
    print(len(s)//2+min(m,n))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#include <string>
int main(){
    int a,b;
    cin >> a >> b;
    int t=a+b;
    int h=a-b;
    int k=a*b;
    int ans = max(t,h);
    ans = max(ans,k);
    cout << ans <<endl;
    return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  double b=0;
  vector<int> a(n);
  rep(i,n){ 
    cin>>a.at(i);
    b+=a.at(i);
  }
  sort(a.begin(),a.end());
  b=b/(4*m);
  if(a.at(n-m)>=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

using namespace std;

int main(){
	int n,tmp,min=INT_MAX,max=INT_MIN;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		if(max < tmp-min) max = tmp - min;
		if(min > tmp) min = tmp;
	}
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 2736
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> arare;
	for (int i = 0; i < n; ++i) {
		string color;
		cin >> color;
		bool ok = true;
		for (int j = 0; j < (int)arare.size(); ++j) {
			if (color == arare[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			arare.push_back(color);
		}
	}

	if (arare.size() == 3)
		cout << "Three" << endl;

	if (arare.size() == 4)
		cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main () {

	int x, a , b;

	scanf("%d%d%d", &x, &a, &b);

	if (b - a <= 0) {
		printf("delicious\n");
	} else if (b - a > x) {
		printf("dangerous\n");
	} else {
		printf("safe\n");
	}

	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define INF 1000000007
using namespace std;

int n,m,a[50],ans=INF;
vector<int> v[50];

inline void dfs(int loc,int mask1,int cost)
{
	int mask2=mask1;
	if(!((mask1>>loc)&1ll)){
		cost+=a[loc];
		mask1|=(1ll<<(loc));
	}
	for(int i=0;i<v[loc].size();i++){
		if(!(mask1&(1ll<<(v[loc][i])))){
			cost+=a[v[loc][i]];
			mask1|=(1ll<<(v[loc][i]));
		}
	}
	if(cost>=ans) return;
	if(loc==n-1){
		ans=cost;
		return;
	}
	for(int i=0;i<v[loc].size();i++){
		if(!(mask2&(1ll<<(v[loc][i])))){
			dfs(v[loc][i],mask1,cost);
		}
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0,0,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Digit_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                string[] input = s.Split(' ');

                int num1 = int.Parse(input[0]);
                int num2 = int.Parse(input[1]);
                int temp = num1 + num2;
                if (temp >= 1000000)
                {
                    Console.WriteLine(7);
                }
                else if (temp >= 100000 && temp <= 999999)
                {
                    Console.WriteLine(6);
                }
                else if (temp >= 10000 && temp <= 99999)
                {
                    Console.WriteLine(5);
                }
                else if (temp >= 1000 && temp <= 9999)
                {
                    Console.WriteLine(4);
                }
                else if (temp >= 100 && temp <= 999)
                {
                    Console.WriteLine(3);
                }
                else if (temp >= 10 && temp <= 99)
                {
                    Console.WriteLine(2);
                }
                else
                {
                    Console.WriteLine(1);
                }
            }
        }
    }
}



Measured memory_bytes: 15860
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

void solve(ll ts){
    string s; cin>>s; ll nu=0;
    for(auto i:s) nu+=(i-'0');
    if(nu%9==0) cout<<"Yes\n"; else cout<<"No\n";
}
 
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 3784
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    ans=max(a*c,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
}


Measured memory_bytes: 3224