akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

joy = 0
while X >= 500:
    X -= 500
    joy += 1000

while X >= 5:
    X -= 5
    joy += 5

print(joy)

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

#pragma optimize("O3")

#define int long long

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int x;
    cin >> x;

    int cur = 100;

    int index = 0;

    while (true) {
        index += 1;
        cur = (cur / 100) + cur;
        if (cur >= x) {
            cout << index;
            break;
        }
    }

    return 0;
}

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

long long tot = 0;
int n, cnt, deg[10001], weight[100001];
vector<int> w, adj[10001];

bitset<10001> vis;

void helper(int node){
    vis[node] = 1;
    for(int nx : adj[node])
        if(!vis[nx])
            helper(nx);
    weight[node] = w[cnt++];
    if(cnt < n)
        tot += w[cnt - 1];
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // optimal to group nodes together based on weight
    // sum will always be sum(arr) - max(arr)

    cin >> n;

    for(int i = 0; i < n - 1; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        adj[a].push_back(b); adj[b].push_back(a);
        ++deg[b]; ++deg[a];
    }

    for(int i = 0; i < n; ++i){
        int j; cin >> j;
        w.push_back(j);
    }

    sort(w.begin(), w.end());

    helper(0);

    cout << tot << "\n";

    for(int i = 0; i < n; ++i){
        if(i == 0)
            cout << weight[i];
        else
            cout << " " << weight[i];
    }

    cout << "\n";

    return 0;

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    ll backtrack(int,int);
    int M = 1000000007;
    ll dp[101][100005];
    int n,w;
    std::vector< pair<int,int> > v;
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n>>w;
        fr(i,n)
        {
            int a,b;
            cin>>a>>b;
            v.pb(mp(a,b));
        }
        cout<<backtrack(0,w)<<endl;
        return 0; 
    }

    ll backtrack(int j,int we)
    {
        if(we<=0)
            return 0;
        else
            if(j>n-1)
                return 0;
            if(dp[j][we]!=0)
                return dp[j][we];
            else
            if(v[j].f > we)
                return dp[j][we]=backtrack(j+1,we);
            else
                return dp[j][we]=max(backtrack(j+1,we),v[j].s + backtrack(j+1,we-v[j].f));
    }

Measured memory_bytes: 76416
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Cannot_Wait_for_Holiday(void) {

	string S;
	cin >> S;

	if		(S.compare("SUN") == 0) cout << 7 << flush;
	else if (S.compare("MON") == 0) cout << 6 << flush;
	else if (S.compare("TUE") == 0) cout << 5 << flush;
	else if (S.compare("WED") == 0) cout << 4 << flush;
	else if (S.compare("THU") == 0) cout << 3 << flush;
	else if (S.compare("FRI") == 0) cout << 2 << flush;
	else							cout << 1 << flush;

	return;
}

int main(void) {

	A_Cannot_Wait_for_Holiday();

	return 0;
}


Measured memory_bytes: 256
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

if __name__ == '__main__':
    n = int(input())
    result = digitSum(n)
    #print(result)
    if(n%result==0):
        print("Yes")
    else:
        print("No")


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M,i,flag=0;
  float sum=0.0;
  cin>>N>>M;
  int a[N];
  for(i=0;i<N;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  sum=sum/(4*M);
  sort(a,a+N);
  reverse(a,a+N);
  for(i=0;i<M;i++)
  {
    if(a[i]<sum)
    {
      cout<<"No";
      flag=1;
      break;
    }
  }
  if(flag==0)
    cout<<"Yes";
  
 return 0; 
}

Measured memory_bytes: 256
N = gets.to_i
G = Array.new(N){[]} # 隣接リスト
C = Array.new(N-1) # 辺の色
M = Array.new(N) # 訪問済チェック

(N-1).times do |i|
  a,b = gets.split.map{|v|v.to_i - 1}
  G[a] << [b, i] # next vertex, edge
  G[b] << [a, i] # next vertex, edge
end

D = G.map(&:size).max

Q = [[0, -1]] # vertex, prev color
while Q.size > 0
  v,c = Q.pop
  M[v] = true
  color = (c + 1) % D
  G[v].each do |(nv,e)|
    next if M[nv]
    C[e] = color
    Q << [nv, color]
    color = (color + 1) % D
  end
