akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        long a, b, c;
        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();

        long a_calc = 0;
        long b_calc = 0;
        long c_calc = 0;
        long min = 0;

        if (a%2 == 0 || b%2 == 0 || c%2 == 0){
            System.out.println(min);
        }else{
            a_calc = b*c;
            b_calc = a*c;
            c_calc = a*b;

            min = a_calc;
            if(min > b_calc)min = b_calc;
            if(min > c_calc)min = c_calc;
            System.out.println(min);
        }

    }
}

Measured memory_bytes: 21844
#include<iostream> 
#include<cmath>
#include<algorithm>
#define PI 3.1415926535
using namespace std;
double a,b,x;
bool check(double mid)
{
	if(b/tan(mid/180*PI)>a)
	{
		if(x<a*(0.5*a*a*tan(mid/180*PI)+a*(b-a*tan(mid/180*PI))))return 1;
		else return 0;
	}
	else
	{
		if(x<a*b*b/tan(mid/180*PI)*0.5)return 1;
		else return 0;
	}
}
int main()
{
	cin>>a>>b>>x;
	double l=0,r=90,mid;
	while(r-l>1e-12)
	{
		mid=(l+r)/2;
		if(check(mid))//如果不流出去 
		{
			l=mid;
		}
		else
		{
			r=mid;
		}
	}
	printf("%.10lf",r);
	return 0;
}

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

using namespace std;
#define int long long

int nbo,poidsmax;
int maxvalue[100][100001];
int values[100];
int poids[100];

signed main()
{
    ios::sync_with_stdio(false);
    cin>>nbo>>poidsmax;
    for(int i = 0 ; i < nbo ; i++)
    {
        cin>>poids[i]>>values[i];
        for(int j = 0 ; j <= poidsmax ; j++)
        {
            maxvalue[i][j]=0;
        }
    }
    for(int i = poids[nbo-1] ; i<=poidsmax ; i++)
    {
        maxvalue[nbo-1][i]= values[nbo-1];
    }
    for(int i = nbo-2 ; i>=0 ; i--)
    {
        for(int j = 0 ; j <= poidsmax ;j ++)
        {
            maxvalue[i][j]=maxvalue[i+1][j];
            //cout<<maxvalue[i][j]<<" ";
        }
        //cout<<endl;
        for(int j = poidsmax-poids[i]; j>=0 ;j --)
        {
            //cout<<maxvalue[i][j+poids[i]]<<" vs "<<maxvalue[i][j]+values[i]<<endl;
            maxvalue[i][j+poids[i]]= max(maxvalue[i][j+poids[i]],maxvalue[i][j]+values[i]);
        }
        
    }
    int maxi = -1 ;
    for(int i = 0 ; i <=poidsmax ; i++)
    {
        //cout<<i<<" "<<maxvalue[0][i]<<endl;
        maxi = max(maxi,maxvalue[0][i]);
    }
    cout<<maxi;
}


Measured memory_bytes: 78336
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N;
	cin >> N;
	vector<int>A(N, 0);
	FOR(N)
		cin >> A[i];
	FOR(N) {
		if (!(A[i] % 2) &&( (A[i] % 3) && (A[i] % 5))) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << ((a > 9 || b > 9) ? -1 : a * b);
}


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

