akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 2e5 + 5;

Modint fact [MAX_N];
Modint ifact [MAX_N];

Modint choose (int n, int r) {
  return fact[n] * ifact[r] * ifact[n - r];
}

int n;
Modint a, b, c;
Modint ans;

Modint expa [MAX_N];
Modint expb [MAX_N];

Modint ic;

Modint sprob;

void consider (int ca, int cb) {
  Modint prob;
  int steps = ca + cb;
  if (ca == n) {
    prob = choose(steps - 1, ca - 1) * expa[ca] * expb[cb];
  } else {
    // assume cb == n
    prob = choose(steps - 1, cb - 1) * expa[ca] * expb[cb];
  }

  sprob += prob;
  // cerr << ca << " " << cb << " " << prob << " " << Modint(steps) + Modint(steps) * ic << endl;
  ans += prob * (Modint(steps) + Modint(steps) * c * ic);
}

int main () {
  fact[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = fact[i - 1] * Modint(i);
  }

  for (int i = 0; i < MAX_N; i++) {
    ifact[i] = inv(fact[i]);
  }

  int A, B, C;
  cin >> n >> A >> B >> C;

  a = Modint(A) * inv(100);
  b = Modint(B) * inv(100);
  c = Modint(C) * inv(100);

  ic = inv(Modint(1) - c);
  
  expa[0] = Modint(1);
  expb[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    expa[i] = expa[i - 1] * a * ic;
    expb[i] = expb[i - 1] * b * ic;
  }
  
  for (int i = 0; i < n; i++) {
    consider(i, n);
    consider(n, i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 9892
#include <stdio.h>
 
#define MAX 100001
#define max(a,b) ((a) < (b) ? (b) : (a))
 
int par[MAX],sib[MAX],deg[MAX];
int height[MAX],dep[MAX];
 
void init(int);
int depth(int,int);
 
int main(){
  int n,i,id,l,r;
 
  scanf("%d" ,&n); 
  init(n);  
 
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);
 
    if(l != -1){
      par[l] = id;
      deg[id]++;
    }
    if(r != -1){
      par[r] = id;
      deg[id]++;
    }
    if(l != -1 && r != -1){
      sib[l] = r;
      sib[r] = l;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    dep[i] = depth(i,0);
  }
 
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, sibling = %d, "
       ,i, par[i], sib[i]);
 
    printf("degree = %d, depth = %d, height = %d, "
       , deg[i], dep[i], height[i]);
     
    if(par[i] == -1){
      printf("root\n");
    }else if(deg[i] != 0){
      printf("internal node\n");
    }else{
      printf("leaf\n");
    }
  }
 
  return 0;
}
 
void init(int n){
  int i;
 
  for(i = 0 ; i < n ; i++){
    par[i] = sib[i] = -1;
    deg[i] = height[i] = 0;
  }
}
 
