akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {

    ll n1, n2, time;

    cin >> n1 >> n2 >> time;

    vector<ll> v1(n1 + 1);
    vector<ll> v2(n2 + 1);

    v1[0] = 0;
    v2[0] = 0;

    for(int i = 1; i <= n1; ++i) {
        ll num;
        cin >> num;

        v1[i] += num + v1[i - 1];

    }


    for(int i = 1; i <= n2; ++i) {
        ll num;

        cin >> num;


        v2[i] += num + v2[i - 1];
    }


    ll answer = 0;
    for(int i = 0; i <= n1; ++i) {

        if(v1[i] > time)
            break;

        ll left = 0;
        ll right = n2 + 1;

        while((right - left) > 1) {

            ll mid = (right + left) / 2;

            if(v1[i] + v2[mid] > time)
                right = mid;
            else
                left = mid;

        }

        answer = max(answer, i + left);

    }

    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 6424
A, B, K = gets.split.map &:to_i
if A+K-1 >= B-K+1
  (A..B).each do |e|
    puts e
  end
else
  (A...A+K).each do |e|
    puts e
  end

  (B-K+1..B).each do |e|
    puts e
  end
end

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int p[100009],f[100009];
main() {
	p[1]=1;

	for (int i=2; i<=100000; i++) {
		for (int j=2*i; j<=100000; j+=i)
			p[j]=1;
	}
	p[2]=0;
	for (int i=1; i<=100000; i++) {                                                                  //构造前缀和
		if(p[i]==0 && p[(i+1)/2]==0 && i!=2) {                                                       //如果该数满足要求，前缀和加1；否则不变
			f[i]=f[i-1]+1;
		} else f[i]=f[i-1];
	}
	int q;
	cin>>q;
	while(q--) {
		int l,r;
		cin>>l>>r;
		cout<<f[r]-f[l-1]<<endl   ;                                                                //对于每组询问，直接输出f[r]-f[l-1]
	}
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
	int n,m,g=0;
	cin>>m>>n;
	int x[m][n],e[4][m*n];
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>x[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n-1;j++){
			if(x[i][j]%2==1){
				e[0][g]=i+1;
				e[1][g]=j+1;
				e[2][g]=i+1;
				e[3][g]=j+2;
				g++;
				x[i][j]--;
				x[i][j+1]++;
			}
		}
		if(x[i][n-1]%2==1&&i<m-1){
			e[0][g]=i+1;
			e[1][g]=n;
			e[2][g]=i+2;
			e[3][g]=n;
			g++;
			x[i][n-1]--;
			x[i+1][n-1]++;
		} 
	}
	cout<<g<<endl;
	for(int i=0;i<g;i++)cout<<e[0][i]<<" "<<e[1][i]<<" "<<e[2][i]<<" "<<e[3][i]<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<((int)n);i++)
#define rep1(i,n) for(ll i=1;i<=((int)n);i++)
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";

typedef long long ll;
const ll maxn=100005;

long long n,a[5];
int main()
{
  while(cin>>n)
  {
    for(int i=0;i<5;i++) cin>>a[i];
    sort(a,a+5);
    cout<<(n-1)/a[0]+5<<"\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();

		int a1 = a % 10;
		int b1 = b % 10;
		int c1 = c % 10;
		int d1 = d % 10;
		int e1 = e % 10;

		int a10 = a;
		if(a%10 != 0) {
			a10 = (a/10 + 1) * 10;
		}
		int b10 = b;
		if(b%10 != 0) {
			b10 = (b/10 + 1) * 10;
		}
		int c10 = c;
		if(c%10 != 0) {
			c10 = (c/10 + 1) * 10;
		}
		int d10 = d;
		if(d%10 != 0) {
			d10 = (d/10 + 1) * 10;
		}
		int e10 = e;
		if(e%10 != 0) {
			e10 = (e/10 + 1) * 10;
		}
		int last = a;
		int last1 = a1;
		int last10 = a10;
		int other = b10 + c10 + d10 + e10;

		if(b1 != 0 && b1 < last1) {
			last = b;
			last1 = b1;
			other = other - b10 + last10;
			last10 = b10;
		}
		if(c1 != 0  && c1 < last1) {
			last = c;
			last1 = c1;
			other = other - c10 + last10;
			last10 = c10;
		}
		if(d1 != 0 && d1 < last1) {
			last = d;
			last1 = d1;
			other = other - d10 + last10;
			last10 = d10;
		}
		if(e1 != 0 && e1 < last1) {
			last = e;
			other = other - e10 + last10;
		}

		System.out.println(other + last);
	}

}

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

