akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int dp[105][105];

int main(){
    int h, w; cin >> h >> w;
    vector<string> vs(h);
    rep(i, h){
        cin >> vs[i];
    }

    if(vs[0][0] == '#') dp[0][0] = 1;
    rep(j, w-1){
        dp[0][j+1] = dp[0][j];
        if(vs[0][j+1] == '#' && vs[0][j] == '.') dp[0][j+1]++;
    }

    rep(i, h-1) rep(j, w){
        if(j == 0){
            dp[i+1][0] = dp[i][0];
            if(vs[i+1][0] == '#' && vs[i][0] == '.') dp[i+1][0]++;
            continue;
        }

        int m = dp[i][j], n = dp[i+1][j-1];
        if(vs[i+1][j] == '#' && vs[i][j] == '.') m++;
        if(vs[i+1][j] == '#' && vs[i+1][j-1] == '.') n++;
        dp[i+1][j] = min(m, n);
    }

    out(dp[h-1][w-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, c;
    cin >> n >> c;
    vector<pair<ll, ll>> xv(n);
    rep(i, n) cin >> xv[i].first >> xv[i].second;
    vector<pair<ll, ll>> dpr(n + 1), dpl(n + 1);
    dpr[0] = make_pair(0, 0);
    dpl[0] = make_pair(0, 0);
    ll plus = 0, minus = 0, score = 0;
    rep(i, n) {
        plus += xv[i].second;
        if (score < (plus - xv[i].first)) {
            minus = xv[i].first;
            score = plus - minus;
        }
        dpr[i + 1] = make_pair(score, minus);
    }
    plus = 0, minus = 0, score = 0;
    rep(i, n) {
        plus += xv[n - 1 - i].second;
        if (score < (plus - (c - xv[n - 1 - i].first))) {
            minus = c - xv[n - 1 - i].first;
            score = plus - minus;
        }
        dpl[i + 1] = make_pair(score, minus);
    }
    ll ans = 0;
    rep(i, n + 1) {
        ans = max(ans, dpr[i].first + dpl[n - i].first - min(dpr[i].second, dpl[n - i].second));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#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() {
  int N; cin >> N;
  int C[50],V[50];
  for ( int i = 0; i < N; i++ ) cin >> V[i];
  for ( int i = 0; i < N; i++ ) cin >> C[i];
  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( V[i] - C[i] > 0 ) sum += V[i]-C[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#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 watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e14
#define MOD 1000000007
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

ll pw(ll a,ll b){
	if(b==0) return 1;
	if(b==1) return a%MOD;
	if(b%2==0) return (pw(a,b/2)*pw(a,b/2))%MOD;
	return ((a*pw(a,b/2))%MOD*pw(a,b/2))%MOD;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; cin>>s;
	
	ll n = s.length();
	ll ans=0;
	ll inc=1;
	forn(i,0,n){
		if(s[i]=='1'){
			ans+=inc*pw(3LL, n-1-i);
			ans%=MOD;
			inc*=2; inc%=MOD;
		}
	}
	ans+=inc; ans%=MOD;
	cout<<ans<<'\n';
	
	return 0;
}


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

 using namespace std;

 int main() {
   int N, i, maxa, mina;

   cin >> N;

   vector<int> a(N + 1);

   for (i = 1; i <= N; i++) cin >> a.at(i);

   maxa = 0;
   mina = 1000;

   for (i = 1; i <= N; i++) {
     maxa = max(maxa, a.at(i));
     mina = min(mina, a.at(i));
   }
   cout << maxa - mina << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>

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; }


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    
    int n;
    long long int act[100010][3];
    long long int dp[100010][3];
    for(int i=0; i<100010; i++)
    {
        for(int j=0; j<3; j++)
        {
            act[i][j]=0;
            dp[i][j]=0;
        }
    }
    
    
    std::cin >> n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            std::cin >> act[i][j];
        }
    }
    
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(j==k) continue;
                chmax(dp[i+1][k], dp[i][j]+act[i][k]);
            }
        }
    }

    std::cout << std::max({dp[n][0], dp[n][1], dp[n][2]}) << std::endl;

    return 0;
}