int depth(int x,int dep){
  height[x] = max(height[x],dep);
  if(par[x] == -1){
    return dep;
  }else{
    return depth(par[x],dep+1);
  }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    char c[10][10];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> c[i][j];
        }
    }

    int res = 0;
    for (int i = 0; i < 1 << (h+w); ++i) {
        int cnt = 0;
        for (int j = 0; j < h; ++j) {
            for (int k = 0; k < w; ++k) {
                if ((i & (1 << j)) == 0 && (i & (1 << (h + k))) == 0 && c[j][k] == '#'){
                    cnt++;
                }
            }
        }
        if (cnt == k){
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
import numpy as np


def main():
    n, d = map(int, input().split())
    ans = 0
    for i in range(n):
        x, y = map(int, input().split())
        dis = np.sqrt(x**2 + y**2)
        if dis <= d:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27164
def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    max_height = A[0]
    ans = 0
    for i in range(1, N):
        if A[i] >= max_height:
            max_height = A[i]
        else:
            ans += max_height - A[i]
    
    print(f'{ans}')

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

const ll INF = 4e18;

struct STNode {
    typedef STNode* NP;
    NP l, r;
    int sz;
    ll mi;
    STNode(int _sz) : sz(_sz) {
        mi = INF;
        if (sz == 1) return;
        l = new STNode(sz/2);
        r = new STNode(sz-sz/2);
    }
    void set(int k, ll x) {
        if (sz == 1) {
            mi = min(mi, x);
            return;
        }
        if (k < sz/2) {
            l->set(k, x);
        } else {
            r->set(k-sz/2, x);
        }
        mi = min(l->mi, r->mi);
    }
    ll get(int a, int b) {
        if (b <= 0 || sz <= a) return INF;
        if (a <= 0 && sz <= b) return mi;
        return min(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

const int MN = 222222;
int n, q, a, b;
int x[MN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> q >> a >> b;
    x[0] = a;
    for (int i = 1; i <= q; i++) {
        cin >> x[i];
    }
    
    STNode* tr = new STNode(n+1);
    STNode* tr1 = new STNode(n+1);
    STNode* tr2 = new STNode(n+1);
    tr->set(b, 0);
    tr1->set(b, -b);
    tr2->set(b, b);
    
    ll sm = 0;
    for (int i = 0; i < q; i++) {
        ll c = min(tr1->get(1, x[i+1]+1) + sm + x[i+1], tr2->get(x[i+1]+1, n+1) + sm - x[i+1]);
        sm += abs(x[i+1] - x[i]);
        tr->set(x[i], c - sm);
        tr1->set(x[i], c - x[i] - sm);
        tr2->set(x[i], c + x[i] - sm);
    }
    cerr << tr->get(x[0], x[0]+1) + sm << endl;
    cout << tr->get(1, n+1) + sm << endl;
    return 0;
}

Measured memory_bytes: 57344
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int a[500001];
int b[500001];
signed main()
{
	int mn1=999999999,mn2=999999999,ans=999999999;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i],mn1=min(mn1,a[i]);
	for(int i=1;i<=m;i++)
		cin>>b[i],mn2=min(mn2,b[i]);
	for(int i=1;i<=k;i++)
	{
		int x,y,tmp;
		cin>>x>>y>>tmp;
		ans=min(ans,a[x]+b[y]-tmp);
	}
	ans=min(ans,mn1+mn2);
	cout<<ans;
	return 0;
}


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



signed main() {

   int n,m;cin>>n>>m;
   vector<int> ret;
   for(int i = 1; i*i <= m; i++)
   {
        if(m%i == 0)
        {
            ret.push_back(i);
            if(i*i!=m)
            {
                ret.push_back(m/i);
            }
        }
   }
   sort(ret.begin(),ret.end()); 

   for(auto i:ret)
   {
       if(n<=i) 
       {cout << m/i << endl;
       return 0;
       }
   }
}


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

   int ar[4];
   cin>>ar[0]>>ar[1]>>ar[2];
   sort(ar,ar+3);
   long long sum=0;
   sum=ar[0]+ar[1];
   cout<<sum<<endl;

   return 0;
}


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

int main(){
    int i,j,k,s;
    int h,w;
    std::vector<int> H,W;

    h=3;
    w=3;

    k=0;
    while(h!=0&&w!=0){
        std::cin>>h>>w;
        H.push_back(h);
        W.push_back(w);
        k=k+1;
    }

    for(s=0;s<k-1;s++){
        for(i=0;i<H[s];i++){
            for(j=0;j<W[s];j++){
                std::cout<<"#"<<std::flush;
            }
            std::cout<<std::endl;
        }
            std::cout<<std::endl;
    }

    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	// 3 : 2, 3, 25
	// n : 2, 4, 3, 9

	if (N == 3) {
		cout << "2 3 25" << endl;
		return 0;
	}

	vector<int> ans = { 2, 4, 3, 9 };
	for (int i = 15; i <= 30000; i += 12) {
		if (ans.size() >= N - 1) { break; }
		ans.emplace_back(i);
		ans.emplace_back(i + 6);
	}
	for (int i = 8; i + 2 <= 30000; i += 6) {
		if (ans.size() >= N - 1) { break; }
		ans.emplace_back(i);
		ans.emplace_back(i + 2);
	}
	for (int i = 6; i <= 30000; i += 6) {
		if (ans.size() >= N) { break; }
		ans.emplace_back(i);
	}

	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << (i < ans.size() - 1 ? " " : "\n");
	}

	return 0;
}


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

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

    string s; cin >> s;
    int n = s.size();

    int cntNotA = 0;
    string notA;
    REP(i, n) if (s[i] != 'A') notA.push_back(s[i]);

    bool ok2 = false;
    if (notA == "KIHBR") ok2 = true;

    bool ok = true;
    REP(i, n - 1)
        if (s[i] == 'A' && s[i + 1] == 'A')
            ok = false;

    bool ok3 = true;
    if (s.find("KIH") == std::string::npos) ok3 = false;

    if (ok && ok2 && ok3) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

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

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

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

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] > abs(x[i] - k)) {
            ans += (ll)2 * abs(x[i] - k);
        }
        else {
            ans += (ll)2 * x[i];
        }
    }

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


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