using namespace std;

#define int long long

#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 rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

signed main()
{
	int X; cin >> X;
	int cur = 100;

	int ans = 0;

	while (cur < X) {
		cur = cur + cur / 100;
		ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;
  if(A + B >= C)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vector<vector<pair<ll, ll>>> v(n);  // v[i][j] : 人iのj番目の証言
    rep(i, n) {
        ll a;
        cin >> a;
        rep(j, a) {
            ll x, y;
            cin >> x >> y;
            x--;
            v[i].pb(make_pair(x, y));
        }
    }

    ll ans = 0;
    for(ll b = 0; b < (1<<n); b++) {  // bのiビット目が1のとき人i(iは0-index)は正直者。0のとき不親切な人

        vl w(n);  // w[i] : 1のとき人iは正直者
        ll now = 0;
        rep(i, n) {
            if( b & (1<<i) ) {
                w[i] = 1;
                now++;
            }
        }

        ll flag = 0;
        rep(i, n) {
            if(w[i]) {
                rep(j, v[i].size()) {
                    if( w[v[i][j].first] != v[i][j].second ) {
                        flag = 1;
                        break;
                    }
                }
            }
            if(flag) {
                break;
            }
        }

        if(flag) {
            continue;
        }

        ans = max(ans, now);
    }

    out(ans);
    re0;
}

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

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();

        int m = sc.NextInt();

        int[] p = new int[m];
        string[] s = new string[m];
        for (int i = 0; i < m; i++)
        {
            p[i] = sc.NextInt() - 1;
            s[i] = sc.Next();
        }

        bool[] ac = new bool[n];
        int cnt = 0;

        int[] wa = new int[n];
        int w = 0;

        for (int i = 0; i < m; i++)
        {
            if (s[i] == "WA")
            {
                wa[p[i]]++;
            }
            else if (s[i] == "AC")
            {
                if (!ac[p[i]])
                {
                    ac[p[i]] = true;
                    cnt++;
                    w += wa[p[i]];
                }
            }
        }

        Console.WriteLine($"{cnt} {w}");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b;
    cin >> a >> b;
    a *= b;
    bool flg = false;
    for( int i = 1; i <= 3; ++i ) {
        if( a * i % 2 == 1 ) flg = true;

    }
    if( flg ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
int inf = 1e9 + 7;
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; }

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> data(n, vector<int>(3));
    rp(i, 0, n) {
        rp(j, 0, 3) {
            scanf("%d", &data.at(i).at(j));
        }
    }
    vector<vector<int>> dp(n, vector<int>(3, -1));
    rp(i, 0, 3) dp.at(0).at(i) = data.at(0).at(i);
    rp(i, 1, n) {
        rp(j, 0, 3) {
            rp(k, 0, 3) {
                if(j != k) chmax(dp.at(i).at(j), dp.at(i-1).at(k) + data.at(i).at(j));
            }
        }
    }
    int ans = -1;
    rp(i, 0, 3) chmax(ans, dp.at(n-1).at(i));
    printf("%d", ans);
    return 0;
} 

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


