akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define read(a) scanf("%d", &a)
#define readl(a) scanf("%lld", &a)
#define reads(a) scanf("%s", a)
#define readf(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define debug(a, b) printf("%s = %d\n", a, b)
#define debug1(a, i, b) printf("%s[%d] = %d", a, i, b)
#define show(a) putchar(a)
#define pb emplace_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
typedef long long LL;
typedef int Int;
typedef double db;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
signed main()
{
    Buff;
    ll n, A, B;
    cin >> n >> A >> B;
    ll ans = n/(A + B) * A + min(n%(A+B), A);
    cout << ans << "\n";
    return 0;
}
/**

**/



Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s, t;
    cin >> s >> t;

    cout << t << s << "\n";
    return 0;
}

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

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

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

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

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

bool search(int a[], int n, int key)
{
    int i = 0;
    a[n] = key;
    while (a[i] != key)
    {
        i++;
    }
    return i != n;
}

int main()
{
    int n, a[10010], q, key, sum = 0;

    cin >> n;
    rep(i, 0, n) cin >> a[i];
    cin >> q;
    rep(i, 0, q)
    {
        cin >> key;
        if (search(a, n, key))
        {
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3160
AA = []

for i in range(3):
    AA.append(input().split())

N = int(input())
for i in range(N):
    bi = input()
    for i in range(3):
        aa = AA[i]
        for a in range(3):
            if bi == aa[a]:
                AA[i][a] = 'B'
            
# yoko
flag = 0
for i in range(3):
    aa = AA[i]
    flag = 1
    for j in range(3):
        if aa[j] != 'B':
            flag = 0 
    if flag == 1:
        break
# tate        
if flag == 0:
    for i in range(3):
        flag = 1
        for j in range(3):
            if AA[j][i] != 'B':
                flag = 0
        if flag == 1:
            break

# naname
if flag == 0:
    flag = 1
    for i in range(3):
        if AA[i][i] != 'B':
            flag = 0
if flag ==0: 
    flag = 1
    for i in range(3):
        if AA[i][2-i] != 'B':
            flag = 0

# print(AA)
            
if flag == 0:
    print('No')
else:
    print('Yes')
            
        
            
            

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,A[1000010],ans,last;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		A[x]++;
	}
	for(int i=0;i<=100010;i++){
		ans+=A[i];
		if(ans==n/2)last++;
	}
	cout<<last;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;




int main(){
    int N,M;
    cin >> N >> M;
    vector<P> v;
    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        x--,y--;
        v.pb(mp(y,x));
    }
    sort(ALL(v));
    int now=-1,ans=0;
    for(int i=0;i<v.size();i++){
        if(now<v[i].sc){
            now=v[i].fs-1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){
  double n,k;
  cin>>n>>k;

  double ans=0.0000000000;
  for(int i=1;i<=n;i++){
  if(i>=k) ans+=(1);
  else{
    double x=log2(k/i);
    double sho=x-(int)x;
    if(sho>0) x++;
    x-=sho;
    double tmp=(pow(0.5,x));
    ans+=(tmp);
  }
  }

  printf("%.10f\n",ans/n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //ABC 161_b
using namespace std;
#define ll long long
int n,m,a[105],sum,num;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double x=sum/(4.0*m);
	for(int i=1;i<=n;i++){
		if(a[i]>=x)
		num++;
	}
	if(num>=m)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main(void)
{
	char s[16], t[16];
	scanf("%s %s", s, t);

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

	char u[16];
	scanf("%s", u);

	if (!strcmp(s, u))
	{
		a--;
	}
	else
	{
		b--;
	}
	printf("%d %d\n", a, b);
	return 0;
}


Measured memory_bytes: 128
from fractions import gcd
from functools import reduce


def inpl():
    return list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def count2(i):
    t = 2
    ret = 1
    while i % t == 0:
        t *= 2
        ret += 1
    return ret - 1


N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = 1
c2 = count2(A[0])
for a in A:
    all_lcm = lcm(all_lcm, a)
    if count2(a) != c2:
        print(0)
        exit()

print(((M // all_lcm) + 1) // 2)


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

typedef long long lnt;
const lnt mod=1e9+7;
lnt a[100100],b[100010],min[100100],ch[100100];
int main(){
    int n,k,i;
    scanf("%d",&n);
    for(k=1;k<=n;k++) scanf("%lld",&a[k]);
    for(k=1;k<=n;k++) scanf("%lld",&b[k]);
    for(k=1;k<=n;k++) min[k]=std::min(a[k],b[k]);
    lnt ans=1;
    for(k=1;k<=n;k++){
        if(a[k]!=a[k-1]){
            ch[k]=1;
            if(a[k]>min[k]) ans=0;
        }
    }
    for(k=n;k>=1;k--){
        if(b[k]!=b[k+1]){
            ch[k]=1;
            if(b[k]>min[k]) ans=0;
        }
    }
    for(k=1;k<=n;k++){
        if(ch[k]) continue;
        ans*=min[k];
        ans%=mod;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 3328
n=int(input())
p=list(map(int,input().split()))
count=0
q = [i for i in range(1,n+1)]  
  
for j in range(0,n) :
  if(p[j]!=q[j]):
    count+=1
    
if(count==0 or count==2):
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (A, V) = readLine()!!.split(" ").map(String::toInt)
    val (B, W) = readLine()!!.split(" ").map(String::toInt)
    val T = readLine()!!.toInt()

    val distance = kotlin.math.abs(A - B)
    val move = V - W

    if(move < 1) {
        println("NO")
        return
    }

    val times = (distance / move) + (if (distance % move == 0) 0 else 1)

    println(if (T < times) "NO" else "YES")
}

Measured memory_bytes: 36352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	int N, A;
	int x[51];
	ll dp[51][51][2501];
	
	cin >> N >> A;
	for(int i = 1; i <= N; i++) cin >> x[i];
	
	for(int i = 0; i <= 50; i++){
		for(int j = 0; j <= 50; j++){
			for(int k = 0; k <= 2500; k++){
				if(i == 0 && j == 0 && k == 0) dp[i][j][k] = 1LL;
				else if(i >= 1 && k < x[i]) dp[i][j][k] = dp[i - 1][j][k];
				else if(i >= 1 && j >= 1 && k >= x[i]) dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
				else dp[i][j][k] = 0LL;
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ans += dp[N][i][i * A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll sum=0;
  for(ll i=1;i<=n;++i)
  {
    if(i%3!=0 && i%5!=0)
      sum+=i%M;
  }
	 cout<<sum<<"\n";
      return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
#include <map>

typedef long long LL;
const int MN = 20;

int N, A[MN];

struct dat {
	dat() {}
	int a, b, c, d;
	dat(int l, int r, int cl, int cr)
		: a(l), b(r), c(cl), d(cr) {}
	friend bool operator < (dat i, dat j) {
		if (i.a != j.a) return i.a < j.a;
		if (i.b != j.b) return i.b < j.b;
		if (i.c != j.c) return i.c < j.c;
		return i.d < j.d;
	}
};
std::map<dat, LL> f;
LL F(int l, int r, int cl, int cr) {
	dat now(l, r, cl, cr);
	if (f.find(now) != f.end()) return f[now];
	if (l > r) return 0;
	LL ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = l; i <= r; ++i)
		ans = std::min(ans, F(l, i - 1, cl, cl + cr) + (LL)A[i] * (cl + cr) + F(i + 1, r, cl + cr, cr));
	return f[now] = ans;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	N -= 2;
	printf("%lld\n", F(1, N, 1, 1) + A[0] + A[N + 1]);
	return 0;
}

Measured memory_bytes: 16512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CRepsept {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int K;
        cin >> K;
        int cnt = 0;
        int num = 0;
        while (cnt <= 10000000) {
            num *= 10;
            num += 7;
            num %= K;
            cnt++;
            if (num == 0) {
                cout << cnt << endl;
                return;
            }
        }
        cout << -1 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CRepsept solver;
    solver.solve(in, out);
    return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using u128 = __int128;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int T;
    cin >> T;
    while (T--) {
        ll N;
        vector<int> A(3);
        int D;
        cin >> N >> A[0] >> A[1] >> A[2] >> D;

        vector<int> primes = {2, 3, 5};

        map<ll, u128> m;
        m[0] = 0;

        function<u128(ll)> f = [&](ll n) {
            if (m.count(n)) {
                return m[n];
            }
            u128 tmp = (u128) n * D;
            REP(i, primes.size()) {
                int p = primes[i];
                ll k0 = n / p;
                ll k1 = (n + p - 1) / p;
                ll y0 = k0 * p;
                ll y1 = k1 * p;
                if (k0 != n) {
                tmp = min(tmp, (u128)(n - y0) * D + A[i] + f(k0));
                }
                if (k1 != n) {
                    tmp = min(tmp, (u128)(y1 - n) * D + A[i] + f(k1));
                }
            }
            return m[n] = tmp;
        };

        cout << (ll)f(N) << endl;
    }

    return 0;
}


Measured memory_bytes: 4696
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int x, y, z; cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
long long target_num, ans;

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

void solve() {
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
//組み合わせ
long long COM (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;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[10000007]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<10000007;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(10000007);i++){
//      if(prime[i]==i){
//          for(j=i*i;j<10000007;j+=i){
//             if(!prime[j])
//                 prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}
vector<pair<int,int>> g[100001];
vector<int> edge(100001);
void dfs(int node,int p=0,int color=-1){
    int cc=1;
    for(pair<int,int> to: g[node]){
        if(to.first == p) continue;
        if(cc == color) cc++;
        edge[to.second]=cc;
        dfs(to.first,node,cc);
        cc++;
    }
}

void solve()
{   
    int n;
    cin>>n;
    for(int i=1;i<=n-1;++i){
        int u,v;
        cin>>u>>v;
        g[u].push_back({v,i});
        g[v].push_back({u,i});
    }
    int ans=INT_MIN;
    for(int i=1;i<=n;++i){
        int size=g[i].size();
        ans=max(ans,size);
    }
    cout<<ans<<'\n';
    dfs(1);
    for(int i=1;i<=n;++i){
        if(edge[i])
            cout<<edge[i]<<'\n';
    }
}

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


Measured memory_bytes: 12372
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef unsigned long long ull;
typedef set<int>::iterator SI;

#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 9901;
 
const int M = 10000007;
const int maxn = 2e5+5;

int main()
{
	int n;
	scanf("%d",&n);
	ll ans =0 ;
	for (int i = 1; i <= n; i ++ )
	{
		ll x = n / i;
		ans += x * (x + 1) / 2 * i;
	}
	printf("%lld\n",ans);
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    if (abs(a-b)%2 == 0) {
        cout << abs(a-b)/2 << endl;
    } else {
        if (a > b) swap(a,b);
        cout << min((a+b-1)/2,(2*n-a-b+1)/2) << endl;
    }
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: u64,
        k: u64,
        a: [u64; n],
    }

    let mut l = 0;
    let mut r = *a.iter().max().unwrap();
    while l < r - 1 {
        let m = (l + r) / 2;
        if a.iter().map(|&x| (x - 1) / m).sum::<u64>() <= k {
            r = m;
        } else {
            l = m;
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 5364
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val o = sc.next()
        val e = sc.next()
        val ans = Array<Char>(o.length + e.length) { if (it % 2 == 0) o[it / 2] else e[it / 2] }
        println(String(ans.toCharArray()))
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 38040
// C++ program to count the Minimum number of
// increasing subsequences
#include <bits/stdc++.h>
using namespace std;

int MinimumNumIncreasingSubsequences(int arr[], int n)
{
    multiset<int> last;

    // last element in each  increasing subsequence
    // found so far
    for (int i = 0; i < n; i++) {

        // here our current element is arr[i]
        multiset<int>::iterator it = last.lower_bound(arr[i]);

        // iterator to the first element larger
        // than or equal to arr[i]
        if (it == last.begin())

            // if all the elements in last larger
            // than or to arr[i] then insert it into last
            last.insert(arr[i]);

        else {
            it--;

            // the largest element smaller than arr[i] is the number
            // before *it which is it--
            last.erase(it); // erase the largest element smaller than arr[i]
            last.insert(arr[i]); // and replace it with arr[i]
        }
    }
    return last.size(); // our answer is the size of last
}

// Driver program
int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; ++i)
        cin >> arr[i];
    cout << MinimumNumIncreasingSubsequences(arr, n);
    return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

long long gcd(long long x, long long y) {
	while (1) {
		if (x < y)swap(x, y);
		x %= y;
		if (x == 0)return y;
	}
}

int main() {
	int N,x=0,z; cin >> N;
	long long ans = 0,y=5e9;
	vector<long long> A(N),L(N),R(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (y > abs(A[i])) {
			y = abs(A[i]); z = i;
		}
		if (A[i] <= 0)x++;
	}
	if (x % 2 == 0) {
		for (int i = 0; i < N; i++) ans += abs(A[i]);
	}
	else{
		for (int i = 0; i < N; i++) { ans += abs(A[i]); }
		ans -= 2 * abs(A[z]);
	}
	cout << ans << endl;

}




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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  sort(an.begin(),an.end());
  int ans = 0;
  for(int i=0; i<n; ++i) for(int j=i+1; j<n; ++j) for(int k=j+1; k<n; ++k){
    if(an[i] == an[j] || an[i] == an[k] || an[j] == an[k]) continue;
    if(an[i] + an[j] > an[k]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
/*    BAJUKA     */
#include<bits/stdc++.h>
#define lld long long int
#define ve vector
#define rep(i,a,b) for(i=a;i<b;i++) 
#define per(i,a,b) for(i=b;i>=a;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair


using namespace std;





int main()
{
	
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld a,b;
    cin>>a>>b;
    if((a*b)%2==0)
    	cout<<"Even";
    else
    	cout<<"Odd";

    
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Class Untitled
 */
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//合計金額
		double total = 0;
		//お年玉を貰った人数
		int peaple = Integer.parseInt(scan.next());
		for(int x = 0; x < peaple; x++){
			//金額
			double money = Double.parseDouble(scan.next());
			//通貨
			String currency = scan.next();
			if(currency.equals("JPY")){
				total += money;
			}else if(currency.equals("BTC")){
				total += money * 380000.0;
			}
		}
		System.out.printf("%.10f", total);
	}
}

Measured memory_bytes: 23124
import Data.List
import Data.Maybe

main = print =<< sol <$> get <*> get <*> getLine

get = fmap read . words <$> getLine

sol [n,k] [r,s,p] t = go 0 z (t++z)
  where
  z = replicate k ' '
  go c [] _ = c
  go c q u  = go c' q' u'
    where
    c' = c + sum (zipWith scr q' u)
    q' = zipWith3 hnd q u u'
    u' = drop k u
  scr 'p' 'r' = p
  scr 'r' 's' = r
  scr 's' 'p' = s
  scr  _   _  = 0

hnd h 'r' f = if h/='p' then 'p' else chs f "rs"
hnd h 's' f = if h/='r' then 'r' else chs f "sp"
hnd h 'p' f = if h/='s' then 's' else chs f "rp"

chs x = fromJust . find (/= sup x)

sup 'r' = 'p'
sup 's' = 'r'
sup 'p' = 's'
sup  _  = ' '


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<P> ba(N);
  FOR(i,0,N) {
    int a, b;
    cin >> a >> b;
    ba[i] = P(b, a);
  }
  sort(ba.begin(), ba.end());

  int now = 0;
  FOR(i,0,N) {
    int end = now + ba[i].second;
    if (end > ba[i].first) {
      cout << "No" << endl;
      exit(0);
    }
    now = end;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
int x,y;
    while(1){

        scanf("%d%d",&x,&y);
        if(x==0&&y==0)break;
        if(x>=y){
            printf("%d %d\n",y,x);
        }
        else{
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 600
X = int(input())
vec=[0]*(X+1)
vec[0]=1
vec[1]=1
for i in range(2,X+1):
    v=i*i
    while v<=X:
        vec[v]=1
        v *= i
for i in range(X,0,-1):
    if vec[i]==1:
        print(i)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A < B) {
    cout << N * A << endl;
  }
  if (N * A == B) {
    cout << B << endl;
  }
  if (N * A > B) {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 998244353

ll f(vector<pair<ll,ll> > &v){
  vector<pair<ll,ll> > v1;
  rep(i,0,v.sz){
    v1.pb(mp(-v[i].fi,-v[i].se));
  }
  sort(all(v1));
  ll d = 0;
  ll index = 0;
  while(index<v1.sz){
    ll a = v1[index].fi;
    ll b = -v1[index].se;
    if(a<=d){
      d += b;
      index++;
    }
    else{
      return -1;
    }
  }
  return d;
}

int main(){
  ll n;
  cin>>n;
  vector<pair<ll,ll> > v1;
  vector<pair<ll,ll> > v2;
  vector<pair<ll,ll> > v3;
  rep(i,0,n){
    string s;
    cin>>s;
    ll mn = 0;
    ll d = 0;
    rep(i,0,s.sz){
      if(s[i]=='(')d++;
      else d--;
      mn = min(mn,d);
    }
    if(d>0){
      v1.pb(mp(mn,d));
    }
    else if(d<0){
      v2.pb(mp(mn,d));
    }
    else{
      v3.pb(mp(mn,d));
    }
  }
  rep(i,0,v2.sz){
    ll a = v2[i].fi;
    ll b = v2[i].se;
    v2[i].fi = a-b;
    v2[i].se = -b;
  }
  ll a1 = f(v1);
  ll b1 = f(v2);
  ll mn1 = 0;
  rep(i,0,v3.sz){
    mn1 = min(mn1,v3[i].fi);
  }
  if(a1!=-1&&a1==b1&&a1+mn1>=0){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

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

void trim (vector<int> &vec, int sz) {
    int len = int(vec.size());

    for (int i=0; i<sz; i++) {
        vec[i] = vec[i+(len-sz)];
    }

    vec.resize(sz);
}

int main () {
    cin.tie(0);

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

    vector<int> p(a), q(b), r(c);

    ll sum = 0;
    for (int i=0; i<a; i++) {
        cin >> p[i];
    }
    for (int j=0; j<b; j++) {
        cin >> q[j];
    }
    for (int k=0; k<c; k++) {
        cin >> r[k];
    }


    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    trim(p, x);
    trim(q, y);

    for (auto v : p) {
        sum += v;
    }
    for (auto v : q) {
        sum += v;
    }

    p.emplace_back(1000000009);
    q.emplace_back(1000000009);

    for (int i=0, lp=0,rp=0; i<c; i++) {
        if (p[lp] > q[rp]) {

            if (r[c-i-1] > q[rp]) {
                sum -= q[rp];
                sum += r[c-i-1];
                rp++;
            } else {
                break;
            }

        } else {

            if (r[c-i-1] > p[lp]) {
                sum -= p[lp];
                sum += r[c-i-1];
                lp++;
            } else {
                break;
            }

        }

    }
    
    cout << sum << endl;
}


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

using namespace std;
struct squ{
    int w, h;
};

int main()
{

    int n, w, d, p, s;
    while (true) {
        cin >> n >> w >> d;
        if (n == 0 && w == 0 && d == 0) {
            break;
        }
        vector<squ> data;
        data.push_back(squ({w, d}));
        for (int i = 1; i <= n; i++) {
            cin >> p >> s;
            p--;
            s %= (data[p].w + data[p].h);
            squ a, b;
            int h = data[p].h;
            int w = data[p].w;
            if (0 < s && s < w) {
                a.w = s; a.h = h;
                b.w = w-s; b.h = h;
            }else{
                a.w = w; a.h = w + h -s;
                b.w = w; b.h = s-w;
            }
            if (a.w * a.h > b.w * b.h) {
                swap(a.w, b.w);
                swap(a.h, b.h);
            }
            vector<squ> tmp;
            for (int j = 0; j < data.size(); j++) {
                if (j != p) {
                    tmp.push_back(data[j]);
                }
            }
            tmp.push_back(a);
            tmp.push_back(b);
            data = tmp;
        }
        vector<int> v;
        for (int i = 0; i < data.size(); i++) {
            v.push_back(data[i].w * data[i].h);
        }
        sort(v.begin(), v.end());
        for (int i = 0; i < v.size() - 1; i++) {
            cout << v[i] << " ";
        }
        cout << v[v.size() - 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s[] = new int[6];
		for(int i = 0; i < 6; i++) {
			s[i] =  sc.nextInt();
		}
		if(s[4]-s[0] > s[5]) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}

	}
}

Measured memory_bytes: 22864
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int a,b,c;
	int t=0,h=0;
	for(;~scanf("%d,%d,%d",&a,&b,&c);){
		if(a*a+b*b==c*c)t++;
		if(a==b)h++;
	}
	cout<<t<<endl<<h<<endl;
	return 0;
}

Measured memory_bytes: 0
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

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

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#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 repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=200010;

int n,h[maxn],a[maxn];
int64 dp[maxn],bit[maxn],ans;

inline int64 query(int i)
{
	i--;

	int64 res=0;
	while(i>0)
	{
		res=max(res,bit[i]);
		i-=i&-i;
	}

	return res;
}

inline void modify(int i,int64 x)
{
	while(i<=n)
	{
		bit[i]=max(bit[i],x);
		i+=i&-i;
	}
}

int main()
{
	SF("%d",&n);
	for(int i=1;i<=n;i++) SF("%d",&h[i]);
	for(int i=1;i<=n;i++) SF("%d",&a[i]);

	for(int i=1;i<=n;i++)
	{
		dp[i]=query(h[i])+a[i];
		modify(h[i],dp[i]);

		ans=max(ans,dp[i]);
	}

	PF("%lld",ans);

	return 0;
}

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

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

int main(void) {
	int n, w[100], s1, s2, s[100], i, t, temp;
	cin >> n;
	rpt(i, n) {
		cin >> w[i];
	}

	rpt(t, n - 1) {
		s1 = 0;
		rpt(i, t + 1) {
			s1 += w[i];
		}
		s2 = 0;
		for (i = t + 1; i < n; i++) {
			s2 += w[i];
		}
		if (s1 <= s2)
			s[t] = s2 - s1;
		else
			s[t] = s1 - s2;
	}

	for (i = n - 3; i >= 1; i--) {
		if (s[i] > s[i + 1]) {
			temp = s[i];
			s[i] = s[i + 1];
			s[i + 1] = temp;
		}
	}

	cout << s[1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}


typedef struct OBJ{
    ll cost;
    ll v;
    ll p;
    char prev;
    bool operator> (const OBJ &a) const
    {
        return (cost > a.cost);
    };
} obj;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    vector<vector<ll>> G(N);
    rep(i,M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    vector<ll> memo(N,0), ans(N,0), dist(N,1e18), prev(N,-1);
    priority_queue<obj,vector<obj>, greater<obj>> que;
    //cout << "aaaa"<<endl;
    obj k;
    k.cost=0;
    k.v=0;
    k.p=0;
    que.push(k);
    while(!que.empty()){
        //int l =0;
        ll c = que.top().cost;
        ll v = que.top().v;
        ll p = que.top().p;
        
        que.pop();
        if(memo[v] != 0)continue;
        memo[v] = 1;
        ans[v] = p;
        for(auto& e:G[v]){
            //prev[e] = v;
            k.v=e;
            k.cost=c+1;
            k.p=v;
            que.push(k);
        }
    }
    cout << "Yes" << endl;
    REP(i,1,N){
        cout << ans[i]+1 << endl;
    }
}


Measured memory_bytes: 34040
program niceshopping
  implicit none
  integer :: A, B, M, price, minprice, i, j
  integer,allocatable :: fri(:), ra(:), dsc(:,:)

  read(*,*) A, B, M
  allocate(fri(A), ra(B), dsc(3,M))

  read(*,*) fri
  read(*,*) ra
  do i = 1, M
     read(*,*) (dsc(j,i) ,j = 1, 3)
  end do
  minprice = minval(fri) + minval(ra)
  do i = 1, M
     price = fri(dsc(1,i)) + ra(dsc(2,i)) - dsc(3,i)
     if (price < minprice) then
        minprice = price
     end if
  end do
  write(*,*) minprice
  deallocate(fri,ra,dsc)
  stop
end program niceshopping


Measured memory_bytes: 2816
import sys


def main():
    A, B, C, X, Y = map(int, sys.stdin.readline().rstrip().split())

    K = max(X, Y) * 2  # 全部ハーフピザで注文する場合

    cost = 5000 * 10**6
    for i in range(K + 1):

        # 不足枚数
        rest_X = max(X - i // 2, 0)
        rest_Y = max(Y - i // 2, 0)

        # 金額を計算し、最小値を求める
        cost = min(rest_X * A + rest_Y * B + i * C, cost)

    print(cost)


main()


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  vector<int> A(N),B(N);
  for (int i = 0; i < N; i++) {
    if(i==0){
      A.at(i)=0;
      B.at(N-1-i)=0;
    }
    else{
      if (S.at(i-1)=='W') A.at(i)=A.at(i-1)+1;
      else A.at(i)=A.at(i-1);
      if (S.at(N-i)=='E') B.at(N-1-i)=B.at(N-i)+1;
      else B.at(N-1-i)=B.at(N-i);
    }
  }

  int count=N;
  for (int i = 0; i < N; i++) {
    count=min(count,A.at(i)+B.at(i));
  }

  cout << count << endl;
}

Measured memory_bytes: 3076
package main

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

func main() {
	In := readLineInt()
	W, H, x, y := In[0], In[1], In[2], In[3]
	ResultB := 0
	if 2*x == W && 2*y == H {
		ResultB = 1
	}
	fmt.Println(float64(W)*float64(H)/2.0, ResultB)
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff          first
#define ss          second
#define ll          int64_t
#define ld          long double
#define nl          cout<<"\n"
#define dbg(x)      cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y)   cerr<<#x<<" = "<<x<<"   "<<#y<<" = "<<y<<"\n"
#define all(v)      v.begin(),v.end()
#define mset(a,v)   memset((a),(v),sizeof(a))
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<typename T,typename U> static inline void amin(T &x,U y)                   {if(y<x)x=y;}
template<typename T,typename U> static inline void amax(T &x,U y)                   {if(x<y)x=y;}  
template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)            {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                    {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                     {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                       {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)             {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
string dec_bin_32(ll n) {string s;for(ll i=31;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
string dec_bin_64(ll n) {string s;for(ll i=63;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=10000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n;
	if(n>=30)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3676
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    C = [[0] * 10 for _ in range(10)]
    for i in range(10):
        for j in range(10):
            for n in range(1, N + 1):
                L = len(str(n)) - 1
                a = n // (10 ** L)
                b = n % 10
                if a == i and b == j:
                    C[i][j] += 1
    answer = 0
    for i in range(10):
        for j in range(10):
            answer += C[i][j] * C[j][i]
    print(answer)


if __name__ == "__main__":
    main()


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, k;
    cin >> n >> k;

    vector<int> pos(n);
    rep(i, n) cin >> pos[i];

    int min_val = INF;
    auto over_0 = lower_bound(all(pos), 0);
    int start = max(0, (int)(over_0 - pos.begin() - k));
    repi(i, start, n - k + 1){
        int m_s = min(0, pos[i]);
        int m_e = max(0, pos[i + k - 1]);
        min_val = min(min_val, m_e - m_s + min(abs(m_s), abs(m_e)));
    }

    cout << min_val << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var s string
	fmt.Scan(&s)
	slice := strings.Split(s, "")
	// ans := make([]int, len(s))

	even := 0
	odd := 0

	for i := 0; i < len(s); i++ {
		num, _ := strconv.Atoi(slice[i])
		if num%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	fmt.Println(len(s) - abs(even-odd))

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 2944