vector<vector<pair<int, int>>> g;
vector<int> color;

void dfs(int now, int prev, int c) {
	for (int i = 0; i < g[now].size(); i++) {
		auto p = g[now][i];

		if (p.first == prev) {
			continue;
		}

		if (p.second % 2 == 0) {
			color[p.first] = c;
		} else {
			color[p.first] = !c;
		}

		dfs(p.first, now, color[p.first]);
	}
}

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

	int n;
	cin >> n;

	g.resize(n);
	color.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		a--; b--;

		g[a].emplace_back(b, w);
		g[b].emplace_back(a, w);
	}

	color[0] = 1;
	dfs(0, 0, 1);

	for (auto v : color) {
		cout << v << endl;
	}
	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Edge {
    ll to;
    ll from;
    ll cost;
};
ll C[2505];
Edge E[5005];
bool U[2505];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, P;
    cin >> N >> M >> P;
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        E[i].from = a;
        E[i].to = b;
        E[i].cost = -(c - P);
    }

    REP(i, N) {
        C[i] = INF;
        U[i] = false;
    }
    C[0] = 0;
    U[N - 1] = true;

    REP(i, N + 5) {
        bool update = false;
        REP(j, M) {
            const auto &e = E[j];
            U[e.from] |= U[e.to];
            if (C[e.from] == INF)
                continue;
            ll cost = C[e.from] + e.cost;
            if (C[e.to] > cost) {
                C[e.to] = cost;
                update = true;
            }
        }
        if (!update)
            break;
    }

    bool inf = false;
    REP(i, M) {
        const auto &e = E[i];
        if (C[e.from] == INF)
            continue;
        ll cost = C[e.from] + e.cost;
        if (C[e.to] > cost && U[e.to])
            inf = true;
    }

    if (inf)
        cout << -1 << endl;
    else
        cout << std::max(0LL, -C[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		long a = 100;
		int ans = 0;

		while (true) {
			ans++;
			long tmp = 0;
			tmp = (long) (a * 0.01);
			a += tmp;

			if(a >= n){
				System.out.println(ans);
				break;
			}

		}
	}
}

Measured memory_bytes: 27068
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b)swap(a,b);
  if(b>c)swap(b,c);
  if(a>b)swap(a,b);
  cout<<a<<' '<<b<<' '<<c<<endl;
  return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;

  vector<pair<ll, ll> > arms;
  arms.reserve(N);
  REP(i, N) {
    ll X, L;
    cin >> X >> L;
    arms.emplace_back(X-L, X+L);
  }

  sort(begin(arms), end(arms),
      [](const pair<ll, ll>& lhs, const pair<ll, ll>& rhs) {
        return lhs.second < rhs.second;
      });

  int ret = 1;
  int cur = arms[0].second;
  REP(i, 1, N) {
    ll s = arms[i].first;
    ll e = arms[i].second;
    if (s<cur) continue;
    ret++;
    cur = e;
  };

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

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 1792
n,m = map(int,input().split())
# 整数の入力値をスペースで受け取ってリスト化
a = list(map(int,input().split()))