Measured memory_bytes: 5500
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//メイン関数
int main() {
	//入力の取得
	int N;
	std::cin >> N;

	std::vector<long> A(N);
	std::vector<long> B(N);

	for(int i=0; i<N; ++i) {
		long tempA;
		long tempB;
		std::cin >> tempA >> tempB;
		A.push_back(tempA);
		B.push_back(tempB);
	}

	//答え
	long answer = 0;

	//計算
	for(int i=N-1; i>=0; --i) {
		long Ai = A.back() + answer;
		long Bi = B.back();
		A.pop_back();
		B.pop_back();
		long answerTemp = (Ai % Bi);
		if(answerTemp == 0) {
			continue;
		}

		answer += Bi - answerTemp;
//		std::cout << Bi - answerTemp << std::endl;
	}

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,a,b;cin >> n >> a >> b;
	int h[n];
	rep(i,n)cin>> h[i];
	sort(h,h+n);
	reverse(h,h+n);
	auto ok = [&](int c){
		//c回でできるか
		int ret = 0;
		rep(i,n){
			int rest = max(0ll,h[i] - c*b);
			//-(a-b)する
			int shine = (rest + a-b - 1)/(a-b);
			ret += shine;
            if(ret > c){
                return false;
            }

		}
		return true;
	};
	
	int bot = -1,top = 1e10;
	while(top - bot > 1){
		int mid = (top + bot)/2;
		if(ok(mid))top = mid;
		else bot = mid;
	}
	cout << top  << endl;
	return 0;
}

Measured memory_bytes: 4344
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll m,n;cin>>m>>n;
	vector<ll> v,a;
	for(ll i=0;i<n;i++){
		ll x;cin>>x;
		v.pb(x);
	}
	sort(all(v));
	for(ll i=1;i<n;i++){
		a.pb(v[i]-v[i-1]);
	}
	ll ans=0;
	if(m>=n)return cout<<"0",0;
	m--;
	sort(all(a));
	//for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;
	for(ll i=0;i<n-m-1;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
}

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

int main() {
  int N, M, L;
  L = 0;
  cin >> N >> M;
  
  vector<int> vec(M);
 
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < M; i++) {
    L += vec.at(i);
  }

  if (L <= N) {
    cout << N - L << endl;
  }
  else {
  cout << "-1" << endl;
  }
}

Measured memory_bytes: 3672
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	fmt.Println(x * x * x)
}



Measured memory_bytes: 1116
from collections import*
from heapq import*
n,m,*a=map(int,open(0).read().split())
t=[-1]*n
def r(x):
  while t[x]>=0:x=t[x]
  return x
def u(x,y):
  x,y=r(x),r(y)
  if x!=y:
    if t[x]>t[y]:x,y=y,x
    t[x]+=t[y]
    t[y]=x
d=defaultdict(list)
for x,y in zip(*[iter(a[n:])]*2):u(x,y)
for i,v in enumerate(a[:n]):d[r(i)]+=v,
if len(d)<2:
  print(0)
  exit()
*d,=map(sorted,d.values())
c=sum(heappop(t)for t in d)
l=[]
for t in d:l+=t
i=len(d)-2
print(i>len(l)and'Impossible'or c+sum(sorted(l)[:i]))

Measured memory_bytes: 104832
N = int(input())
A = list(map(int, input().split()))
used = [False for i in range(N)]
ans = 0
for i in range(len(A)):
    if i + 1 == A[A[i] - 1] and not used[i] and not used[A[i] - 1]:
        ans += 1
        used[i] = True
        used[A[i] - 1] = True
print(ans)

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