typedef long long ll;
using namespace std;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,A[3]; 
	cin>>n>>A[0]>>A[1]>>A[2];
    vector<pair<ll,ll>> Q(n);
    for( int i=0;i<n;i++ )
	{
        string s; cin>>s;
        Q[i] = make_pair(s[0]-'A', s[1]-'A');
    }
    vector<char> ans(n);
    for( int i=0;i<n;i++ )
    {
        int x = Q[i].first;
        int y = Q[i].second;
        if ( A[x]==0 && A[y]==0 )
		{
            cout<<"No\n";
            return 0;
        }
        int decide = x;
        if ( A[x]==1 && A[y]==1 )
		{
            if ( i+1<n && ( Q[i+1].first==y || Q[i+1].second==y ) )
                decide = y;
        }
		else if( A[x]>=A[y] )
		{
            decide = y;
        }
        ans[i] = "ABC"[decide];
        
    //    cout<<ans[i]<<endl;
        
		( decide==x ) ? ( A[x]++, A[y]-- ) : ( A[x]--, A[y]++ );
    }
    cout<<"Yes\n";
    for( int i=0;i<n;i++ ) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int n,k,mod;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 305
int f[N][N],C[N][N],s[N][N];
signed main()
{
	cin>>n>>k>>mod;
	C[0][0]=1;
	for(int i=1;i<=n+1;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	}
	for(int i=0;i<=k;i++) f[1][i]=f[0][i]=1;
	for(int i=k;i>=0;i--) s[1][i]=add(s[1][i+1],f[1][i]),s[0][i]=add(s[0][i+1],f[0][i]);
	for(int i=2;i<=n+1;i++)
	{
		for(int j=0;j<=k;j++)
		{
			for(int c=1;c<=i-1;c++)
			{
				f[i][j]=add(f[i][j],mul(f[i-c][j],s[c][j+1],C[i-2][c-1]));
			}
		}
		for(int j=k;j>=0;j--) s[i][j]=add(s[i][j+1],f[i][j]);
	}
	cout<<f[n+1][0]<<endl;
	// int ans=0;
	// for(int i=1;i<=k;i++) ans=add(ans,f[n][i]);
	// cout<<ans<<endl;
	return 0;
}




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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B;
    cin >> A >> B;
    if(B % A == 0) {
        printf("%lld\n", A + B);
    }
    else {
        printf("%lld\n", B - A);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    vector<int> a(3);
    for( int i = 0; i < 3 ; i++) cin >> a[i];
    
    sort( a.begin() , a.end() );
    for( int i = 0; i < 3 ; i++) {
        cout << a[i] ;
        if( i == 2 ) cout << endl;
        else cout << " ";
    }
    
    
}


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

using namespace std;
using ll = long long;

const int N = 405;
ll DP[ N ][ N ];
ll n, a[ N ];

ll dfs(int l = 1, int r = n) {
    if( l == r ) return 0LL;
    ll &ret = DP[ l ][ r ];
    if( ~ret ) return ret;
    ret = 4e18;
    for(int k = l; k <= n; k += 1)
        ret = min(ret, dfs(l, k) + dfs(k + 1, r) + a[ r ] - a[ l - 1 ]);
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i += 1)
        cin >> a[ i ], a[ i ] += a[ i - 1 ];

    memset(DP, -1, sizeof DP);
    cout << dfs() << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, k, d;
	cin >> n >> k >> d;
	if(n < 0) n = -n;
	if(double(n / d) < k){
//		cout << 'w';
		if(k % 2 == 1){
			cout << min((n + d) % (2 * d), -((n + d) % (2 * d) - 2 * d));
		}else{
			cout << min(n % (2 * d), -(n % (2 * d) - 2 * d));
		}
	}else cout << n - k * d << endl;
	return 0;
}
//100000000000001 10000000 10000000

Measured memory_bytes: 3624
n = int(input())
count = 0

def divs(n:int):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    # divs.sort()
    return divs

for i in range(1,n+1,2):
    if len(divs(i)) == 8:
        count += 1