# 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示
if n >= sum(a):
    print(n - sum(a))
# リスト内の日数の合計が夏休みの日数より多ければ-1を表示
else:
    print("-1")

Measured memory_bytes: 9860
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  int r;
  cin>>r;
  
  if(r<1200) cout<<"ABC"<<endl;
  else if(r<2800) cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;

  return 0;
}

Measured memory_bytes: 3576
using System;
class SS
{
  static void Main()
  {
    var num=int.Parse(Console.ReadLine());
    var line=Console.ReadLine();
    if(line.Length>num)
    {
      for(int i=0;i<num;i++)
      {
        Console.Write(line[i]);
      }
      Console.WriteLine("...");
    }
    else
      Console.WriteLine(line);
  }
}

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

int main(){
  int N;
  cin >> N;
  int t=N;
  int cnt=0;
  for (int i = 0; i < 10; i++) {
    cnt+=N%10;
    N=N/10;
  }
  if(t%cnt==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,A;

  cin>>N>>A;

  cout<< N*N-A<<"\n";


}

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


Measured memory_bytes: 256
def mips():
  return map(int,input().split())
def rev(data):
    a = data[0]
    data[0] = data[1]
    data[1] = a
    return None
N,M = mips()
data = dict()
for i in range(M):
    pref,year = mips()
    if pref not in data:
        data[pref] = [[year,i+1,pref]]
    else:
        data[pref].append([year,i+1,pref])
ans = []
for pref in data:
    data[pref].sort()
    for i in range(len(data[pref])):
        data[pref][i][0] = i+1
        rev(data[pref][i])
        ans.append(data[pref][i])
ans.sort()
for i in range(M):
    ken = str(ans[i][2])
    when = str(ans[i][1])
    ken,when = format(ken,'0>6'),format(when,'0>6')
    print(ken+when)

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

using namespace std;

int l,m;
int coin[20],dp[50001];

int main(){
    cin>>l>>m;

    for(int i=0;i<m;i++){
        cin>>coin[i];
    }

    for(int i=1;i<=50000;i++){
        dp[i]=50001;
    }
    for(int i=0;i<=50000;i++){
        for(int j=0;j<m;j++){
            if(i+coin[j]<=l)dp[i + coin[j]]=min(dp[i+coin[j]],dp[i]+1);
        }
    }
    cout<<dp[l]<<endl;
}


Measured memory_bytes: 3276
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, d = readmi()
t = []
for i in range(n):
    k = readl()
    t.append(k)
count = 0
b = defaultdict(lambda:defaultdict(int))
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if b[i][j] == 1:
            continue
        b[i][j] = 1
        b[j][i] = 1
        p = 0
        for k in range(d):
            p += abs(t[i][k] - t[j][k]) ** 2
        if float.is_integer(math.sqrt(p)):
            count += 1
print(count)

Measured memory_bytes: 6480
#include<bits/stdc++.h> 
#include <chrono> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono; 

template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less_equal<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
       'j','k','l','m','n','o','p','q','r','s','t','u','v',
       'w','x','y','z'};

// rectangle intersection
// x5 = max(x1, x3);
// y5 = max(y1, y3);
// x6 = min(x2, x4);
// y6 = min(y2, y4); 

// const int mx = 20005;

// char get_next(char c) {
// 	for(int i=0; i<25; i++) if(c == alphabet[i]) return alphabet[i+1];
// 	return 'a';
// }