bool S[15], H[15], C[15], D[15] = {false};
int main() {
	
	char r;	
	int n;
	int x;
	
	cin >> n;
		
	for ( int i = 0 ; i < n ; i++ ) {
    	cin >> r >> x;
	
		if (r == 'S') {
			S[x] = true; 
		} else if (r == 'H') {
			H[x] = true; 
		} else if (r == 'C') {
			C[x] = true; 
		} else if (r == 'D') {
			D[x] = true; 
		}
		
	}
	
	for (int i = 1; i < 14; i++) {
		if (S[i] == false) {
			cout << 'S' << " " << i << endl;	
		} 
	}
	
	for (int i = 1; i < 14; i++) {
		if (H[i] == false) {
			cout << 'H' << " " << i << endl;	
		} 
	}
	
	for (int i = 1; i < 14; i++) {
		if (C[i] == false) {
			cout << 'C' << " " << i << endl;	
		} 
	}
	
	for (int i = 1; i < 14; i++) {
		if (D[i] == false) {
			cout << 'D' << " " << i << endl;	
		} 
	}
	
	return 0;
}


Measured memory_bytes: 3100
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  int ans = 0;
  ans = n*(n-1)/2 + m*(m-1)/2;
  printf("%d\n",ans );
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool chk = false;
		for(int i=1;i<N-1;i++){
			if(E[0].Contains(i) && E[N-1].Contains(i)) chk = true;
		}
		Console.WriteLine(chk ? "POSSIBLE" :"IMPOSSIBLE");
		
	}
	int N,M;
	HashSet<int>[] E;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		E = new HashSet<int>[N];
		for(int i=0;i<N;i++) E[i] = new HashSet<int>();
		for(int i=0;i<M;i++){
			d = ria();
			d[0]--; d[1]--;
			E[d[0]].Add(d[1]);
			E[d[1]].Add(d[0]);
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

struct name {
  string name_;
  int count_;
};

bool cmp (const name &a, const name &b) {
  if (a.count_ > b.count_) {
    return true;
  }
  if (a.count_ < b.count_) {
    return false;
  }
  if (a.name_ < b.name_) {
    return true;
  }
  if (a.name_ < b.name_) {
    return false;
  }
  return false;
}

int main() {

  int N;
  cin >> N;

  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    string s_;
    cin >> s_;
    mp[s_]++;
  }

  vector<name> v;
  for (auto item:mp) {
    name v_ = name();
    v_.name_ = item.first;
    v_.count_ = item.second;
    v.push_back(v_);
  }

  sort(v.begin(), v.end(), cmp);

  int current = v[0].count_;
  for (int i = 0; i < N; i++) {
    if (v[i].count_ == current) {
      cout << v[i].name_ << endl;
    } else {
      break;
    }
  }

  return 0;

}

Measured memory_bytes: 30448
import java.util.Scanner;
import java.util.StringJoiner;

class Main {

	static int count;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] s = new int[n];

		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		sc.close();

		mergeSort(s, 0, n);

		StringJoiner sj = new StringJoiner(" ");
		for (int i = 0; i < n; i++) {
			sj.add(String.valueOf(s[i]));
		}

		System.out.println(sj.toString());
		System.out.println(count);

	}

	private static void mergeSort(int[] arr, int left, int right) {

		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(arr, left, mid);
			mergeSort(arr, mid, right);
			merge(arr, left, mid, right);
		}

	}

	private static void merge(int[] arr, int left, int mid, int right) {

		int n1 = mid - left;
		int n2 = right - mid;

		int[] L = new int[n1+1];
		int[] R = new int[n2+1];

		for (int i = 0; i < n1; i++) {
			L[i] = arr[left+i];
		}

		for (int i = 0; i < n2; i++) {
			R[i] = arr[mid+i];
		}
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;

		int i = 0;
		int j = 0;

		for (int k = left; k < right; k++) {
			if (L[i] <= R[j]) {
				arr[k] = L[i];
				i++;
			} else {
				arr[k] = R[j];
				j++;
			}

			count++;

		}
	}
}

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