print (count)

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }else if(a<=12){
        cout<<b/2<<endl;
    }else{
        cout<<b<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='+')n++;
        if(s[i]=='-')n--;
    }
    cout<<n<<endl;    
}

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

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

    vector<vector<int>> a(2, vector<int>(n));

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        int cnt = 0;
        for (int j = 0; j <= i; j++)
        {
            cnt += a[0][j];
        }
        for (int k = i; k < n; k++)
        {
            cnt += a[1][k];
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
vector<vector<int>>G;
void dfs(int v,int prev,int dis,int d[]){
    d[v]=dis;
    for(int nx :G[v]){
        if(nx==prev)continue;
        dfs(nx,v,dis+1,d);
    }
}
int main()
{
    int N;
    cin >> N;
    for(int i=0;i<N;i++)G.push_back(vector<int>());

    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int fen[N],snk[N];
    dfs(0,-1,0,fen);
    dfs(N-1,-1,0,snk);
    int cn=0;
    for(int i=0;i<N;i++){
        if(fen[i]<=snk[i])cn++;
        else cn--;
    }
    if(cn>0){
        cout << "Fennec" << endl;
    }
    else{
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1)*a%MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1)*a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size()>n) return kaijo_memo[n];
  if(kaijo_memo.size()==0) kaijo_memo.push_back(1);
  while(kaijo_memo.size()<=n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1]*kaijo_memo.size()%MOD);
  return kaijo_memo[n];
}

signed main(){
	int n; cin>>n;
	VI c(9,0);
	rep(i,n){
		int a; cin>>a;
		c[min(a/400,8)]++;
	}
	int cnt=0;
	rep(i,8){
		if(c[i]) cnt++;
	}
	cout<<max(1,cnt) SP cnt+c[8]<<endl;

	return 0;
}


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

int main(){
    int a;
    int b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }
    else if(a<b){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

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

        int X = sc.nextInt();
        int A = sc.nextInt();

        System.out.println(solve(X, A));

        sc.close();
    }

    static int solve(int X, int A) {
        return (X < A) ? 0 : 10;
    }
}

Measured memory_bytes: 35676
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

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

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push


ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}

/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;

    ll m,n;
    cin>>m>>n;

    cout << for_big_mod(m,n,1000000007) << endl;


    //main();

    rn0;
}

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	static long N;
	static long ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int ans=0;
		for(int i=0;i<N;i++) {
			int l=sc.nextInt();
			int r=sc.nextInt();
			ans+=r-l+1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25832
#include <stdio.h>
 int main(void) {
    int n, m, l, a[100][100], b[100][100], i, j, k;
    long num;
 
    scanf("%d %d %d", &n, &m, &l);
    for (i=0; i<n; i++) {
        for (j=0; j<m; j++) scanf("%d", &a[i][j]);
    }
    for (i=0; i<m; i++) {
        for (j=0; j<l; j++) scanf("%d", &b[i][j]);
    }
    for (i=0; i<n; i++) {
        for (k=0; k<l; k++) {
        num=0;
            for (j=0; j<m; j++) {
        num += a[i][j]*b[j][k];
            }
        printf("%ld", num);
            if (k!=l-1) printf(" ");
        }
        printf("\n");
    }
}


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

#define Fast_IO ios_base::sync_with_stdio(0); cin.tie(0);

typedef unsigned long long uLL;
typedef long long int LL;
const int N = 1e5 + 5;
const int inf = 1e9;
const LL INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int main( int argc , char const *argv[] ) {
        int n;
        cin >> n;
        while( 1 ) {
                int x = n;
                set <int> S;
                while( x ) {
                        S.insert( x%10 ) , x /= 10;
                }
                if( S.size() == 1 ) return cout << n <<endl,0;
                n++;
        }
        return 0;
}









Measured memory_bytes: 256
n=int(input())
s=input()

#n=19
#s='3141592653589793238'
psw=[]
ilist=[]
jlist=[]
klist=[]
for i in range(n-2):
    jlist=[]
    if s[i] in ilist:
        continue
    else:
        ilist.append(s[i])
        for j in range(i+1, n-1):
            klist=[]
            #print(j)
            if s[j] in jlist:
                continue
            else:
                jlist.append(s[j])    
                for k in range(j+1, n):
                    if s[k] in klist:
                        continue
                    else:
                        #print(i,j,k)
                        klist.append(s[k])
                        p=s[i]+s[j]+s[k]
                        psw.append(p)
print(len(psw))

Measured memory_bytes: 3064
N, M = map(int, input().split())
adj_matrix = [[0]*N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1

    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        used[i] = True
        ans += dfs(i, used)
        used[i] = False        
    return ans

used = [False] * N
used[0] = True
print(dfs(0, used))

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

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

int main() {

    int k, x;
    cin >> k >> x;

    for (int s = x - k + 1; s < min(x + k, 1000000); s++) {
        cout << s << endl;

    }

}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
dx = (x1 - x2)
dy = (y2 - y1)
x3 = x2 - dy
y3 = y2 - (dx)
x4 = x1 - dy
y4 = y1 - (dx)
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll  maxn=4e5+5,inf=1e9+5;
ll  x,l,r,mid,ans,y;
bool b;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>x;
	y=100;
	ans=0;
	while(y<x){
		l=y/100;
		y+=l;
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a==0&&b==0)break;
		System.out.printf("%d %d\n",Math.min(a, b),Math.max(a, b));
		}
}
}