int32_t main() {
 	fastIO;
	int tc;
	// cin >> tc;
	tc = 1;
	while(tc--) {
		int x;
		cin >> x;
		if(x < 600) cout << 8;
		else if(x < 800) cout << 7;
		else if(x < 1000) cout << 6;
		else if(x < 1200) cout << 5;
		else if(x < 1400) cout << 4;
		else if(x < 1600) cout << 3;
		else if(x < 1800) cout << 2;
		else if(x < 2000) cout << 1;
		cout << endl;
    }     
}


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

int main() {
    int K;

    cin >> K;

    int conv = 0;
    for (int odd = 1; odd <= K; odd = odd+2) {
        for (int even = 2; even <= K; even = even+2) {
            conv++;
        }
    }
    cout << conv << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	ll l;
 	cin >> l;
 	ld x = l;
 	x = (x / 3.000);
 	ld y = (x * x * x);
 	cout << fixed << setprecision(20) << y << endl;   
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static int fac(int n){
        if(n==0) return 1;
        return n*fac(n-1);
    }     
    public static void main(String[] args){        
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        int [] in2 = new int [a];
        int b = 1;
        int c = 1;
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
        for(int i=0;i<a;i++){
                             in2[i] = sc.nextInt();
                            }
		for(int i=0;i<a;i++){b+=(in[i]-1)*fac(a-1-i);
        for(int j=0;j<a;j++){if(in[j]>in[i]){in[j]--;}                                                             
                            }                                                      
                            }  
        for(int i=0;i<a;i++){c+=(in2[i]-1)*fac(a-1-i);
        for(int j=0;j<a;j++){if(in2[j]>in2[i]){in2[j]--;}                                                             
                            }                                                      
                            }                                    
		System.out.println(Math.max(b-c,c-b));
	}
}


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