end

puts D
C.each do |c|
  puts c+1
end

Measured memory_bytes: 29564
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, a[100], b[100], c[100];
int dp[60][60][9];
int main() {
	for (int i = 0; i < 60; i++) { for (int j = 0; j < 60; j++) { for (int k = 0; k < 9; k++)dp[i][j][k] = -999999999; } }
	cin >> n >> m; for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i]; dp[0][m][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= m; j++) {
			for (int k = 0; k <= 8; k++) {
				if (dp[i][j][k] <= -100000000)continue;
				for (int l = 0; l <= 8; l++) {
					for (int o = 0; o <= k; o++) {
						for (int r = 0; r <= l; r++) {
							if (r + o >= 9)continue;
							int p = a[i] * r + b[i] * o;
							if (r == 0 && o == 0)p = c[i];
							int q = j - l; if (q < 0)continue;
							dp[i + 1][q][l] = max(dp[i + 1][q][l], dp[i][j][k] + p);
						}
					}
				}
			}
		}
	}
	int maxn = -999999999; for (int i = 0; i <= m; i++) { for (int j = 0; j <= 8; j++)maxn = max(maxn, dp[n][i][j]); }
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 3260
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	t = dict()
	for i in a:
		if t.get(i):
			t[i] += 1
		else:
			t[i] = 1
	a, b = 0, 0
	for k in t:
		if t[k] >= 4:
				a = max(a, k)
				b = max(b, k)
		elif t[k] >= 2:
			if k > a:
				b = a
				a = k
	print(a*b)
resolve()

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>

const int maxn=1e6+10;
const ll maxN=1e18+10;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int h,a;
  cin >> h >> a;
  if (h%a==0) cout << h/a;
  else cout << h/a+1;
}
    

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

using namespace std;