int main() {
  int h, w;
  cin >> h >> w;

  map<int, int> s;
  multiset<int> vals;

  rep(i, w) s[i] = i;
  rep(i, w) vals.insert(0);

  rep(i, h) {
    int l, r;
    cin >> l >> r;
    --l;
    auto it = s.lower_bound(l);
    int mr = -1;
    while (it != s.end() && it->first <= r) {
      mr = max(mr, it->second);
      int x = it->first - it->second;
      vals.erase(vals.find(x));
      s.erase(it++);
    }
    if (mr != -1 && r < w) {
      vals.insert(r - mr);
      s[r] = mr;
    }
    int ans = -1;
    if (vals.size() > 0) {
      ans = *vals.begin() + (i + 1);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 22324
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int k; string str; cin>>k>>str;
    if(str.size()<=k) cout<<str;
    else{
        for(int i=0;i<k;i++) cout<<str[i];
        for(int i=1;i<=3;i++) cout<<".";
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N,M,Q;cin>>N>>M>>Q;
	vector<int> vec[N];
	rep(i,0,M){
		int l,r; cin>>l>>r; l--; r--;
		vec[l].push_back(r);
	}
	rep(i,0,N) sort(vec[i].begin(), vec[i].end());
	rep(i,0,Q){
		int p,q; cin>>p>>q; p--; q--;
		int res = 0;
		rep(j,p,q+1) res += upper_bound(vec[j].begin(), vec[j].end(), q) - vec[j].begin();
		cout<<res<<endl;
	}
}

Measured memory_bytes: 2176
def main():
    _ = int(input())
    nums_list = list(map(int, input().split()))

    for num in nums_list:
        if num % 2 == 0 and (num % 3 != 0 and num % 5 != 0):
            print('DENIED')
            return
    else:
        print('APPROVED')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<iomanip>

using namespace std;
int func(double x);

int main() {

	double total=0;
	double N,A=0;
	cin >> N;


	vector<long long> x(N);
	vector<long long> y(N);

	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		cin >> y[i];

	}

	for (int i = 0; i < N; i++)
	{
			for (int j = 0; j < N; j++&& i!=j)
			{
				A +=sqrt(((x[i]-x[j])*(x[i] - x[j]) +(y[i]-y[j])*(y[i]-y[j])))*func(N - 1) / func(N);
			}
	}

	cout << std::setprecision(12) << A;
}

int func(double x)
{
	if (x > 1) {
		x *= func(x - 1);
	}
	return x;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    vector<int>a(5);
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    for(int i=0;i<5;i++){
        if(a[i]!=i+1){
            cout<<i+1<<endl;
        }
    }
}


Measured memory_bytes: 3556
#include <iostream>
using namespace std;
 
int main() {
    int a[101][101];
    int n;
    int m;
    int b[101];
    int c;
    cin>>n>>m;
 
    for( int i=1; i<n+1; i++){
        for( int j=1; j<m+1; j++){
            cin>>a[i][j];
        }
    }
    for( int i=1; i<m+1; i++)cin>>b[i];
    for( int i=1; i<n+1; i++){
        c=0;
        for( int j=1; j<m+1; j++){
            c+=a[i][j]*b[j];
        }
        cout<<c<<endl;
    }
 
}

Measured memory_bytes: 3108
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair
#define RANK       first
#define NUM        second

typedef long long ll;

ll val[255];

ll convert(string &in,ll base){
  ll now = 1;
  ll ret=0;
  for(int i=in.size()-1;i>=0;i--){
    ret+=(val[in[i]])*now;
    now*=base;
  }
  return ret;
}

void fact(int n,int *base,int *basenum,int &p){
  for(int i=2;i<=n;i++){
    if (n%i == 0){
      base[p]=i;
      basenum[p]=0;
      while(true){
	if (n/i == 0 || n%i != 0)break;
	n/=i;
	basenum[p]++;
      }
      p++;
    }
  }
}

ll count(int p,int *basenum,ll *cnt){
  ll ret=(1LL<<62);
  rep(i,p){
    ret=min(ret,cnt[i]/basenum[i]);
  }
  return ret;
}

main(){
  for(int i=0;i<10;i++){
    val['0'+i]=i;
  }
  for(int i='A';i<='Z';i++){
    val[i]=i-'A' + 10;
  }
  ll in;string inp;
  int base[100];
  int basenum[100];
  ll cnt[100];
  int num[100];

  while(cin>>in>>inp && in){
    ll tmp = convert(inp,in);
    ll ans = 0;
    int p=0;
    fact(in,base,basenum,p);
    
    rep(i,p){
      cnt[i]=0;
      ll now = base[i];
      while(true){
	if (tmp/now == 0)break;
	cnt[i]+=tmp/now;
	now*=base[i];
      }
    }
    cout << count(p,basenum,cnt) << endl;
  }
}

Measured memory_bytes: 928
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/*
 * 引き分けが存在しない場合(C = 0)を考える.
 * 高橋くんが勝つには青木くんがk回(0 <= k <= N - 1)勝利, 高橋くんがN-1回勝利
 * した状態で高橋くんが勝てば良い. 勝負が行われる回数の期待値は
 * sum(k from 0 to N - 1) (k + N) * comb(N - 1 + k, k) * (A/100)**(N-1) * (B/100)**k
 * 引き分けが存在する場合を考える.
 * 1回勝負が着くまでの期待値は 100/(100 - C) と書ける.
 * よって上としたの式の積が答え
 * 高橋くんの勝つ確率は A/(A+B), 青木くんが勝つ確率は B/(A+B) とみなす
 *
 * (100)/(100-C) * sum(k from 0 to N - 1) (K + N) * comb(N-1+k,k)
 *   * (A/(A+B)) ** (N-1) * (B/(A+B)) ** k
 */

int powmod(int a, int p, int mod) {
    int ans = 1;
    int mul = a;

    for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
        if ((p & 1) == 1) ans = (ans * mul) % mod;
    }

    return ans;
}

class Combination {
public:
    int N;
    int mod;
    vector<int> fact;
    vector<int> revFact;

    Combination(int n, int m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2, MOD);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    int get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

signed main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    Combination comb = Combination(2 * N, MOD);

    int aab = powmod((A * powmod(A + B, MOD - 2, MOD)) % MOD, N, MOD);
    int bab = powmod((B * powmod(A + B, MOD - 2, MOD)) % MOD, N, MOD);
    int ret = 0;

    for (int k = 0; k < N; k++) {
        int tmp = (aab * powmod((B * powmod(A + B, MOD-2, MOD)) % MOD, k, MOD)) % MOD;
        tmp += (bab * powmod((A * powmod(A + B, MOD-2, MOD)) % MOD, k, MOD)) % MOD;
        tmp %= MOD;
        tmp *= (k + N);
        tmp %= MOD;
        tmp *= comb.get(N-1+k, k);
        tmp %= MOD;

        ret += tmp;
        ret %= MOD;
    }

    ret = (ret * 100) % MOD;
    ret = (ret * powmod(100-C, MOD-2, MOD)) % MOD;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3328
/*  Perseverance can make miracle happens  */
/* If u identify me then u r my frnd */

#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define vi vector<int>
#define pq priority_queue<int>
#define mpi map<int,int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define M 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

//---------------------------------------------------------------------------------------------------------------------------------//

int mod(long long x) {
	return ((x % M + M) % M);
}
int add(int a, int b) {
	return mod(mod(a) + mod(b));
}
int diff(int a, int b) {
	return mod(mod(a) - mod(b));
}

int mul(int a, int b) {
	return mod(mod(a) * mod(b));
}

//---------------------------------------------------------------------------------------------------------------------------------//

void solve() {
	string s;
	cin >> s;

	int n = s.length() - 1;
	string a = "es";
	if (s[n] != 's') {
		s = s + 's';
	}
	else {

		s = s + 'e';
		s = s + 's';
	}
	cout << s << endl;





}


int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	// int t; cin >> t;
	int t = 1;

	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A;
 int B;
 int C;
 cin >> A >> B >> C;

 if (A < C && C < B){
 cout << "Yes" <<endl;
 }

else if (B < C && C < A){
cout << "Yes" <<endl;
}
else {
cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    int X,Y;
    cin >> X >> Y;
    int ans = 2e9+1;
    for(int i=0;i<2;i++) for(int j=0;j<2;j++){
        int x = (i? -X:X),y = (j? -Y:Y);
        if(x<=y) ans = min(ans,i+j+y-x);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
n = gets.to_i
hash = Hash.new(0)
n.times do
  s = gets.chomp
  hash[s] += 1
end
arr = []
i = 0
temp = 0
hash.sort_by{|k,v| -v}.each do |k,v|
  if v < temp && i > 0
    break
  end
  arr << k
  temp = v if i.zero?
  i += 1
end
puts arr.sort


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

const int mod=1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int>dp(n+1, -1);
  dp[0]=1;
  dp[1]=1;
  for(int i=0; i<m; i++){
    int tmp;
    cin >> tmp;
    dp[tmp]=0;
  }
  for(int i=2; i<=n; i++){
    if(dp[i]==0)continue;
    dp[i]=(dp[i-2]+dp[i-1])%mod;
  }
  cout << dp[n];
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int monsterHealth = input.nextInt();
        int attacks= input.nextInt();
        int neededAttack =(int) Math.ceil((double)monsterHealth/attacks);
        System.out.println(neededAttack);
    }
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <stdlib.h>

#define MAX 1000



int main(){

	int n,r;
	int p,c;
	int i,j;
	int number[MAX];
	int buffer[MAX];
	int index;

	while(1){

		scanf("%d %d",&n,&r);			

		if(n == 0 && r == 0){
			return 0;
		}

		for(i=0; i<n; i++){
			number[n-i-1] = i+1;
		}
		/*
		for(j=0;j<n;j++){
			printf("%d ",number[j]);
		}
		printf("\n");
		*/


		for(i=0; i<r; i++){
			scanf("%d %d",&p,&c);
			index = 0;
			for(j=0; j<c; j++){
				buffer[index] = number[p-1+j];
				index++;
			}
			for(j=0; j<p-1; j++){
				buffer[index] = number[j];
				index++;
			}

			for(j=p-1+c; j<n; j++){
				buffer[index] = number[j];
				index++;
			}
			for(j=0; j<n; j++){
				number[j] = buffer[j];
			}
			/*
			for(j=0;j<n;j++){
				printf("%d ",number[j]);
			}
			printf("\n");
			*/
		}
		printf("%d\n",number[0]);

	}

	return 0;
	
}

Measured memory_bytes: 608
N = int(input())
S = [input() for i in range(N)]
count_AC, count_WA, count_TLE, count_RE = 0, 0, 0, 0
for s in S:
    if s == 'AC':
        count_AC+=1
    elif s == 'WA':
        count_WA+=1
    elif s == 'TLE':
        count_TLE+=1
    else:
        count_RE+=1

print('AC x '+str(count_AC))
print('WA x '+str(count_WA))
print('TLE x '+str(count_TLE))
print('RE x '+str(count_RE))

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c1, c2;
  int a[3] = {1,0,0};
  while(~scanf("%c,%c\n",&c1,&c2))
    swap(a[c1-'A'],a[c2-'A']);
  REP(i,3) if(a[i]==1) printf("%c\n",'A'+i);
  return 0;
}

Measured memory_bytes: 1196
n = []
while True:
    try:
        tmp = int(input())
        if tmp == 0:
            break
        else:
            n.append(tmp)
    except EOFError:
        break

for i in range(len(n)):
    c = 0
    d = 5
    for j in range(1,n[i]+1):
        while d <= n[i]:
            c += (n[i]//d)
            d *= 5
    print(c)

Measured memory_bytes: 7608
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,K=mi()
    ans = set()
    for i in range(A,A+K):
        if A<=i<=B:
            ans.add(i)
    
    for i in range(B-K+1,B+1):
        if A<=i<=B:
            ans.add(i)
    
    ans = list(ans)
    ans.sort()
    print(*ans,sep='\n')







if __name__ == "__main__":
    main()

Measured memory_bytes: 9240
N = int(input())
S = input()

alphabets = 'abcdefghijklmnopqrstuvwxyz'.upper()

for letter in S:
    index = alphabets.index(letter)
    if index + N > 25:
        new_index = index + N - 26
    else:
        new_index = index + N

    print(alphabets[new_index], end='')


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

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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


int main(void) {
	int a, b, c, x, y;
	int count = 0;
	int point = 0;

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

	point = x*a + y*b;
	FOR(i, 1, max(x,y)) {
		count = max(0, x - i)*a + max(0, y - i)*b + c*(i * 2);
		if (count < point) {
			point = count;
		}
	}
	cout << point << endl;


	return 0;
}



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

int main() {
string N;
  cin >>N;
  if((N[0]==N[1] &&N[1]==N[2]) || N[1]==N[2] &&N[2]==N[3]){
    cout <<"Yes";
  }
  else{
    cout <<"No";
    
  }
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n = int(input())
s = input()
q = int(input())

### BIT 
def init(bit, values):
    for i,v in enumerate(values):
        update(bit,i,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def update(bit,i,x):
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return

l = [chr(v) for v in range(ord("a"), ord("z")+1)]
d = {c: [0] * (n+1) for c in l}
for i,c in enumerate(s):
    update(d[c], i+1, 1)
s = list(s)
ans = []
for i in range(q):
    v,i,c = input().split()
    if v=="1":
        i = int(i)-1
        if d[s[i]][i+1]>=1:
            update(d[s[i]], i+1, -1)
        update(d[c], i+1, 1)
        s[i] = c
    else:
        ll,rr = int(i),int(c)
        val = sum(query(d[c], rr) - query(d[c], ll-1) >= 1 for c in l)
        ans.append(val)
write("\n".join(map(str, ans)))

Measured memory_bytes: 207612
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
typedef vector<int> vi;
typedef pair<int , int> ii;
int mod = 1000 * 1000 * 1000 + 7;
ll Q , H , S , D , N;
int main()
{
    //freopen("input.txt" , "r" , stdin);
    scanf("%lld %lld %lld %lld %lld" , &Q , &H , &S , &D , &N);
    D = min(S << 1 , D);
    D = min(H << 2 , D);
    D = min(Q << 3 , D);
    S = min(H << 1 , S);
    S = min(Q << 2 , S);
    cout << (N / 2) * D  + (N % 2) * S;
}


Measured memory_bytes: 256
N = gets.to_i
L = gets.split.map(&:to_i).group_by(&:itself).map{|k,ary| [k,ary.count]}

p L.combination(3).map{|a,b,c|
    ans = 0
    if a[0]+b[0]>c[0] && b[0]+c[0]>a[0] && a[0]+c[0]>b[0] then
        ans = a[1] * b[1] * c[1]
    end
    ans
}.sum

Measured memory_bytes: 15768
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include<math.h>
#define ll long long int
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int main(void){
	int N;
	scanf("%d",&N);
	ll A,B=0;
	bool ok=true;
	for(int i=0;i<N;i++){
		scanf("%d",&A);
		if(B>A){
			ok=false;
			break;
		}
		if(B==A){
			B=A;
		}else{
			A--;
			B=A;
		}
	}
	if(ok)printf("Yes");
	else printf("No");
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

    ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

    ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,const ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

mint calc(int H,int W){
    mint ans=mint(2).pow(H)+mint(2).pow(W)-1;
    
    
    int g=gcd(H,W);
    ans+=mint(2).pow(g)-2;
    return ans;
}

signed main(){
    int H,W,T;
    cin>>H>>W>>T;

    int gh=gcd(H,T);
    int gw=gcd(W,T);


    mint ans=calc(H/gh,W/gw).pow(gh*gw);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String a =sc.nextLine();
    	StringBuffer sb = new StringBuffer(a);
		String dst = sb.reverse().toString();

    	if(a.length()==3){
    		System.out.println(dst);
    	}else{
    		System.out.println(a);
    	}

    }

}

Measured memory_bytes: 24660
V=int(input())

G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]

import heapq

def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
    
    while(len(q)):
        
        p=heapq.heappop(q)
        v=p[1]
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                
                heapq.heappush(q, (d[e[0]], e[0]))

import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
    
dijkstra(0)
for i,c in enumerate(d):
    print(i, c)
    

    

Measured memory_bytes: 41604
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  string sta;
  REP(i,26) sta += 'a' + i;
  REP(i,26) sta += 'A' + i;
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> lst(n);
    REP(i,n) cin>>lst[i];
    string s;
    cin>>s;
    int m=s.size();
    REP(i,m) {
      int ind = find(begin(sta),end(sta),s[i]) - begin(sta);
      ind += 52 - lst[i%n];
      ind %= 52;
      cout << sta[ind];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int r,D,x,xx;
  cin >> r >> D >> x;
  for(int i = 0;i < 10;i++){
    xx = r*x - D;
    cout << xx << endl;
    x = xx;
  }
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool dp[80][80][20000];
int A[80][80],B[80][80];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<20000;k++){
            dp[i][j][k]=0;
            }
            int x=A[i][j]-B[i][j];
            if(i==0&&j==0){
            dp[i][j][10000+x]=1;
            }
            for(int k=100;k+100<20000;k++){
            if(i>0){
                dp[i][j][k]|=dp[i-1][j][k-x];
                dp[i][j][k]|=dp[i-1][j][k+x];
            }
            if(j>0){
                dp[i][j][k]|=dp[i][j-1][k-x];
                dp[i][j][k]|=dp[i][j-1][k+x];
            }
            }
        }
    }
    int ans=1e9;
    for(int i=0;i<20000;i++){
      if(dp[h-1][w-1][i]){
          ans=min(ans,abs(i-10000));
      }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 125312
#include<iostream>
#include<vector>
using namespace std;
int d(int a,int b){
	int c=a-b;
	if(c<0){
		c*=-1;
	}
	return c;
}

int main(void){
int n;
cin>>n;
int x,y,t,nx=0,ny=0,nt=0;
bool f=true;
	for(int i=0;i<n;i++){
		cin>>t>>x>>y;
		if(t-nt<d(x,nx)+d(y,ny)||((t-nt)%2)!=((d(nx,x)+d(ny,y))%2)){
		//	cout<<t-nt<<' '<<d(x,nx)<<' '<<d(y,ny)<<endl;
			f=false;
		}else{
			nt=t;
			nx=x;
			ny=y;
		}
	}
	if(f){
	cout<<"Yes"<<endl;}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;

struct Edge{
    int to,from; ll cost;
    Edge(){}
    Edge(int to,int from,ll cost):to(to),from(from),cost(cost){}
};
bool operator<(const Edge& x,const Edge& y){
    return x.cost<y.cost;
}

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

int main(){
    int n,h,w; cin >> n >> h >> w;
    vector<Edge> v;
    for(int i=0;i<n;i++){
        int r,c,a; cin >> r >> c >> a;
        r--; c--;
        v.push_back(Edge(r,c+h,a));
    }
    ll ans=0;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    UnionFind uf(h+w);

    for(int i=0;i<n;i++){
        if(!uf.same(v[i].from,v[i].to)){
            if(uf.done[uf.find(v[i].from)]&&uf.done[uf.find(v[i].to)])continue;
            uf.unite(v[i].from,v[i].to);
            ans+=v[i].cost;
        }
        else{
            if(!uf.done[uf.find(v[i].from)]){
                uf.done[uf.find(v[i].from)]=true;
                ans+=v[i].cost;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3440
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

/* field_t
		point connected to
*/
typedef vector<vector<int> > field_t;
/* dis_t
		distance
*/
typedef vector<int> dist_t;

void cal(const field_t field, int* dist, int start){
	queue<int> q;
	q.push(start);

	while(!q.empty()){
		int cur = q.front(); q.pop();
		if(dist[cur-1]!=-1){
			vector<int> next = field[cur-1];
			while(!next.empty()){
				int next_t = next[0]; next.erase(next.begin());
				if(dist[next_t-1]==-1){
					dist[next_t-1]=dist[cur-1]+1;
					q.push(next_t);
				}else{
					dist[next_t-1]=min(dist[cur-1]+1, dist[next_t-1]);
				}
			}
		}
	}
}

int main(void){
	int N;
	cin >> N;

	// init
	field_t field(N);
	dist_t dist_1(N, -1), dist_N(N, -1);

	//create field
	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;
		field[a-1].push_back(b);
		field[b-1].push_back(a);
	}
	dist_1[0]=0;
	dist_N[N-1]=0;

	cal(field, &dist_1.front(), 1);
	cal(field, &dist_N.front(), N);

	//compare
	int black = 0;
	int white = 0;
	for(int i=0; i<N; i++){
		if(dist_1[i] <= dist_N[i]){
			black ++;
		}else{
			white ++;
		}
	}
	if(black>white){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
	return 0;
}

Measured memory_bytes: 11992
N,M = map(int, input().split())
A = [int(a) for a in input().split()]

data = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
inf = -10**9
dp = [inf for i in range(N+1)]
dp[0] = 0
for i in range(1, N+1):
    for j in range(M):
        if i-data[A[j]] >= 0:
            dp[i] = max(dp[i], dp[i-data[A[j]]]+1)
            
ans = 0
A.sort(reverse=True)
n = dp[N]
i = n-1
temp = N
while i >= 0:
    j = 0
    while j < M:
        if temp-data[A[j]] >= 0:
            if dp[temp-data[A[j]]] == dp[temp]-1:
                temp -= data[A[j]]
                temp = max(temp, 0)
                ans += A[j]*10**i
                j = M
        j += 1
    i -= 1
    
print(ans)

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

int main(){
  bool zoro1=false,zoro2=false,zoro3=false;
  bool onetwothree=false;
  bool AllClear=false;
  int n;
  cin>>n;
  
  int d[n][2];
  rep(i,n)cin>>d[i][0]>>d[i][1];
  rep(i,n){
    if(d[i][0]==d[i][1])zoro1=true;
    if(d[i+1][0]==d[i+1][1])zoro2=true;
    if(d[i+2][0]==d[i+2][1])zoro3=true;
    
    if(zoro1 and zoro2 and zoro3){
      AllClear=true;
      break;
    }else{
      zoro1=false;
      zoro2=false;
      zoro3=false;
      continue;
    }
  }
    
  if(AllClear)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]int, 4)
	b := make([]int ,4)
	for scanner.Scan() {
		inputa := strings.Split(scanner.Text(), " ")
		for i := range a {
			a[i], _ = strconv.Atoi(inputa[i])
		}
		scanner.Scan()
		inputb := strings.Split(scanner.Text(), " ")
		for i := range b {
			b[i], _ = strconv.Atoi(inputb[i])
		}
		hit := 0
		blow := 0
		if a[0] == b[0] {
			hit++
		}
		if a[1] == b[1] {
			hit++
		}
		if a[2] == b[2] {
			hit++
		}
		if a[3] == b[3] {
			hit++
		}
		if a[0] == b[1] {
			blow++
		}
		if a[1] == b[2] {
			blow++
		}
		if a[2] == b[3] {
			blow++
		}
		if a[1] == b[0] {
			blow++
		}
		if a[2] == b[1] {
			blow++
		}
		if a[2] == b[0] {
			blow++
		}
		if a[3] == b[2] {
			blow++
		}
		if a[3] == b[1] {
			blow++
		}
		if a[3] == b[0] {
			blow++
		}
		if a[0] == b[2] {
			blow++
		}
		if a[1] == b[3] {
			blow++
		}
		if a[0] == b[3] {
			blow++
		}
		fmt.Printf("%d %d\n", hit, blow)
	}
}


Measured memory_bytes: 1096
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn=600010,mod=924844033,G=5;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
struct data{int v,nxt;}edge[maxn<<1];
int n,p,N,l,head[maxn],sz[maxn],fac[maxn],inv[maxn],rev[maxn];
int t[maxn],f[maxn],g[maxn];
int pls(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int dec(int x,int y){return x-y<0?x-y+mod:x-y;}
int c(int n,int m){return m>n?0:(ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int power(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=(ll)x*x%mod)
	  if(y&1)
	    res=(ll)res*x%mod;
	return res;
}
void insert(int u,int v)
{
	edge[++p]=(data){v,head[u]};head[u]=p;
	edge[++p]=(data){u,head[v]};head[v]=p;
}
void NTT(int *a,int f)
{
	for(int i=1;i<N;i++) if(i<rev[i]) swap(a[i],a[rev[i]]);
	for(int i=1;i<N;i<<=1)
	{
		int gn=power(G,(mod-1)/(i<<1));
		for(int j=0;j<N;j+=(i<<1))
		{
			int g=1,x,y;
			for(int k=0;k<i;++k,g=(ll)g*gn%mod)
			{
				x=a[j+k];y=(ll)g*a[j+k+i]%mod;
				a[j+k]=pls(x,y);a[j+k+i]=dec(x,y);
			}
		}
	}
	if(f==-1)
	{
		int iv=power(N,mod-2);reverse(a+1,a+N);
		for(int i=0;i<N;i++) a[i]=(ll)a[i]*iv%mod;
	}
}
void dfs(int x,int pre)
{
	sz[x]=1;
	for(int i=head[x];i;i=edge[i].nxt)
	  if(edge[i].v^pre)
	  {
	  	dfs(edge[i].v,x);
	  	sz[x]+=sz[edge[i].v];
	  	++t[sz[edge[i].v]];
	  }
	if(sz[x]<n) ++t[n-sz[x]];
}
void input()
{
	int u,v;
	read(n);
	for(int i=1;i<n;i++){read(u);read(v);insert(u,v);}
	dfs(1,1);fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=power(fac[n],mod-2);
	for(int i=n-1;~i;i--) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	for(l=0,N=1;N<=(n+n);N<<=1) ++l;
	for(int i=0;i<N;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1));
}
int main()
{
	input();
	for(int i=1;i<=n;i++) t[i]=(ll)fac[i]*t[i]%mod;
	for(int i=0;i<=n;i++) g[i]=inv[i];
	reverse(t,t+n+1);
	NTT(t,1);NTT(g,1);
	for(int i=0;i<N;i++) g[i]=(ll)g[i]*t[i]%mod;
	NTT(g,-1);
	for(int i=0;i<=n;i++) f[i]=((ll)n*c(n,i)%mod+(ll)g[n-i]*dec(0,inv[i]))%mod;
	for(int i=1;i<=n;i++) printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 32512
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let mut dist: HashMap<i64, i64> = HashMap::new();
  let mut a = vec![];
  let mut b = vec![];

  for _ in 0..x {
    let a = read::<i64>();
    let current = dist.entry(a).or_insert(0);
    *current += 1;
  }

  for (k, v) in dist.iter() {
    if 2 <= *v {
      a.push(k);
    }
    if 4 <= *v {
      b.push(k);
    }
  }

  if a.len() < 2 {
    println!("{}", 0)
  } else {
    a.sort();
    let mut ans = a[a.len() as usize - 1] * a[a.len() as usize - 2];
    if 1 <= b.len() {
      b.sort();
      ans = max(ans, b[b.len() - 1] * b[b.len() - 1])
    }
    println!("{}", ans)
  }

}



Measured memory_bytes: 12540
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int K = sc.nextInt();
        if (K < 10) {
            System.out.println(K);
            return;
        }
        int[] ret = new int[10];
        ret[0] = 1;
        for (int i = 1; i < K; i++) {
            ret = getNext(ret);
        }
        int i = 9;
        for (; ret[i] == 0; i--);
        for (; i >= 0; i--)
            System.out.print(ret[i]);
        System.out.println();
    }

    private static int[] getNext(int[] n) {
        int length = 10;
        for (;length > 0 && n[length - 1] == 0; length--);
        int i = 0;
        for (; i <= length; i++) {
            n[i]++;
            if (n[i] > 9 || i == length) continue;
            if (i == length - 1 || n[i + 1] - n[i] >= -1) {
                i++;
                break;
            }
        }
        for (i--; i > 0; i--) {
            n[i - 1] = Math.max(0, n[i] - 1);
        }
        return n;
    }
}


Measured memory_bytes: 24148
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	vector<vector<ll>> A(3, vector<ll>(3, 0));

	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> A[i][j];
		}
	}
		
	int N;
	cin >> N;

	vector<vector<bool>> B(3, vector<bool>(3, 0));

	rep(k, N)
	{
		ll b;
		cin >> b;

		bool flg = false;

		rep(i, 3)
		{
			rep(j, 3)
			{
				if (b == A[i][j])
				{
					B[i][j] = true;
					flg = true;
					break;
				}
			}

			if(flg) break;
		}
	}

	if (B[0][0] && B[0][1] && B[0][2]
		|| B[1][0] && B[1][1] && B[1][2]
		|| B[2][0] && B[2][1] && B[2][2]
		|| B[0][0] && B[1][0] && B[2][0]
		|| B[0][1] && B[1][1] && B[2][1]
		|| B[0][2] && B[1][2] && B[2][2]
		|| B[0][0] && B[1][1] && B[2][2]
		|| B[0][2] && B[1][1] && B[0][2]
			)
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int combination(int n,int m){
    if(n<m) return 0;
    if(n==m || m==0) return 1;

    return combination(n-1,m-1) + combination(n-1,m);
}

int main(){
    int N,M;
    cin >> N >> M;

    cout << combination(N,2)+combination(M,2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    string T;
    cin>>S>>T;
    T.pop_back();
    cout<<(S == T ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		int flag = 0;

		for (int i=0; i < n;i++){
			long l = sc.nextLong();

			if (l%2 == 0) {
				if (flag == 1 && l != 0){
					ans += 1;
					l = l - 1;
					flag = 1;
				} else {
					flag = 0;
				}
				ans += l/2;

			} else {
				if (flag == 1) {
					ans += 1;
					flag = 0;
				} else {
					flag = 1;
				}
				ans += l/2;

			}
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23696
#include "bits/stdc++.h"
using namespace std;

int main() {

	int N, K;
	cin >> N >> K;
	vector<int> vec(K);
	for (int i = 0; i < K; i++) cin >> vec.at(i);

	int res = N;
	while (true) {
		string s = to_string(res);
		for (int i = 0; i < K; i++) {
			for (int j = 0; j < s.size(); j++) {
				if (vec.at(i) == (int)(s.at(j) - '0')) goto NEXT_LOOP;
			}
		}
		break;

		NEXT_LOOP:
		res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5 + 4;
  vi adj[maxn];
  vi vis(maxn);
  int dfs(int src){
    vis[src]=1;
    int cnt=1;
    for(int x:adj[src]){
      if(!vis[x]){
         cnt += dfs(x);
      }
    } 
    return cnt;
  }
  
  
  
  void solve(){
    map<pair<int,int>,int>mp;
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      if(mp[{min(a,b),max(a,b)}]==1)continue;
      else{
        adj[a].pb(b);
        adj[b].pb(a);
        mp[{min(a,b),max(a,b)}]=1;
      }
    }
    int mx=0;
    for(int i=1;i<=n;i++){
       if(!vis[i]){
          mx = max(mx,dfs(i));
       }
    }
    cout << mx;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

Measured memory_bytes: 33604
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int i,j;
    int a,b,t;
    int bis=0;

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

    for (i=1;i<(t+1);i++){
        if (i%a==0){
            bis+=b;
        }
    }

    printf("%d",bis);
    return 0;
}


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

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

    sort(p.begin(),p.end());
    p[n-1] /= 2;

    int ans = 0;
    rep(i,n) ans += p[i];

    cout << ans << endl;
}


Measured memory_bytes: 256
# https://atc_oder.jp/contests/abc170/tasks/abc170_c
# at_coder_friends test-all B.rb
# require 'pry'

X, N = gets.split.map(&:to_i)
if N == 0
  puts X
else
  ps = gets.split.map(&:to_i)
  min, max = ps.minmax

  s_min = min - 1
  e_max = max + 1

  ts = (s_min..e_max).to_a - ps

  abses = ts.map do |e|
    (e - X).abs
  end

  abses_min = abses.min

  min_indexes = abses.map.with_index do |e, i|
   i if e == abses_min 
  end.compact

  ans = min_indexes.map do |i|
    ts[i]
  end.min

  #p "ans=#{ans}, ts=#{ts}, abses#{abses}, min_indexes=#{min_indexes}"

  puts ans
end




Measured memory_bytes: 14280
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    print("Yes" if "7" in input() else "No")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 27224