using namespace std;

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

	int N,num,mod,sum;
	cin >> N;
	num = N;
	sum = 0;

	while (N) {
		mod = N % 10;
		sum = sum + mod;
		N = N / 10;
	}
	if (num % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main(){
  char c;
  int x, y, atx, aty, ind, count = 1;
  std::vector<int> real;
  std::queue<int> q;

  std::cin >> x;
  std::cin >> y;

  while(x != 0 || y != 0){

    real.resize(x*y);

    for(int i = 0; i < y; i++){         //地図の読み込みと＠の座標の格納
      for(int j = 0; j < x; j++){
        std::cin >> c;
        if(c == '.'){

          real[i*x + j] = 1;

        }else if(c == '#'){

          real[i*x + j] = 0;

        }else if(c == '@'){

          real[i*x + j] = -1;
          atx = j;//atx と aty は＠の座標を意味している
          aty = i;

        }else{

          std::cout << "unexpected char input!" << std::endl;
          return 0;

        }
      }
    }

    //＠を起点にして探索を開始する。

    q.push(atx + aty * x);

    while( !q.empty() ){

      ind = q.front();
      q.pop();


      if( ind%x != 0){//左をチェック 左端でなければ
        if(real[ ind-1 ] == 1 ){

          real[ ind-1 ] = -1;
          q.push( ind-1 );
          count++;
        }
      }

      if( ind%x != x-1 ){//右をチェック 右端でなければ
        if(real[ ind+1 ] == 1){

          real[ ind+1 ] = -1;
          q.push( ind+1 );
          count++;
        }
      }

      if( ind-x > -1 ){//上をチェック 上端でなければ
        if(real[ ind-x ] == 1){

          real[ ind-x ] = -1;
          q.push( ind-x );
          count++;
        }
      }

      if( ind+x < x * y){//下をチェック 下端でなければ
        if(real[ ind+x ] == 1){

          real[ ind+x ] = -1;
          q.push( ind+x );
          count++;
        }
      }

    }

    std::cout << count << std::endl;

/*
    for(int i = 0; i < y;i++){
      for(int j = 0; j < x; j++){
        std::cout << real[i*x + j];
      }
      std::cout << std::endl;
    }
//*/
    std::cin >> x;
    std::cin >> y;
    count = 1;
  }

  return 0;
}



Measured memory_bytes: 3164
n, k = gets.chomp.split.map(&:to_i)
pos = []
neg = []

gets.chomp.split.map(&:to_i).each do |e|
  if e >= 0
    pos << e
  else
    neg << -e
  end
end

pos.sort!
neg.sort!

MOD = 10 ** 9 + 7
ans = 1

if ([neg.size, k].min & ~1) + pos.size >= k
  if k % 2 == 1
    ans = ans * pos.pop % MOD
    k -= 1
  end
  while k > 0
    if neg.size < 2 || (pos.size > 1 && (pos[-1] * pos[-2]) > (neg[-1] * neg[-2]))
      ans = ans * pos.pop % MOD * pos.pop % MOD
    else
      ans = ans * neg.pop % MOD * neg.pop % MOD
    end
    k -= 2
  end
else
  ans = MOD - 1
  [*pos, *neg].min(k).each { |e| ans = ans * e % MOD }
end

puts ans


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

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum^=a.at(i);
  }

  for(int i=0;i<N;i++){
    int x=sum^a.at(i);
    cout<<x<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 4028
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
totals=[0]*n

for i in range(n-1,-1,-1):
    if totals[i]%2==a[i]:
        continue
    else:
        ans[i]+=1
        tmp=1
        while tmp*tmp<=i+1:
            if (i+1)%tmp==0:
                totals[tmp-1]+=1
                if tmp !=(i+1)//tmp:
                    totals[((i+1)//tmp)-1]+=1

            tmp+=1


cnt=ans.count(1)

print(cnt)
if cnt!=0:
    b=[]
    for j in range(n):
        if ans[j]==1:
            b.append(j+1)

    print(*b)
    

Measured memory_bytes: 99596
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  char c; cin >> c;
  if ( c == 'A' ) cout << "T" << endl;
  else if( c == 'T' ) cout << "A" << endl;
  else if ( c == 'C' ) cout << "G" << endl;
  else if ( c == 'G' ) cout << "C" << endl;
  return 0;
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int a = r * 100 + g * 10 + b;
    if (a % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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();
		sc.close();

		if ((a + b) % 2 == 0) {
			System.out.println((a + b) / 2);
		} else {
			System.out.println("IMPOSSIBLE");
		}

	}

}


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

int memo[51][51][51][51][2][3];

const int FLAG = INT_MAX;

int calc(const vector<int>& a, const vector<int>& b, int i1, int j1, int i2, int j2, bool t, int skip){
    if(memo[i1][j1][i2][j2][t][skip] != FLAG) return memo[i1][j1][i2][j2][t][skip];
    if(!t){
        if(i1 == (int)a.size()){
            if(skip == 2) return memo[i1][j1][i2][j2][t][skip] = 0;
            int sum = 0;
            for(int i = i2;i < i1;i++){
                sum += a[i] != -1 ? a[i] : 0;
            }
            for(int i = j2;i < j1;i++){
                sum -= b[i] != -1 ? b[i] : 0;
            }
            sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
            return memo[i1][j1][i2][j2][t][skip] = sum;
        }
        int res = skip == 2 ? 0 : INT_MIN;
        if(a[i1] == -1){
            res = max(res, -calc(a, b, i1 + 1, j1, i2, j1, !t, 0));
        }
        else{
            res = max(res, -calc(a, b, i1 + 1, j1, i2, j2, !t, 0));
        }
        if(skip < 2){
            int sum = 0;
            for(int i = i2;i < i1;i++){
                sum += a[i] != -1 ? a[i] : 0;
            }
            for(int i = j2;i < j1;i++){
                sum -= b[i] != -1 ? b[i] : 0;
            }
            sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
            res = max(res, sum);
        }
        return memo[i1][j1][i2][j2][t][skip] = res;
    }
    if(j1 == (int)b.size()){
        if(skip == 2) return memo[i1][j1][i2][j2][t][skip] = 0;
        int sum = 0;
        for(int i = i2;i < i1;i++){
            sum -= a[i] != -1 ? a[i] : 0;
        }
        for(int i = j2;i < j1;i++){
            sum += b[i] != -1 ? b[i] : 0;
        }
        sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
        return memo[i1][j1][i2][j2][t][skip] = sum;
    }
    int res = skip == 2 ? 0 : INT_MIN;
    if(b[j1] == -1){
        res = max(res, -calc(a, b, i1, j1 + 1, i1, j2, !t, 0));
    }
    else{
        res = max(res, -calc(a, b, i1, j1 + 1, i2, j2, !t, 0));
    }
    if(skip < 2){
        int sum = 0;
        for(int i = i2;i < i1;i++){
            sum -= a[i] != -1 ? a[i] : 0;
        }
        for(int i = j2;i < j1;i++){
            sum += b[i] != -1 ? b[i] : 0;
        }
        sum -= calc(a, b, i1, j1, i1, j1, !t, skip + 1);
        res = max(res, sum);
    }
    return memo[i1][j1][i2][j2][t][skip] = res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < m;i++){
        cin >> b[i];
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            for(int k = 0;k <= n;k++){
                for(int l = 0;l <= m;l++){
                    for(int o = 0;o < 2;o++){
                        for(int p = 0;p < 3;p++){
                            memo[i][j][k][l][o][p] = FLAG;
                        }
                    }
                }
            }
        }
    }
    cout << calc(a, b, 0, 0, 0, 0, false, 1) << endl;
    return 0;
}