int main() {
    
    string s, t;
    cin >> s >> t;
    int s_length = s.length();
    int t_length = t.length();
    vector<vector<int>> dp(s_length + 1, vector<int>(t_length + 1));
    for (int i = 0; i <= s_length; i++) {
        dp[i][0]  = 0;
    }
    for (int i = 0; i <= t_length; i++) {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= s_length; i++) {
        for (int j = 1; j <= t_length; j++) {
            if (s.substr(i-1, 1) == t.substr(j-1, 1)) {
                dp[i][j] = dp[i-1][j-1] + 1; 
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string res = "";
    int i = s.length();
    int j = t.length();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j-1]) {
            --j;
        } else {
            res = s.substr(i-1, 1) + res;
            --i;
            --j;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 35584
//============================================================================
// Name        : Test.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int n,x;
	int c = 0;

	while(1){
		cin >> n >> x;
		if(n == 0 && x == 0) break;

		for(int i = 1; i <= n-2;i++){
			for(int j = i+1; j <= n-1;j++){
				for(int k = j+1; k <= n;k++){
					//cout <<  i << j << k << " " <<i+j+k << endl;
					if((i+j+k) == x) c += 1;
				}
			}
		}

		/*
		for(int i = 1; i <= n;i++){
			for(int j = 1; j <= n;j++){
				for(int k = 1; k <= n;k++){
					//cout <<  i << j << k << " " <<i+j+k << endl;
					if(i == j || j == k || k == i){
						cout <<  i << j << k << " " <<i+j+k << endl;
						break;
					}
					if((i+j+k) == x) c += 1;
				}
			}
		}
		*/

		cout << c << endl;

		c = 0;
	}

	return 0;
}

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

#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii >
#define vll vector<ll >
#define cps CLOCKS_PER_SEC
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define print(s) cout<<#s<<" : ";for(auto i:(s))cout<<i<<" ";cout<<"\n";
#define slld(t) scanf("%lld",&(t))
#define sd(t) scanf("%d",&(t))
#define pd(t) printf("%d\n",(t))
#define plld(t) printf("%lld\n",(t))
#define endl "\n"

const int N = 1e7+10;
int dp[N];
int main()
{
    dp[1] = 1;
    dp[2] = 2;
    for(int i = 3;i<N;i++)
    {
        int k = sqrt(2*i)-1;
        while(1)
        {
            if(dp[i-k] < k)
            {
                dp[i] = k;
                break;
            }
            k++;
        }
    }   
    int n;
    cin>>n;
    vi vec;
    while(n > 0)
        vec.eb(dp[n]),n-=dp[n];
    sort(all(vec));
    for(int x:vec)
        cout<<x<<endl;
}

Measured memory_bytes: 39424
#include<iostream>
using namespace std;
int main()
{
  int A, B, K;
  cin >> A >> B;
  if((A+B)%2 == 0){
    K = (A+B)/2;
    cout << K << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
    return 0;
}

Measured memory_bytes: 256
inp = input()
inp = inp.split()
a = int(inp[0])
b = int(inp[1])
c = int(inp[2])
k = int(inp[3])
if k <= a:
    print(k)
else:
    sum = a
    k = k - a
    if k <= b:
        print(sum)
    else:
        k = k - b
        sum = sum - k
        print(sum)

Measured memory_bytes: 9072
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
 
int main()
{
/*
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
 */
	int n,x,ans=0;
	cin >> n;
	for (int i = 0, mi = 1e9; i < n; i++) {
		cin >> x;
		if (x < mi)mi = x, ans++;
	}
	cout << ans << endl;
	return 0;
}

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

signed main(){
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int ans=0;
  if(K%2==0){
    ans=A-B;
  }else{
    ans=B-A;
  }
  if(ans>=1000000000000000000){
    cout<<"Unfair"<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
char s[100010]; 
int a[10010];
int main() {
	scanf("%s",s);
	int n=strlen(s);
	rep(i,0,n-1){
		a[s[i]]=1;
	}
	if((a['W']^a['E'])||(a['N']^a['S']))puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        if(1<=N && N<=9){
            System.out.println(N);
        }else if(10<=N && N<=99){
            System.out.println(9);
        }else if(100<=N && N<=999){
            System.out.println(9+N-99);
        }else if(1000<=N && N<=9999){
            System.out.println(909);
        }else if(10000<=N && N<=99999){
            System.out.println(909+N-9999);
        }else{
            System.out.println(90909);
        }
        
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
long long  modl(long long a, long long b, long long c) 
{
    long long res, t;
    res = 1 % c;
    t = a % c;
    while (b)
    {
        if (b & 1)
        {
            res = res * t % c;
        }
        t = t * t % c;
        b >>= 1;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,temp=1,i;
    long long int var;
    cin>>n;
    long int mod=pow(10,9)+7;
    vector<long long int> a(n);
    if(n%2==0)
    {
    for(i=0;i<n;i++)
    {
        cin>>var;
        if(var%2==0)
        {temp=0;
        break;}
        else
        {
            a[var/2]++;
        }
        if(a[var/2]>2)
        {
            temp=0;
            break;
        }
    }
    }
    else
    {
    for(i=0;i<n;i++)
    {
        cin>>var;
        if(var%2!=0)
        {temp=0;
        break;}
        else
        {
            a[var/2]++;
        }
        if(a[var/2]>2)
        {
            temp=0;
            break;
        }
    }
    if(a[0]!=1)
    temp=0;
    }
    if(temp==0)
    {
        cout<<0;
    }
    else
    cout<<modl(2,(n/2),mod)%mod;
    
    return 0;
}

Measured memory_bytes: 1024
var
	n,ans:Longint;
procedure f(x:int64;a,b,c:Boolean);
begin
	if x>n then exit;
	if a and b and c then inc(ans);
	f(x*10+3,True,b,c);
	f(x*10+5,a,True,c);
	f(x*10+7,a,b,True);
end;
begin
	read(n);
	if n>777777752 then begin writeln(26484);exit;end;
	f(0,False,False,False);
	writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
#define N 524288
#define pi acosl(-1)
typedef complex<long double> C;
int n,m,i,t,g[N];
C a[N],b[N];
void FFTinit(){
	for (i=1;i<N;i++) g[i]=g[i>>1]>>1|((i&1)<<18);
}
void FFT(C *a,int f){
	int i,j,k,p;
	for (i=0;i<N;i++)
		if (g[i]>i) swap(a[i],a[g[i]]);
	for (i=1;i<N;i<<=1){
		C e(cos(pi/i),f*sin(pi/i));
		for (j=0;j<N;j+=i<<1){
			C w(1,0);
			for (k=0;k<i;k++,w*=e){
				C x=a[j+k],y=w*a[j+k+i];
				a[j+k]=x+y;a[j+k+i]=x-y;
			}
		}
	}
}

int mod = 200003;
int root = 2;
LL cnt[200005];
LL ans[410005];
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
int main(){
    int vis[200005];
    LL sum=1;
    for(int i = 0;i<mod-1;i++){
        vis[sum]=i;
        sum=sum*root%mod;
    }

    int n;
    scanf("%d",&n);
    vector<int> v;
    for(int i = 0;i<n;i++){
        int x=2;
        scanf("%d",&x);
        if(x){
            v.pb(vis[x]);
            cnt[vis[x]]++;
         //   printf("%d ",vis[x]);
            assert(f_pow(root,vis[x])==x);
        }
    }
 //  printf("\n");
    for(int i = 0;i<200005;i++){
        a[i]=cnt[i];
    }
    FFTinit();
    FFT(a,1);
    for(int i = 0;i<N;i++)a[i]=a[i]*a[i];
    FFT(a,-1);
    LL res=0;

    for(int i = 0;i<400005;i++){
        ans[i%(mod-1)]+=(a[i].real()/N+0.5);
      /*  if(ans[i]){
     //       printf("%d %lld\n",i,ans[i]);
            res+=f_pow(2,i)*ans[i];
        }*/
    }
    for(auto it:v){
        ans[(it*2)%(mod-1)]--;
    }
    for(int i = 0;i<400005;i++){
        ans[i]=ans[i]/2;
        if(ans[i]){
          //  printf("%d %lld\n",i,ans[i]);
            res+=f_pow(2,i)*ans[i];
        }
    }
    printf("%lld\n",res);
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/

Measured memory_bytes: 28572
#include "bits/stdc++.h"
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin>>s;
    bool ok=false;
    for(ll i=0;i<s.length();i++){
        if(s[i]=='9') ok=true;
    }
    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
#define fi first
#define se second
#define mod 1000000007
#define maxn 200005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;while(t--)
#define go_pt int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<ll,ll>pii;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int infi = 100005;
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    #endif

    fastio;
    ll n;
    cin>>n;
    ll ans = (n-1)*(n);
    ans/=2;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int a[2];
	cin >> a[0] >> a[1] >> a[2];

	int b = a[0]+a[1];
	if(a[1]+a[2] < b){
		b = a[1]+a[2];
	}

	if(a[0]+a[2] < b){
		b = a[0]+a[2];
	}

	cout << b;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

l,r,d = LI()
ans = 0
for i in range(l, r+1):
    if i % d == 0:
        ans += 1
print(ans)

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=2100;
const ll mod=1e9+7;
const ll inf=1e9+500;


ll dp[maxn][2*maxn];
ll par[maxn][2*maxn];


ll fac[maxn*maxn];
ll rfac[maxn*maxn];

ll  ent(ll n,ll k){
	if(k>n || k<0){
		return 0;
	}
	return (((fac[n]*rfac[n-k])%mod)*rfac[k])%mod;
}	
ll poww(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b&1){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b=(b>>1);
	}
	return ans;
}
int main(){

	fac[0]=1;
	for(ll i=1;i<maxn*maxn;i++){
		fac[i]=(fac[i-1]*i)%mod;
	}	
	for(ll i=0;i<maxn*maxn;i++){
		rfac[i]=poww(fac[i],mod-2);
	}




	ll n,k;
	cin>>n>>k;

	if(k==1){
		cout<<1;
		return 0;
	}
	dp[1][1]=1;
	par[1][1]=1;
	for(ll j=2;j<2*maxn;j++){
		par[1][j]=par[1][j-1];
	}
	for(ll i=2;i<=n;i++){
		for(ll j=1;j<2*i;j++){
			dp[i][j]=ent(j+(k-2)*i-1,k-2)*par[i-1][j-1];
			par[i][j]=(par[i][j-1]+dp[i][j])%mod;
		}
		for(ll j=2*i;j<2*maxn;j++){
			par[i][j]=par[i][j-1];
		}
	}
	cout<<(par[n][2*maxn-5]*fac[n])%mod<<endl;

}








/*    
	  .      _______    __    ___     ________      ________       _________     _________   ________
	  .     /       \  |  |  /  /    /        \    |        \     /         \   |        |  |   __   \
	  .    /   _____/  |  | /  /    /    ___   \   |   ___   \   |   _______/   |  ______|  |  |  \   \
	  .   /   /        |  |/  /    /    /   \   \  |  |   \   \  |  (______     |  |_____   |  |__/   /
	  .   |  |         |     /     |   /     \  |  |  |    |  |   \        \    |        |  |      __/
	  .   |  |         |     \     |   \     /  |  |  |    |  |    \______  \   |  ______|  |      \
	  .   \   \_____   |  |\  \    \    \___/   /  |  |___/   /    _______) |   |  |_____   |   |\  \
	  .    \        \  |  | \  \    \          /   |         /    /         /   |        |  |   | \  \
	  .     \_______/  |__|  \__\    \________/    |________/     \________/    |________|  |___|  \__\
 */



Measured memory_bytes: 203008
#include <stdio.h>
int main(){
  int n, x[100+1]={0};
  long long sum=0, min=1000000000;
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf("%d", &x[i]);
  }

  for(int p=0; p<100; p++){
    for(int i=0; i<n; i++){
      sum += ( (x[i]-p) * (x[i]-p) );
    }
    if( sum < min ){ min = sum; }
    sum=0;
  }
  printf("%lld\n", min);
  return 0;
}

Measured memory_bytes: 1716
#include<iostream>
using namespace std;
 
int N, A, B, C, D;
int X_SET,Y_SET,X_SUM,Y_SUM;

int main(){
   
cin>>N>>A>>B>>C>>D;
  
X_SET = N / A;
	if( N % A > 0) X_SET = X_SET + 1 ;

Y_SET = N / C;
	if( N % C > 0) Y_SET = Y_SET + 1 ;

X_SUM = B * X_SET;
Y_SUM = D * Y_SET;

	if( X_SUM < Y_SUM ) cout<< X_SUM <<endl;
	else 
 	cout<< Y_SUM <<endl;

  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<stack>
using namespace std;
 
vector<int> G[1000000];
int inG[1000000];
int len[1000000];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, y;
	y = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n - 1; ++j) {
			cin >> a;
			--a;
			int x = min(a, i) * 1000 + max(a, i);
			if (j > 0) {
				G[y].push_back(x);
				++inG[x];
			}
			y = x;
		}
	}
	stack<int> st;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (inG[i * 1000 + j] == 0) st.push(i * 1000 + j);
		}
	}

	vector<int> ans;
	while (st.size()) {
		int i = st.top(); st.pop();
		ans.push_back(i);
		for (auto& e : G[i]) {
			if (--inG[e] == 0) st.push(e);
		}
	}
	if (ans.size() < n*(n - 1) / 2) {
		cout << -1 << endl;
	}
	else {

		for (auto e : ans) {
			len[e] = max(1, len[e]);
			for (auto f : G[e]) {
				len[f] = max(len[e] + 1, len[f]);
			}
		}
		int ansmax = 0;
		for (int i = 0; i < 1000000; ++i) {
			ansmax = max(ansmax, len[i]);
		}
		cout << ansmax << endl;
	}

}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


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

    string S;
    cin >> S;

    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	cin >> N >> M;
	VI cnt(N, 0);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	bool F = true;
	REP(i, N) {
		if (cnt[i] % 2)F = false;
	}
	cout << (F ? "YES" : "NO") << endl;
	return 0;
}



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

int main(){
    ll n, m;
    cin >> n >> m;
    
    map<ll,ll> store;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        store[a] += b;
    }

    ll sum=0;
    //mapは要素を下位から上位へと並べている
    for(auto &x:store){
        if(x.second<m){
            sum += x.first*x.second;
            m -= x.second;
        }
        else{
            sum += x.first*m;
            break;
        }
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 9828
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n);
		for(auto&ae:a) scanf("%d", &ae);
		sort(a.begin(), a.end());
		printf("%d\n", a.back()-a[0]);
	}
	return 0;
}


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

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