Measured memory_bytes: 42812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
  int n;cin>>n;
    string s;cin>>s;
    vector<vector<int>> v(10);
    REP(i,n){
        v[(int)(s[i]-'0')].push_back(i);
    }
    int res=0;
    REP(i,10)REP(j,10)REP(k,10){
      bool f=false;
        REP(l,v[j].size()){
          
            if(!f && (!v[i].empty()) && (!v[k].empty()) && v[i][0]< v[j][l] && v[j][l]<v[k][v[k].size()-1]){
                res++;
                f=true;
           }
        }

    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 512
MOD = 10 ** 9 + 7

def main(n):
  result = [0, 0]
  for i in range(n-2):
    s = (sum(result[:-2]) + 1) % MOD 
    result.append(s)

  return result[n-1]


n = int(input())
print(main(n))

Measured memory_bytes: 9192
mod = 10**9 +7
n, a, b = map(int, input().split())

lis = []
on = 0 + n
count = 0
while on > 0:
  if on & 1 == 1:
    lis.append(count)
  count += 1
  on >>= 1

two = [2]
for _ in range(count-1):
  two.append(two[-1]*two[-1]%mod)

ans = 1
for item in lis:
  ans = ans * two[item] %mod

op = mod-2
invlis = []
count = 0
while op > 0:
  if op & 1 == 1:
    invlis.append(count)
  count += 1
  op >>= 1


def modinv(N):
  if N == 1:
    return 1
  else:
    res = 1
    Nlis = []
    for _ in range(count):
      Nlis.append(N%mod)
      N = N*N%mod
    for item in invlis:
      res = res * Nlis[item] %mod
    return res

ans_a = 1
for k in range(n-a+1, n+1):
  ans_a = ans_a*k%mod
amother = 1
for k in range(2, a+1):
  amother = amother * k % mod
ans_a = ans_a*modinv(amother)%mod

ans_b = 1
for k in range(n-b+1, n+1):
  ans_b = ans_b*k%mod
bmother = 1
for k in range(2, b+1):
  bmother = bmother * k % mod  
ans_b = ans_b*modinv(bmother)%mod

print((ans-ans_a-ans_b-1)%mod)

Measured memory_bytes: 65272
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string n;
	cin >> n;
	cout << (n[0] == n[2] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
	 	
  int count = 1;
  int x = k;
  
  while(x <= n){
 	x *= k;
    ++count;
  }
 
  cout << count << endl;
  
  return 0;
  
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll bitgauss(vector<ll> &a) {
  ll r = 0;
  int n = a.size();
  int rank = 0;
  for (int k = 60; k >= 0; k--) {
    for (int i = rank; i < n; i++) {
      if (a[i] & (1LL << k)) {
        swap(a[rank], a[i]);
        r |= (1LL << k);
        for (int j = 0; j < n; j++) {
          if (j == rank) continue;
          if (a[j] & (1LL << k)) {
            a[j] ^= a[rank];
          }
        }
        rank++;
        break;
      }
    }
  }
  return r;
}

int msb(ll bit) {
  for (int k = 60; k >= 0; k--) {
    if (bit & (1LL << k)) return k;
  }
  return -1;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<int> count(61);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 60; j++) {
      if (a[i] & (1LL << j)) count[j]++;
    }
  }
  ll A = 0;
  for (int i = 0; i < n; i++) {
    A ^= a[i];
  }

  ll mask = 0;
  for (int i = 0; i <= 60; i++) {
    if (count[i] % 2 == 0 && count[i] > 0) mask |= (1LL << i);
  }
  for (int i = 0; i < n; i++) {
    a[i] &= mask;
  }
  bitgauss(a);
  ll B = 0;
  for (int i = 0; i < n; i++) {
    ll m = msb(a[i]);
    if (m >= 0 && count[m] % 2 == 0) {
      B ^= a[i];
      for (int k = 0; k <= 60; k++) {
        if (a[i] & (1LL << k)) count[k]++;
      }
    }
  }
  cout << (A ^ B) + B << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define bitmax 20
using std::cin;
using std::cout;
int l;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> l;
    cout << bitmax << ' ';
    int ans = 36;
    if((l >> (bitmax - 1)) & 1)
      ans += 2;
    for(int i = (bitmax - 2); i >= 0; --i)
      if((l >> i) & 1) ++ ans;
    cout << ans << '\n';


    for(int i = bitmax - 1, j = 1; i > 1; --i, j <<= 1){
      cout << i << ' ' << (i + 1) << ' ' << j << '\n';
      cout << i << ' ' << (i + 1) << ' ' << 0 << '\n';
    }
    int j = 0;
    if((l >> (bitmax - 1)) & 1){
      cout << "1 2 0\n1 2 " << (1 << (bitmax - 2)) << '\n';
      j |= 1 << (bitmax - 1);
    }
    for(int i = (bitmax - 2); i >= 0; --i)
      if((l >> i) & 1){
        cout << 1 << ' ' << (bitmax - i) << ' ' << j << '\n';
        j |= 1 << i;
      }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
bool flag = false ;
int main() {
	int t ;
	cin >> t ;
	while(t--) {
		int a ;
		cin >> a ;
		if(a%2==0) {
			if(a%3==0||a%5==0) flag = false ;
			else {
				flag = true ;
				break ;
			}
		}
	}
	if(flag) cout << "DENIED" << endl;
	else cout << "APPROVED" << endl ;
	return 0 ;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[110];
int n, maxn;
int mj(int x){
int ans = 0;
for(int i =1 ;i <=n ;i++){
    ans+=(x-a[i])*(x-a[i]);
}
return ans;
}
int main()
{

cin>>n;
 maxn = -1;
for(int i = 1;i<=n;i++){
    cin>>a[i];
    maxn = max(a[i],maxn);
}
    int minn=0x3f3f3f3f;
for(int i = 1;i<=maxn;i++){
  minn=min(minn,mj(i))  ;
}
cout<<minn<<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);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int A[][] = new int[n][m];
		int B[][] = new int[m][l];
		int i,j,k;
		long c;
		for(i=0; i<n; i++){
			for(j=0; j<m; j++){
				A[i][j] = sc.nextInt();
			}
		}
		for(j=0; j<m; j++){
			for(k=0; k<l; k++){
				B[j][k] = sc.nextInt();
			}
		}
		for(i=0; i<n; i++){
			for(k=0; k<l; k++){
				c = 0;
				for(j=0; j<m; j++){
					c += ( A[i][j] * B[j][k] );
				}
				if(k!=0) System.out.print(" ");
				System.out.print(c);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 44884
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int i,n=s.length();
    for(i=0;i<n;i++){
        switch(s.at(i)){
            case 'A':
                cout << 'T';
                break;
            case 'T':
                cout << 'A';
                break;
            case 'C':
                cout << 'G';
                break;
            case 'G':
                cout << 'C';
                break;
            default:
                break;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type ll int64


func main() {

	var N int
	var L int
	fmt.Scan(&N,&L)


	abs_min := 100000//絶対値の最小

	value := 0
	sum := 0
	dis := 0

	for i:=0;i<N ; i++ {
		value = L + i
		sum += value

		if abs_min >= abs(value) { //絶対値の最小が一番小さくなるようにする
			abs_min = abs(value)
			dis = value
		}

	}


	fmt.Println(sum - dis)


}


func abs(value int) int {
	if value < 0 {
		value = -value
	}
	return value
}



Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, t;
ll f[31];
ll g[51];

int solve(){
	REP(i, n) g[i] = 1LL << i;
	for(int i=1;i<31;i++){
		ll to = 0LL;
		REP(j, n) if(1&(f[i]>>j)) to |= g[j];
		if(to == (1LL<<n)-1) return i;
		REP(j, n) if(1&(f[i]>>j)) g[j] = to;
	}
	return -1;
}

main(){
	int i,j;
	while(cin >> n, n){
		memset(f, 0, sizeof(f));
		REP(i, n){
			cin >> m;
			REP(j, m){
				cin >> t;
				f[t] |= 1LL << i;
			}
		}
		cout << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int A , B , C , X , Y;  cin >> A >> B >> C >> X >> Y;
  int C2 = C * 2; //Cを二枚買うときの値段
  int ans = 0;

  if(A + B <= C2){
    ans = A * X + B * Y;
  }else{
    int i = 0;  //iはC2を買う枚数
    while(i < X && i < Y){
      i++;
      ans += C2;
    }
    //今AかBを買う必要のある枚数が片っぽ0の状況
    if(X - i != 0 && C2 < A){
      ans += C2 * (X - i);
    }else if(Y - i != 0 && C2 < B){
      ans += C2 * (Y - i);
    }else{
      ans += A * (X - i) + B * (Y - i);
    }
  }

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

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

int main () {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  long long minPrice = INFINITY;
  for (int r = 0; r/2 <= max(x, y); r += 2) {
    int p = x - r/2;
    int q = y - r/2;
    if (p < 0) p = 0;
    if (q < 0) q = 0;
    long long price = p*a + q*b + r*c;
    minPrice = min(minPrice, price);
  }
  cout << minPrice << endl;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  const A: number[] = [];
  const B: number[] = [];
  for (let i = 0; i < N; i++) {
    A[i] = Number(input[i + 1][0]);
    B[i] = Number(input[i + 1][1]);
  }

  A.sort((a, b) => a - b);
  B.sort((a, b) => a - b);

  if (N % 2 === 0) {
    const minMedian = A[N / 2 - 1] + A[N / 2];
    const maxMedian = B[N / 2 - 1] + B[N / 2];

    return maxMedian - minMedian + 1;
  } else {
    const minMedian = A[(N + 1) / 2 - 1];
    const maxMedian = B[(N + 1) / 2 - 1];

    return maxMedian - minMedian + 1;
  }
};

console.log(main(read()));


Measured memory_bytes: 123728
def solve():
    from collections import deque
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    S = f_i.readline().rstrip()
    
    M *= -1
    pos = N
    rec = deque()
    while pos:
        for move in range(M, 0):
            next_pos = pos + move
            if next_pos >= 0 and S[next_pos] == '0':
                pos = next_pos
                rec.appendleft(move)
                break
        else:
            print(-1)
            break
    else:
        print(' '.join(str(-move) for move in rec))

solve()

Measured memory_bytes: 10916
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
} 
ll Logn(ll  n, ll r) 
{ 
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0; 
}
 
int main()
{
	FAST
	int t=1;
//	cin>>t;
	while(t--)
	{	
		ll a,b,n;
		cin>>a>>b>>n;
		cout<<(a*min(b-1,n))/b;
	}
    return 0;
}
  
 
 
 
 






Measured memory_bytes: 3648
long long w,s;
n,i,d[10000];
C(int*a,int*b){return*a-*b;}
main(){
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++)
			scanf("%d",d+i);
		qsort(d,n,4,C);
		for(w=s=i=0;i<n-1;i++)
			s+=w+=d[i];
		printf("%lld\n",s);
	}
	exit(0);
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;

int main() {
  string S; cin >> S;
  
  vector<bool> exist(26, false);
  for (int i=0; i<S.size(); i++) {
    exist[S[i] - 'a'] = true;
  }
  
  for (int i=0; i<exist.size(); i++) {
    if (!exist[i]) {
      cout << char(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 101;
static const int INFTY = (1 << 30);
int V;
vector<pair<int, int> > G[MAX];

void dijkstra(int r, int t) {
    priority_queue<pair<int, int> > pq;
    bool visited[MAX];
    int d[MAX];
    for (int i = 1; i <= V; i++) {
        visited[i] = false;
        d[i] = INFTY;
    }
    d[r] = 0;
    pq.push({0, r}); //dist from target * -1, current node
    visited[r] = true;

    while ( !pq.empty() ) {
        pair<int, int> f = pq.top(); pq.pop();
        int current = f.second;
        visited[current] = true;

        if (d[current] < f.first * (-1)) continue;

        for (unsigned long i = 0; i < G[current].size(); i++) {
            int target = G[current][i].first;
            if (visited[target]) continue;
            if (d[target] > d[current] + G[current][i].second) {
                d[target] = d[current] + G[current][i].second;
                pq.push({d[target] * (-1), target});
            }
        }
    }
    (d[t] == INFTY) ? cout << -1 << endl : cout << d[t] << endl;
}


int main()
{
    int k, q, source, target, cost;
    for (;;) {
        scanf("%d %d", &V, &k);
        if (V == 0 && k == 0) break;
        for (int i = 0; i < k; i++) {
            scanf("%d", &q);
            if (q == 1) {
                scanf("%d %d %d", &source, &target, &cost);
                G[source].push_back({target, cost});
                G[target].push_back({source, cost});
            }
            else if (q == 0) {
                scanf("%d %d", &source, &target);
                //if (rec[source][target] != -1) printf("%d\n", rec[source][target]);
                dijkstra(source, target);
            }
        }
        for (int i = 1; i <= V; i++) G[i].clear();
    }
    return 0;
}



Measured memory_bytes: 3180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

 int main() {
	 int X;
	 cin >> X;
	 int ans = 1;
	 for (int i = 2; i*i <= X; i++) {
		 int Y = i;
		 while (Y*i <= X) Y *= i;
		 ans = max(ans, Y);
	 }
	 cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n;
	ll h;cin>>n>>h;
	vint a(n), b(n);
	rep(i, n){
		cin>>a[i] >> b[i];
	}
	sort(all(a), greater<int>());
	sort(all(b), greater<int>());
	int m = a[0];
	int cou = 0;
	rep(i, n){
		if(b[i] <= m){
			break;
		}else{
			h-=b[i];
			cou++;
			if(h <= 0){
				cout << cou << endl;
				return 0;
			}
		}
	}
	cou += (h+m-1)/m;
	cout << cou << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int n = 0;
		for (int i = 0; i < N - 1; i++) {
			if (x >= a[i]) {
				n++;
			}
			x -= a[i];
			if(x <= 0) {
				break;
			}
		}

		if (x > 0 && x == a[N - 1]) {
			n++;
		}

		System.out.println(n);

		return;
	}

}


Measured memory_bytes: 21716