Measured memory_bytes: 161660
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int n = in.nextInt();
       double money = 100000;
       for(int i=0;i<n;i++) {
           money = money + money * 0.05;
           money = Math.ceil(money/1000.0) * 1000;
       }
       System.out.printf("%.0f\n", money);
    }
}

Measured memory_bytes: 17172
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, q, a, b, u, d, c[100010];
vector<int> vec[100010];
int dp[15][100010];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	cin >> q;
	REP(i, q) {
		cin >> u >> d >> c[i];
		dp[d][u] = i;
	}
	for (int i = 10; i > 0; i--) {
		REP(j, n) {
			for (int k : vec[j]) {
				dp[i - 1][k] = max(dp[i - 1][k], dp[i][j]);
			}
			dp[i - 1][j] = max(dp[i - 1][j], dp[i][j]);
		}
	}
	REP(j, n) {
		if (dp[0][j])cout << c[dp[0][j]] << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<int> p(n); cin >> p;
  ll res = 0;
  int curr = n + 1;
  rep(i, n){
    curr = min(curr, p[i]);
    if(curr >= p[i])++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())

ans = [0] * (N+1)   # 答え用のリストを用意する

for x in range(1,100):      # Nの上限が10**4なのでルート(10**4)までで計算
    for y in range(1,100):
        for z in range(1,100):
            a = x * x + y * y + z * z + x * y + y * z + z * x
            if a <= N:      # 条件より計算結果aはNを超えてはならない
                n = a       # 計算結果aがn（インデックス番号）となるように
                ans[n] += 1 #リストのn番目のインデックスでカウント
      
for n in range(1,N+1):
    print(ans[n])

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

void solve()
{
    int n;
    cin>>n;
    double p;
    double dp[n+5][n+5];
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>p;
        for(int j=0;j<=i;j++)
        {
            if(j) dp[i][j]+=p*dp[i-1][j-1];
            dp[i][j]+=(1-p)*dp[i-1][j];
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++)
        if(i>n-i) ans+=dp[n][i];
    printf("%.12lf\n",ans);
}

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

Measured memory_bytes: 70528
# -*- coding: utf-8 -*-

n = int(input())

if n == 0:
    print('0')
    exit()

d_list = []
for i in range(0, n):
    d_list.append(int(input()))


d_list.sort()
d_list.reverse()

cnt = 1
for i in range(1, len(d_list)):
    if d_list[i] != d_list[i - 1]:
       cnt += 1

print(cnt)


Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C = readline().split()

    if A[-1] == B[0] and B[-1] == C[0]:
        print('YES')
    else:
        print('NO')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9012
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (a, b, ab, x, y): (i32, i32, i32, i32, i32) = read();
    let mut min_cost = 1e9 as i32;
    for i in 0..x+y+1 {
        let mut cost = i * ab * 2;
        cost += max(0, x-i) * a;
        cost += max(0, y-i) * b;
        min_cost = min(min_cost, cost);
    }
    println!("{}", min_cost);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
int main(void){
    long long int n,sum;
    long int i,j;
    scanf("%lld",&n);
    sum = 0;
    for(i=1;i<=((n));i++){
        j = n/i;
        sum = sum + i*(j*(j+1)/2);
    }
    
    printf("%lld",sum);
}


Measured memory_bytes: 1716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n;
	cin >> n;
	vector<ll> a(n+2);
	a[0] = 2, a[1] = 1;
	rep(i, n) {
		a[i + 2] = a[i + 1] + a[i];
	}
	cout << a[n];
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;

int main(){

	int n,k;
	cin>>n>>k;
	int ans=0;
	if(n>=10)ans=k;
	else ans=k+100*(10-n);


	cout<<ans;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int r, c, i, j;
        int subTotal = 0;
        int total = 0;

        //整数受け取り
        string[] str = Console.ReadLine().Split(' ');
        r = int.Parse(str[0]);
        c = int.Parse(str[1]);

        //2次元配列数値受け取り
        int[,] array = new int[r, c];

        for (i = 0; i < r; i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');

            for (j = 0; j < c; j++)
            {
                array[i, j] = int.Parse(str2[j]);
            }
        }

        //横配列計算
        for (i = 0; i < r; i++)
        {
            for (j = 0; j < c; j++)
            {
                subTotal += array[i, j];
                Console.Write(array[i, j] + " ");
            }
            Console.Write(subTotal);
            subTotal = 0;
            Console.WriteLine("");
        }

        //縦配列計算
        for (j = 0; j < c; j++)
        {
            for (i = 0; i < r; i++)
            {
                subTotal += array[i, j];
            }
            Console.Write(subTotal + " ");
            total += subTotal;
            subTotal = 0;
        }
        Console.WriteLine(total);
    }
}