fn main() {
    let x:u32 = read();
    let y:u32 = read();
    let ans = gcd(x, y);
    println!("{}", ans);
}

fn gcd(x: u32, y: u32) -> u32 {
    if y == 0 {
        return x;
    }
    return gcd(y, x % y);
}


Measured memory_bytes: 5024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int c = scan.nextInt();
		int ans = 0;
		int b[] = new int[m];

		for (int i = 0; i < m; i++) {
			b[i] = scan.nextInt();
		}

		int num = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				num += scan.nextInt() * b[j];
			}
			if (num + c > 0)  ans++;
			num = 0;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <cstdlib>
#include <ctime>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 311
#define M 500010

typedef unsigned long long ull;
typedef long long ll;
const int INF=1<<30;

int w[N], v[N];
int dp[N][N][N];

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n, W, res = 0; 
	scanf("%d %d", &n, &W);
	for (int i = 1; i <= n; ++i) scanf("%d %d", &w[i], &v[i]);
	for (int t = 1; t <= n; ++t)
	{
		W -= w[1]; if (W < 0) break;
		int tmp = min(W, 300);
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= n; ++j)
				for (int k = 0; k <= tmp; ++k)
					dp[i][j][k] = -INF;
		dp[0][0][0] = 0;
		for (int i = 1; i <= n; ++i)
		{
			dp[i][0][0] = 0;
			for (int j = 1; j <= i; ++j)
			{
				for (int k = 0; k < w[i] - w[1]; ++k) dp[i][j][k] = dp[i - 1][j][k];
				for (int k = (w[i] - w[1]); k <= tmp; ++k)
				{
					dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - (w[i] - w[1])] + v[i]);
					//if (dp[i][j][k] > 0)cout << t<<" " <<i <<" " << j <<" " <<k <<" "<<dp[i][j][k] <<endl;
				}
			}
		}
		for (int k = 0; k <= tmp; ++k)  res = max(res, dp[n][t][k]);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 37888
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