const int MOD = 1000000007;
const int MAX = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  int h, w, k, ans = 0, sum;
  char c;
  cin >> h >> w >> k;
  vector<vector<int>> ctable(h + 1, vector<int>(w + 1, 0));
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j < w + 1; j++) {
      cin >> c;
      if (c == '#') {
        ctable[0][0]++;
        ctable[0][j]++;
        ctable[i][0]++;
        ctable[i][j] = 1;
      }
    }
  }
  k = ctable[0][0] - k;
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      sum = 0;
      for (int ia = 0; ia < h; ia++) {
        if (i & (1 << ia)) {
          sum += ctable[ia + 1][0];
        }
      }
      for (int ia = 0; ia < w; ia++) {
        if (j & (1 << ia)) {
          sum += ctable[0][ia + 1];
        }
      }
      for (int ia = 0; ia < h; ia++) {
        for (int ib = 0; ib < w; ib++) {
          if (i & (1 << ia) && j & (1 << ib)) {
            sum -= ctable[ia + 1][ib + 1];
          }
        }
      }
      if (sum == k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	int n, k;
	int d, snack_home;
	cin >> n >> k;

	vector<int> home(n+1,0);

	for (int i = 0;i < k;i++) {
		cin >> d;
		while (d--) {
			cin >> snack_home;
			home[snack_home] += 1;
		}
	}
	int count = 0;
	for (int i = 1;i < home.size();i++) {
		if (home[i] == 0)
			count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long H = sc.nextLong();

            long ans = 0;

            while (H > 0) {
                ans = ans * 2 + 1;

                H = H / 2;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    map<int, ll> data;
    for (int i = 0; i < N; i++) {
        int a;
        ll b;
        cin >> a >> b;
        if (data.count(a)) {
            data[a] += b;
        }
        else {
            data[a] = b;
        }
    }
    ll sum = 0;
    for (pair<int, ll> p : data) {
        sum += p.second;
        if (sum >= K) {
            cout << p.first << endl;
            break;
        }
    }
}


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

struct UnionFind {
    //vector d
    //親のノードを記録する
    //親の場合は-(木の要素数)を記録する
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {} //constructor
    int find(int x){
        if(d[x] < 0){
            return x;
        }
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)
            return false;
        //xの木の方が、yの木よりも小さくないといけない
        if(-d[x] > -d[y]){
            swap(x, y);
        }
        d[x] += d[y];//yの木の要素数をxの木の要素数に合算する
        d[y] = x;//yの親をxにする
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return -d[x];
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    rep(i,q){
        int c, a, b;
        cin >> c >> a >> b;
        if(c==0){
            uf.unite(a, b);
        }else{
            cout << uf.same(a, b) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
  ll a,b,c;
  cin>>a>>b>>c;
  if(b*c>=a) cout<<"Yes"<<nn;
  else cout<<"No"<<nn;


}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll n;
const ll N_MAX = 3000+10;
ld pr[N_MAX];
ld dp[N_MAX][N_MAX]; // dp[i][j] = (i番目のコインまでで表がj個である確率)

ld q(ll i, ll j){
    if(dp[i][j]!=-1) return dp[i][j];

    if(j==0) dp[i][j] = q(i-1,j) * (1.0-pr[i-1]);
    else dp[i][j] = q(i-1,j) * (1.0-pr[i-1]) + q(i-1,j-1) * pr[i-1];

    return dp[i][j];
}

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

    cin >> n;
    REP(i,n) cin >> pr[i];

    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n;j++){
            if(i==0 && j==0) dp[i][j] = 1;
            else if(i==0) dp[i][j] = 0;
            else dp[i][j] = -1;
        }
    }
    ld ans = 0;

    for(ll i=n/2+1;i<=n;i++){
        ans += q(n,i);
    }
    cout << SP(12) << ans <<endl;


    
    return 0;
}



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

template<typename T = ll>
struct Dinic {
    struct Edge { int to, rev; T cap; Edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) {} };
    vector<vector<Edge>> graph;
    vector<int> level; // 距離
    vector<int> iter;

    void add_edge(int from, int to, T cap) {
        graph[from].emplace_back(to, graph[to].size(), cap);
        graph[to].emplace_back(from, graph[from].size() - 1, 0);
    }

    void bfs(int s) {
        level.assign(graph.size(), INT32_MAX);
        level[s] = 0;
        queue<int> que;
        que.push(s);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (auto& e : graph[v]) {
                if (e.cap > 0 && level[e.to] == INT32_MAX) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    T dfs(int v, int t, T f) {
        if (v == t) return f;
        for (int i = iter[v]; i < (int)graph[v].size(); ++i) {
            auto& e = graph[v][i];
            if (e.cap > 0 && level[e.to] > level[v]) {
                T ret = dfs(e.to, t, min(f, e.cap));
                if (ret > 0) {
                    e.cap -= ret;
                    graph[e.to][e.rev].cap += ret;
                    return ret;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t) {
        T flow = 0;
        for (T f; ; ) {
            bfs(s);
            if (level[t] == INT32_MAX) return flow;
            iter.assign(graph.size(), 0);
            while ((f = dfs(s, t, numeric_limits<ll>::max())) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    int V, E;
    cin >> V >> E;
    Dinic<ll> flow;
    flow.graph.resize(V);
    for (int i = 0; i < E; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        flow.add_edge(u, v, c);
    }

    cout << flow.max_flow(0, V - 1) << endl;
}


Measured memory_bytes: 3156
#include<iostream>
#define AC ios_base::sync_with_stdio(0),cin.tie(0)
#define ll long long 
#define eps 1e-6
using namespace std;
int main(){
	AC;
	ll a,b,c;
	cin>>a>>b>>c;
	ll p=(c-a-b)*(c-a-b);
	if(c-a-b<=2) cout<<"No\n";
	else if(4*a*b<p) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> v(N), c(N);
    for(int i=0; i<N; ++i) cin >> v[i];
    for(int i=0; i<N; ++i) cin >> c[i];
    int ans=0;
    for(int i=0; i<N; ++i) ans += max(0, v[i]-c[i]);
    cout << ans << endl;
	return 0;
}


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    print(N*N*N);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

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

    int x = c - a, y = d - b;
    cout << c - y << ' ' << d + x << ' ' << a - y << ' ' << b + x << endl;

    return 0;
}

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

int main() {
  int A, B, sam;
  cin >> A >> B;
  for(; A <= B; A++){
  int o = A / 10000, p = A / 1000 % 10,
      q = A / 10 % 10, r = A % 10;
    if (o == r && p == q){
      sam += 1;
    }
  }
  cout << sam << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,i,x,max,min;
    long long sum=0;
    scanf("%d",&n);
    scanf("%d",&x);
    min=x;
    max=x;
    sum+=x;
    for(i=1;i<n;i++){
        scanf("%d",&x);
        if(x<min) min=x;
        if(x>max) max=x;
        sum+=x;
    }
    
    printf("%d %d %ld\n",min,max,sum);
    
    return 0;
}


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

using namespace std;

const int MAX_N = 100000 + 7;

vector<int> A[MAX_N];

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

  int bb4ac = 1 + 8 * N;
  int sqrt_bb4ac = (sqrt(bb4ac) + 0.5);
  if (sqrt_bb4ac * sqrt_bb4ac != bb4ac) {
    puts("No");
    return 0;
  }

  if ((1 + sqrt_bb4ac) & 1) {
    puts("No");
    return 0;
  }

  int K = (1 + sqrt_bb4ac) / 2 - 1;
  for (int i = 1, sum = 0; i <= K; i++) {
    for (int j = 0; j < i; j++) {
      sum++;
      A[i].push_back(sum);
    }
  }

  puts("Yes");
  printf("%d\n", K + 1);

  printf("%d ", K);
  for (int i = 1; i <= K; i++)
    printf("%d%c", A[i].back(), " \n"[i == K]);

  for (int i = 1; i <= K; i++) {
    printf("%d ", K);
    int cnt = 0;
    for (int j = 0; j < (int)A[i].size(); j++)
      printf("%d%c", A[i][j], " \n"[++cnt == K]);
    for (int j = i + 1; j <= K; j++)
      printf("%d%c", A[j][(int)A[i].size() - 1], " \n"[++cnt == K]);
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  bool can = false;
  for(int i = 0; i < 26; i++) {
    for(int j = 0; j < 15; j++) {
      if(4 * i + 7 * j == N) {
      cout << "Yes" << endl;
      can = true;
      break;
      }
    }
     if(can) {
        break;
      }
  }
  if(!can) {
    cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  string ar;
  cin >> ar;
  int n = ar.size();
  int x = 0;
  int y = 0;
  for (int i = 0; i < n; i++){
    if (i & 1){
      if (ar[i] == '0'){
        x++;
      }
      else {
        y++;
      }
    }else {
      if (ar[i] == '1'){
        x++;
      }else {
        y++;        
      }
    }
  }
  cout << min(x, y) << '\n';
  return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	VI z(42);
	rep(i, 42){
		rep(j, n) z[i] += a[j]>>i & 1;
	}
	ll sp = 0;
	repr(i, 41, 0){
		if(z[i] < (n+1)/2 && sp + (1LL<<i) <= k) sp += 1LL<<i;
	}
	ll ans = 0;
	rep(i, n) ans += sp ^ a[i];
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<P> b(n);
	REP(i,n) {
		b[i].first=a[i];
		b[i].second=i;
	}
	sort(ALL(b));
	vector<ll> ret(n,0);
	ll lb=n;
	for(ll i=n-1; i>=0; i--) {
		if(i==0||b[i].first!=b[i-1].first) {
			if(b[i].second<lb) lb=b[i].second;
			if(i==0) ret[lb]+=(n-i)*b[i].first;
			else ret[lb]+=(n-i)*(b[i].first-b[i-1].first);
		}
	}
	REP(i,n) cout<<ret[i]<<endl;
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  rep(i,n){
    s.at(i)='x';
    cout<<s.at(i);
  }
}




 





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

int main() {
	int n, x;
	cin >> n >> x;
	int l[n+1], c[n+2];
	c[1] = 0;
	for(int i = 1; i < n+1; i++)
	{
		cin >> l[i];
		c[i+1] = c[i]+l[i];
	}
	for(int i = 1; i < n+2; i++)
	{
		if(x < c[i])
		{
			cout << i-1;
			return 0;
		}
	}
	cout << n+1;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	map<pair<int, int>, int>cnt;
	set<int>s;
	for (int i = 0; i < 6; ++i)
	{
		int h, w;
		cin >> h >> w;
		if (h > w)swap(h, w);
		cnt[{h, w}] ++;
		s.insert(h);
		s.insert(w);
	}
	if (s.size() == 3)
	{
		auto itr = s.begin();
		int a = *itr;
		++itr;
		int b = *itr;
		++itr;
		int c = *itr;
		if (cnt[{min(a, b), max(a, b)}] == 2 && cnt[{min(c, b), max(c, b)}] == 2 && cnt[{min(a, c), max(a, c)}] == 2)
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	else if (s.size() == 2)
	{
		auto itr = s.begin();
		int a = *itr;
		++itr;
		int b = *itr;
		if (cnt[{min(a, b), max(a, b)}] == 4 && cnt[{a, a}] == 2)
		{
			cout << "yes\n";
		}
		else if (cnt[{min(a, b), max(a, b)}] == 4 && cnt[{b, b}] == 2)
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	else if (s.size() == 1)
	{
		auto itr = s.begin();
		int a = *itr;
		if (cnt[{a, a}] == 6)
		{
			cout << "yes\n";
		}
		else
		{
			cout << "no\n";
		}
	}
	else
	{
		cout << "no\n";
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;
double const EPS = 1e-6;

int main() {

  int N, K, T, U, V; double L;
  cin >> N >> K >> T >> U >> V >> L;
  set<int> D;
  rep(i, N) {
    int d; cin >> d;
    D.insert(d);
  }

  int ninjin = 0;
  double stime = 0.0;
  int zizoku = 0;

  // ティツキツ敕ゥツ崢「テ」ツつ?テ」ツ?堙」ツ?、テゥツ?イテ」ツつ?」ツつ?

  rep(len, L) {

    if(D.count(len)) {
      if(ninjin + 1 > K) {
        zizoku = V * T;
      } else {
        ninjin ++;
      }
    }

    if(!zizoku && ninjin > 0) {
      ninjin --;
      zizoku = V * T;
    }

    if(zizoku) {
      zizoku --;
      stime += 1.0 / V;
    } else {
      stime += 1.0 / U;
    }

  }

  printf("%.10f\n", stime);
    
  return 0;
}

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

int main(){
	int N, i, s[5], a[5];
	for(i=0; i<5; i++){
		s[i] = a[i] = 0;
	}
	
	cin >> N;
	for(i=0; i<3; i++){
		s[i] = N/pow(10,i);
	}
	for(i=0; i<3; i++){
		a[i] = s[i] - 10*s[i+1];
	}
	
	if(a[0]==a[2]){
		cout << "Yes" << endl;
	}
	else	cout << "No" << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  double w;
  for(double i=1;i<3501;i=i+1){
    for(double j=1;j<3501;j=j+1){
      w=n*i*j/(4*i*j-n*i-n*j);
      if(fmod(w,1)==0&&w>0&&w<3501){
        int a=w;
        cout << i <<" "<< j <<" "<< a;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    vector<pair<int,int>> A;
    while(true){
        int n, x;
        cin >> n >> x;
        if(n == 0 and x == 0) break;
        A.push_back(make_pair(n, x));
    }
    for(auto p : A){
        int n = p.fi, x = p.se;
        int count = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x) count++;
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3120
def resolve():
    import math
    x, k, d = list(map(int, input().split()))
    ans = abs(x)
    x = abs(x)
    if x - d * k >= 0:
        ans = x - d * k
    else:
        k -= math.floor(x / d)
        x -= math.floor(x / d) * d
        if k % 2 == 1: x = abs(x - d)
        ans = x
    print(ans)


resolve()


Measured memory_bytes: 8972
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x + r <= W&&y - r >= 0 && y + r <= H)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> es(n, 0);
	vector<int> ws(n, 0);

	int e = 0;
	int w = 0;
	for (int i = 0; i < n; i++) {
		int ie = n - i - 1;
		es[ie] = e;
		if (s[ie] == 'E') {
			e++;
		}

		ws[i] = w;
		if (s[i] == 'W') {
			w++;
		}
	}

	int ans = n;

	for (int i = 0; i < n; i++) {
		ans = min(ans, es[i] + ws[i]);
	}

	// for (auto x : es) {
	// 	cout << x << " ";
	// }
	// cout << endl;
	// for (auto x : ws) {
	// 	cout << x << " ";
	// }
	// cout << endl;

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


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (s.count(x) == 0) s.insert(x);
		else s.erase(x);
	}

	cout << s.size() << "\n";
}

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

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

	printNum = a;

	for (int i = 0; i < k; i++)
	{
		cout << printNum << endl;
		if (printNum >= b)
		{
			return 0;
		}
		++printNum;
	}

	if (printNum <= b - k + 1)
	{
		printNum = b - k + 1;
	}

	for (int i = 0; i < k; i++)
	{
		cout << printNum << endl;
		if (printNum >= b)
		{
			return 0;
		}

		++printNum;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	string N;
	int count = 0;

	cin >> N;



	for (int i = 0; N[i] != '\0'; i++) {
		if (N[i] == '2') {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  rep(i, 101) {
    rep(j, 2) {
      ll tmp;
      if (j == 0) tmp = x - i;
      else tmp = x + i;

      if (find(p.begin(), p.end(), tmp) == p.end()) {
        cout << tmp << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  int sum = 0;
  int i = 0;
  while(sum < x){
    i++;
    sum += i;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

// {{{ Update / Max Query Segtree
namespace update_max_st {
  using S = ll;
  using F = ll;

  const S INF = 1e18;
  const F ID = 1e18;

  S op(S a, S b) { return std::max(a, b); }
  S e() { return -INF; }
  S mapping(F f, S x) { return (f == ID ? x : f); }
  F composition(F f, F g) { return (f == ID ? g : f); }
  F id() { return ID; }
  using st = atcoder::lazy_segtree<S, op, e, F, mapping, composition, id>;
}  // namespace update_max_st
using update_max_segtree = update_max_st::st;
// }}}

void solve() {
  ll N, K;
  cin>>N>>K;
  update_max_segtree st(303030);
  st.apply(0, 303030, 0);
  rep(_,N) {
    ll a;
    cin>>a;
    ll t = st.prod(max(a-K,0ll), min(a+K+1, 303030ll));
    st.apply(a, t+1);
  }
  cout << st.prod(0,303030) << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 18064
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n) {
        int s[5001];

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

        int ma = -100000;

		for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) {
			ma = max(ma, s[i] - s[j - 1]);
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 1040
#include <stdio.h>
int main(void){
    // Your code here!
    int i,j,k,n,x;
    int count;
    
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0&&x==0) break;
        
        count=0;
        for(i=1;i*3+3<=x;i++){
            for(j=i+1;i+2*j+1<=x;j++){
                for(k=n;k>j;k--){
                    if(x==i+j+k){
                        count++;
                        break;
                    }
                    else if(x>=i+j+k){
                        break;
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<20);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ll ans=0;
	ll ans2=0;
	for(int i=0;i<n;i++){
		if(n-1-i<k-1)continue;
		ans+=a[i]*p.comb(n-1-i,k-1);
		while(ans<0){
			ans+=mod*mod;
		}
		ans%=mod;
	}
	sort(a.rbegin(),a.rend());
	for(int i=0;i<n;i++){
		if(n-1-i<k-1)continue;
		ans2+=a[i]*p.comb(n-1-i,k-1);
		while(ans2<0){
			ans2+=mod*mod;
		}
		ans2%=mod;
	}
	cout << (ans2-ans+mod)%mod << endl;
}

Measured memory_bytes: 17408
// 2014/09/13 Tazoe

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
	for(int I=1; ; I++){
		int W;
		cin >> W;

		if(W==0)
			break;

		int DP[1001] = {0};

		int N;
		cin >> N;

		for(int i=0; i<N; i++){
			string s;
			cin >> s;

			for(int j=0; j<s.size(); j++){
				if(s[j]==','){
					s[j] = ' ';
					break;
				}
			}

			istringstream is(s);
			int v, w;
			is >> v >> w;

			for(int j=W; j-w>=0; j--){
				DP[j] = max(DP[j], DP[j-w]+v);
			}
		}

		int V_max = DP[W];
		int W_max = W;
		for(int i=W-1; i>=0; i--){
			if(DP[i]>=V_max){
				V_max = DP[i];
				W_max = i;
			}
		}

		cout << "Case " << I << ":" << endl;
		cout << V_max << endl;
		cout << W_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <functional>
#include <vector>
using namespace std;

const long long MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> graph[n + 1];
    for (int a, b; cin >> a >> b; graph[b].emplace_back(a)) {
        graph[a].emplace_back(b);
    }
    long long result = 1;
    function<void(int, int, int, int)> dfs = [&](int node, int parent, int depth, int free) {
        result = result * free % MOD;
        int used = 1;
        for (int i : graph[node]) {
            if (i != parent) {
                int next = k - used;
                if (depth > 0) {
                    next--;
                }
                dfs(i, node, depth + 1, max(next, 0));
                used++;
            }
        }
    };
    dfs(1, -1, 0, k);
    cout << result;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(pll i1, pll i2) {return (i1.s < i2.s);}
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a<=5)
        cout<<0;
    else if(a>=6&&a<=12)
        cout<<b/2;
    else
        cout<<b;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long int k,n,max=0;
  cin>>k>>n;
  long int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  for(int i=0;i<n-1;i++)
  {
      if(a[i+1]-a[i]>max)
        max=a[i+1]-a[i];
  }
  if(k-a[n-1]+a[0]>max)
    max=k-a[n-1]+a[0];
  cout<<k-max;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#define rep(i,n) for(int i=0; i< (int)(n); i++)
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	int d[110];
	cin >> N;
	rep(i,N) cin >> d[i];
	set <int> values;
	rep(i,N) values.insert(d[i]);
	cout << values.size() << "\n";


} 



Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
ts = n.times.map{gets.chomp.split.map(&:to_i)}.sort_by(&:first).sort_by(&:last).reverse
ans = 0
availables = (1..m).to_a
ts.each do |d,r|
  if index = availables.bsearch_index{|i| i >= d}
    availables.delete_at(index)
    ans += r
  end
end
puts ans

Measured memory_bytes: 15528
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;

vector<int> v, parent, dist;

// P(parent, dist)
P find(int a){
  if(parent[a] == a) return P(a, dist[a]);
  P p = find(parent[a]);
  parent[a] = p.first;
  dist[a] += p.second;
  return P(p.first, dist[a]);
}

bool same(int a, int b){
  return find(a).first == find(b).first;
}

void merge(int a, int b, int _d){
  if(same(a, b)) return ;
  P pa = find(a), pb = find(b);
  int d = _d - pb.second + pa.second;
  if(d < 0){
    d *= -1;
    swap(pa, pb);
  }
  parent[pb.first] = pa.first;
  dist[pb.first] = d;
}

void init_union_find(int V){
  v = vector<int>(V);
  parent = vector<int>(V);
  dist = vector<int>(V, 0);
  REP(i, V) parent[i] = i;
}

int main() {
  int N, M;
  while(cin >>N >>M && N){
    init_union_find(N);
    REP(i, M){
      char c; cin >>c;
      if(c == '!'){
        int x, y, z; cin >>x >>y >>z;
        merge(x - 1, y - 1, z);
      } else{
        int x, y; cin >>x >>y;
        P xp = find(x - 1), yp = find(y - 1);
        if(!same(x - 1, y - 1)) cout <<"UNKNOWN" <<endl;
        else cout <<yp.second - xp.second <<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MOD = 998244353, MX = 2e6+5;
int n,m;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
ll ans;
int main(){
	scanf("%d%d", &n, &m);
	setcomb(m*2+n);
	ans = MOD - n*comb(m+n-2,n-1)%MOD;
	for(int i=m&1; i<=min(m,n); i+=2) ans += comb(n,i) * comb((m*3-i)/2+n-1,n-1) % MOD;
	printf("%lld\n", ans % MOD);
}

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

using namespace std;

#define N_MAX 20

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

	double x[N_MAX];
	string u[N_MAX];

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

	double ans = 0;

	for (int i = 0; i < N; i++) {
		if (u[i] == "JPY") {
			ans += x[i];
		} else {
			ans += x[i] * 380000.0;
		}
	}

	cout << ans << 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 n = Integer.parseInt(sc.next());
        
        if(n == 1){
            System.out.println("Hello World");
        }else{
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            System.out.println(a+b);
        }
    }
}

Measured memory_bytes: 21204