Measured memory_bytes: 9288
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\143\\A'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class A(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        a = q[0] - q[1]*2
        if a < 0:
            print("0")
        else:
            print(str(a))


solver = A(REL_PATH)
solver.exec_resolve()

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

int n;

double d(int x1,int y1,int x2,int y2)
{
    return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}

int fact(int i)
{
    if(i==1)return 1;
    return i*fact(i-1);
}

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

    if(1<=a&&a<=9&&1<=b&&b<=9)
    {
        cout<<a*b<<endl;
    }else
    {
        cout<<-1<<endl;
    }

}


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

int main(){
  string s;
  cin>>s;
  for(int i = 0;i<s.size();){
    if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]!='r'){
      i+=5;
    }else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r'){
      i+=6;
    }else if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&(s[i+5]!='e'||s[i+7]=='a'||s[i+5]==s.size())){
      i+=5;
    }else if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r'&&s[i+7]!='a'){
      i+=7;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 512
#n=int(input())
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#li=input().split()
#S=input()

lis=list(map(int,input().split()))
S=""
x=lis[2]-lis[0]
y=lis[3]-lis[1]
S+="U"*y
S+="R"*x
S+="D"*y
S+="L"*(x+1)
S+="U"*(y+1)
S+="R"*(x+1)
S+="D"
S+="R"
S+="D"*(y+1)
S+="L"*(x+1)
S+="U"
print(S)


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func solve(k, n int, as []int) int {
	prev := as[0]
	max := (k - as[n-1]) + prev
	for i := 1; i < n; i++ {
		diff := as[i] - prev
		if diff > max {
			max = diff
		}
		prev = as[i]
	}
	return k - max
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	s := scanNums(2)
	t := scanNums(s[1])
	fmt.Println(solve(s[0], s[1], t))
}


Measured memory_bytes: 10240