ll N, M;
map<ll, ll> C;

string dp[10001];

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> N >> M;
    vector<ll> A;
    rep (i, M) {
        ll a;
        cin >> a;
        A.pb(a);
    }
    sort(all(A));
    ll table[] = {0,2,5,5,4,5,6,3,7,6};
    rep (i, M) {
        C[table[A[i]]] = A[i];
    }
    rep (i, N + 1) {
        if (i != 0 && dp[i] == "") continue;
        for (auto c : C) {
            if (i + c.fst > N) continue;
            string tmp = dp[i] + to_string(c.snd);
            sort(rall(tmp));
            const string& s_ = dp[i + c.fst];
            if (tmp.size() > s_.size()) {
                dp[i + c.fst] = tmp;
            } else if (tmp.size() == s_.size() && tmp > s_) {
                dp[i + c.fst] = tmp;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 29568
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	void run() {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		while(sc.hasNext()) {
			String str = sc.next();
			for(int i=0;i<str.length();i++) {
				if('0' <= str.charAt(i) && '9' >= str.charAt(i)) {
					String num = "";
					for(;i<str.length() && '0' <= str.charAt(i) && '9' >= str.charAt(i); i++)
						num += str.charAt(i);
					ans += Integer.parseInt(num);
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
N = gets.to_i
word = []
ac = 0
wa = 0
tle = 0
re = 0

(1..N).each do
  word.push(gets.chomp)
end

word.each do |text|
  case text
    when 'AC'
      ac += 1
    when 'WA'
      wa += 1
    when 'TLE'
      tle += 1
    when 'RE'
      re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 20460
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	string S;
	cin >> S;
	vector< char > table(3);
	table[0] = 'R';
	table[1] = 'G';
	table[2] = 'B';
	vector< vector< int > > acc(3, vector< int >(N + 1, 0));
	int ans = 0;
	rep(k, 3) rep(i, N) acc[k][i + 1] = acc[k][i] + (S[i] == table[k]);
	rep(i, N) rep(j, N) if (i < j) {
		if (S[i] == S[j])
			continue;
		int t;
		rep(k2, 3) if (S[i] != table[k2] && S[j] != table[k2]) t = k2;
		ans += acc[t][N] - acc[t][j + 1];
		int k = j * 2 - i;
		if (k < N && S[k] == table[t])
			ans--;
	}
	cout << ans << endl;
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, K;
    cin >> N >> K;

    int ans = 0;
    REP(i, N) {
        int h; cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << endl;


    return 0;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i).second >> a.at(i).first;
    }

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

    int t = 0;

    for(int i = 0;i < n;i ++){
        t += a.at(i).second;
        if(t > a.at(i).first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

// #include <boost/multiprecision/cpp_int.hpp>

using namespace std;
// namespace mp = boost::multiprecision;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  // mp::int128_t ans = 0;
  // bool ok = true;
  // for (int i = 0; i < n; ++i) {
  //   mp::int128_t a;
  //   cin >> a;
  //   if (a == 0) {
  //     ans = 0;
  //     break;
  //   }
  //   if (ok) {
  //     if (i == 0) {
  //       ans += a;
  //     } else {
  //       ans *= a;
  //     }
  //     if (ans > 1000000000000000000) {
  //       ans = -1;
  //       ok = false;
  //     }
  //   }
  // }

  int64_t ans = 0;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    int64_t a;
    cin >> a;
    if (a == 0) {
      ans = 0;
      break;
    }
    if (ok) {
      if (ans > 1000000000000000000 / a) {
        ans = -1;
        ok = false;
      } else {
        if (i == 0) {
          ans += a;
        } else {
          ans *= a;
        }
      }
    }
  }

  cout << ans << '\n';

  return 0;
}


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

    while (true)
    {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        
        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
                
                if(i % 2 == 0) {
                    if(j % 2 == 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }else{
                    if(j % 2 == 0){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
        cout << endl;
        }
    cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092