akhauriyash/Code-Regression huggingface dataset:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
s = []
for i in range(h):
    s.append(input().strip())
empcol = [True]*w
heademp = [h]*w
rightmostnonempcol = -1
for j in range(w):
    for i in range(h):
        if s[i][j]=='#':
            heademp[j] = i
            empcol[j] = False
            rightmostnonempcol = j
            break
b = [ [0]*w for i in range(h) ]
rect = 1
lastnonempcol = -1
for j in range(w):
    if j > rightmostnonempcol:
        for i in range(h):
            b[i][j] = b[i][j-1]
        continue
    if empcol[j]:
        continue
    for i in range(h):
        if s[i][j]=='#' and i!=heademp[j]:
            rect += 1
        b[i][j] = rect
    for jj in range(j-1,lastnonempcol,-1):
        for i in range(h):
            b[i][jj] = b[i][j]
    lastnonempcol = j
    rect += 1

for i in range(h):
    for j in range(w):
        printn(('' if j==0 else ' ') + str(b[i][j]))
    print('')


Measured memory_bytes: 45148
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    s = input()

    l = 0
    r = 0

    for i in s:
        if i == ")" and r > 0:
            r -= 1
        elif i == ")":
            l += 1
        if i == "(":
            r += 1
    print("("*l + s + ")"*r)




if __name__=="__main__":
    main()


Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1000000
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int H,W;
vector<string> S;
typedef pair<int,int> P;
vector<vector<int> > field;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int gx, gy;
bool bfs();

int main(){
    cin >> H >> W;
    S.resize(H);
    field.resize(H,vector<int>(W));
    REP(i,H){
        string s; 
        cin >> s;
        S[i] = s;
    }
    int count = 0; // #を数える
    REP(i,H){
        REP(j,W){
            if(S[i][j] == '#'){count++;}
            field[i][j] = INF;
        }
    }
    bool flag = bfs();

    int ans = H * W - count - field[H-1][W-1] - 1;

    cout << (flag ? ans : -1) << endl;
}

bool bfs(){
    bool flag = false;
    queue<P> que;
    int sx = 0,sy = 0;
    que.push(P(sx,sy));
    field[sx][sy] = 0;

    while(!que.empty()){
        P p = que.front();
        if(p.first == H - 1 && p.second == W -1){flag = true; break;}
        else{
        que.pop();
            REP(i,4){
                int nx = p.first + dx[i], ny = p.second + dy[i];
                if(0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] == '.' && field[nx][ny] == INF){
                    que.push(P(nx,ny));
                    field[nx][ny] = field[p.first][p.second] + 1;
                }
            }
        }
    }
   return flag;
}





Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
P = sorted([A[i]-B[i] for i in range(N) if A[i]-B[i]>0],reverse=True)
C = [0 for _ in range(N+1)]
for i in range(1,len(P)+1):
    C[i] = C[i-1]+P[i-1]
M = [B[i]-A[i] for i in range(N) if B[i]-A[i]>0]
p = sum(P)
m = sum(M)
if m>p:
    ans = -1
else:
    if len(M)==0:
        ans = 0
    else:
        for i in range(1,len(P)+1):
            if C[i]>=m:
                ans = i
                break
        ans += len(M)
print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  VI t(210101,0);
  VI s(n),e(n),c(n);
  vector<PII> ch[k];
  rep(i,n){
    cin >> s[i] >> e[i] >> c[i];
    c[i]--;
    ch[c[i]].push_back(PII(s[i],e[i]));
  }

  rep(i,k){

    if(ch[k].size() == 0) continue;

    sort(all(ch[i]));
    rep(j,(int)ch[i].size() - 1){
      if(ch[i][j].second == ch[i][j+1].first){
        ch[i][j+1].first = ch[i][j].first;
        ch[i][j].first = -1;
      }
    }

    rep(j,ch[i].size()){
      if(ch[i][j].first == -1) continue;
      else {
        // cout << i << " " << ch[i][j].first << "," << ch[i][j].second << endl;
        t[2*ch[i][j].first - 1]++;
        t[2*ch[i][j].second + 1]--;
      }
    }
  }

  int cnt = 0;
  rep(i,210100){
    t[i+1] += t[i];
    cnt = max(t[i],cnt);
  }
  cout << cnt << endl;
  return 0;
}


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

const int N = 100010;
const int M = std::exp(std::log(1e10) / 3) + 10;
typedef std::pair <int, int> pii;
typedef long long ll;

int min[N];
std::vector <int> prime;

inline int sqrt(ll n){
	int x = std::sqrt(n) + 3;
	while (1ll * x * x > n){
		-- x;
	}
	return x;
}

int main(){
	for (int i = 2; i < N; ++ i){
		if (!min[i]){
			min[i] = i;
			prime.push_back(i);
		}
		for (int j = 0, sz = prime.size(); j < sz && prime[j] * i < N; ++ j){
			min[i * prime[j]] = prime[j];
			if (i % prime[j] == 0){
				break;
			}
		}
	}
	std::map <std::vector <pii>, int> Hash;
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; ++ i){
		ll x;
		scanf("%lld", &x);
		std::vector <int> fact;
		for (auto u : prime){
			if (u > M) break;
			while (x % u == 0){
				x /= u;
				fact.push_back(u);
			}
		}
		if (x != 1){
			int y = sqrt(x);
			if (1ll * y * y == x){
				fact.push_back(y);
				fact.push_back(y);
			}
			else if (x < N && min[x] == x){
				fact.push_back(x);
			}
			else{
				++ ans;
				continue;
			}
		}
		std::vector <pii> vec;
		for (int i = 0, pre = 0, sz = fact.size(); i <= sz; ++ i){
			if (i == sz || fact[i] != fact[i - 1]){
				int y = (i - pre) % 3;
				if (y) vec.push_back({fact[i - 1], y});
				pre = i;
				if (i == sz) break;
			}
		}
		++ Hash[vec];
	}
	auto u = Hash.begin();
	if (!(u -> first).size()){
		++ ans;
		Hash.erase(u);
	}
	while (Hash.size()){
		auto u = Hash.begin();
		std::vector <pii> tmp;
		for (auto v : u -> first){
			tmp.push_back({v.first, 3 - v.second});
		}
		int x = Hash.count(tmp) ? Hash[tmp] : 0;
		ans += std::max(u -> second, x);
		Hash.erase(u);
		Hash.erase(tmp);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define s second
#define pb(x) push_back(x)
#define f first
using namespace std;
int main(){
       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
        IOS;
        ll n ;
        cin >> n;
        map<string,ll> mp;
        char a;
        bool B=true;
        for(int i=0;i<n;i++)
        {

            if(i==0)
            {
                string ch;
                cin >> ch;
                a=ch[ch.size()-1];
                mp[ch]++;
            }
            else
            {
                string ch;
                cin >> ch;
                mp[ch]++;
                if(ch[0]==a && mp[ch]==1)
                    a=ch[ch.size()-1];
                else
                    B=false;
            }
        }
        if(B==false)
            cout <<"No";
        else
            cout << "Yes";
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);

  ll a,p;cin>>a>>p;

  ll ans = (a*3+p)/2;


  cout << ans << endl;

}

















//


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String [] args) {
        FastReader reader = new FastReader();

        int N = reader.nextInt();
        double [] value = new double [N];

        for (int i = 0; i < N; i++) {
            value[i] = reader.nextDouble();
        }

        double [][] dp = new double [N + 1][N + 1];

        for (int i = 0; i < dp.length; i++) {
            for (int j = 0; j <= i; j++) {
                if (i == 0) {
                    dp[i][j] = 1;
                    break;
                }
                dp[i][j] = (j == 0? 0 : dp[i - 1][j - 1]) * value[i - 1] + dp[i - 1][j] * (1 - value[i - 1]);

            }
        }
        double p = 0;
        for (int heads = dp[0].length - 1; heads >= 0 ; heads--) {
            int tails = N - heads;
            if (heads > tails)
                p += dp[dp.length - 1][heads];
        }

        System.out.println(p);
    }


    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 106740
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll h, w, m;
        cin >> h >> w >> m;
        if(h == 1 || w == 1){
            cout << m;
            return 0;
        }
        vector<ll> col(w + 1), row(h + 1);
        set<pair<ll,ll>> s;
        for(i = 0; i < m; i++){
            ll x, y;
            cin >> x >> y;
            row[x]++;
            col[y]++;
            s.insert({x, y});
        }
        
        
        vector<pair<ll,ll>> ca, ra;
        for(i = 0; i < h; i++){
            ra.pb({row[i + 1], i + 1});
        }
        for(i = 0; i < w ;i++){
            ca.pb({col[i + 1] ,i + 1});
        }
        sort(ra.rbegin(), ra.rend());
        sort(ca.rbegin(), ca.rend());
        vector<ll> r, c;
        for(auto u : ra){
            r.pb(u.ss);
        }
        for(auto u : ca){
            c.pb(u.ss);

        }
        ll ans = 0;
        ll csz = c.size();
        ll rsz = r.size();
        
        for(i = 0; i < rsz; i++){
            for(j = 0; j < 1; j++){
                ll val = row[r[i]] + col[c[j]];
                if(s.find({r[i], c[j]}) != s.end()){
                    val--;
                }
                ans = max(ans, val);
            }
        }
        for(i = 0; i < csz; i++){
            for(j = 0; j < 1; j++){
                ll val = row[r[j]] + col[c[i]];
                if(s.find({r[j], c[i]}) != s.end()){
                    val--;
                }
                ans = max(ans, val);
            }
        }
        cout << ans;
    }
    return 0;
}
/*
100 100 10
1 3
2 3
12 42
11 11
43 21
23 12
23 54
12 12
1 5
*/

Measured memory_bytes: 44940
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
using namespace std;
int a,b,k;
int main()
{
	cin>>a>>b>>k;
	for (int i=a;(i<a+k && i<=b);i++)
		cout<<i<<endl;
	int t=a+k-1;
	if (t>=b)
	{
		system("pause");
    	return 0;
	}
	else
	{
		if (b-k+1>t)
		{
			for (int j=b-k+1;j<=b;j++)
				cout<<j<<endl;
		}
		else
		{
			if (b-k+1<=t)
			{
				for (int i=t+1;i<=b;i++)
					cout<<i<<endl;
			}
		}
	}
	system("pause");
    return 0;
}

Measured memory_bytes: 504
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	S := make([]string, N)
	m := make(map[string]int)
	max := 0
	for i, _ := range S {
		fmt.Scan(&S[i])
		m[S[i]]++
		if max < m[S[i]] {
			max = m[S[i]]
		}
	}

	k := make([]string, 0)
	for key, _ := range m {
		k = append(k, key)
	}

	sort.Strings(k)

	for _, key := range k {
		if m[key] == max {
			fmt.Println(key)
		}
	}

}


Measured memory_bytes: 34304
N,K = map(int,input().split())
p = list(map(int,input().split()))

s = s_tmp = sum(p[0:K])
for i in range(N-K):
    s_tmp = s_tmp - p[i] + p[i+K]
    if s < s_tmp:
        s = s_tmp

print((s+K)/2)


Measured memory_bytes: 25060
K,S = map(int,input().split())
x = 0
for i in range(K+1):
    if S-i > 2*K:
        continue
    else:
        for l in range(K+1):
            if S-i-l > K or i+l > S:
                continue
            else:
                x += 1
print(x)

Measured memory_bytes: 2940
import java.util.*;

public class Main
{
    public static void main( String[] args )
    {
        Scanner sc = new Scanner(System.in);
        // int H = sc.nextInt();
        boolean flag = false;
        int N = sc.nextInt();
        for(int i = 0;i<N;i++){
            int A = sc.nextInt();
            if(A%2 == 0){
                if(A%3!=0 && A%5!=0){
                    flag = true;
                }
            }
        }
        if(flag){
            System.out.println("DENIED");
        }else{
            System.out.println("APPROVED");         
        }

    }
}

Measured memory_bytes: 23124
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n;
char data[605][605];
int dp[605][605];

int jahja(int x, int y)
{
  if (x == 2 * n - 1 || y == 2 * n - 1) return 1;
  int &ret = dp[x][y];
  if (ret >= 0) return ret;
  int jauh = 0;
  ret = jahja(x + 1, y + 1);
  FORN(i,1,ret + 1)
  {
    if (x + i >= 2 * n - 1 || y + i >= 2 * n - 1) break;
    if (data[x][y+i] != data[x+i][y]) break;
    jauh = i;
  }
  ret = min(ret + 1, jauh + 1);
  return ret;
}

int main()
{
  scanf("%d",&n);
  REP(i,n)
  {
    getchar();
    REP(j,n)
    {
      scanf("%c",&data[i][j]);
    }
  }
  REP(i,2*n) REP(j,2*n) data[i][j] = data[i%n][j%n];
  RESET(dp,-1);
  int risan = 0;
  REP(i,n) REP(j,n) if(jahja(i,j) >= n) ++risan;
  printf("%d\n",risan);
  return 0;
}











Measured memory_bytes: 2048
/*
CF ID: Ankit717
LANG: C++
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200005
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf push_front
#define nl cout << "\n";

const ll INF=1e18L+5;
 
struct Data{
	ll p;
	ll h;
};

void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pll &a,pll &b){
	if(a.first==b.first){
		return a.second>b.second;
	}else{
		return a.first<b.first;
	}
}

// vector<pll> adj[maxn];
// vector<ll> par;
// vector<bool> vis;

ll gcd(ll a,ll b){
    while(a!=0){
        ll temp=a;
        a = b % a;
        b = temp;
    }

    return b;
}

// bool prime[maxn],near[maxn];
// void sieve(){
// 	f(i,0,maxn+1){
// 		prime[i]=true;
// 	}
// 	prime[0]=falsrime[1]=false;
// 	for(ll i=2;i*i<=maxn;i++){
// 		if(prime[i]){
// 			for(j=i*i;j<=maxn;j+=i){
// 				prime[j]=false;
// 			}
// 		}
// 	}
// }

void solve(){
	ll n;
	cin >> n;
	ll a[n];
	f(i,0,n){
		cin >> a[i];
	}

	ll ans=0,m=a[0];
	f(i,1,n){
		if(m>a[i]){
			ans+=m-a[i];
		}
		m=max(m,a[i]);
	}

	cout << ans;nl;
}	

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    
	// ll t;
	// cin >> t;
	// f(i,0,t){
		solve();
	//}
}


Measured memory_bytes: 5176
#include <iostream>



using namespace std;
int main(int argc, char *args[])
{
	int n;
	int m;
	int k;
	cin>> n >> m >> k;
	if(n+m>=k)
	{
		cout<<"Yes" <<endl;
	}
else
	{
		cout<<"No"<<endl;
	}
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
					
public class Program
{
	public static int comp = 0;
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] ls = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);
		mergeSort(ls, 0, n);
		Console.WriteLine(string.Join(" ", ls));
		Console.WriteLine(comp);
	}
	public static void mergeSort(int[] ls, int left, int right){
		if (left + 1 < right){
			int mid = (left + right)/2;
			mergeSort(ls, left, mid);
			mergeSort(ls, mid, right);
			merge(ls, left, mid, right);
		}
	} 
	public static void merge(int[] ls, int left, int mid, int right){
		int n1 = mid - left, n2 = right - mid;
		int[] L = new int[n1 + 1], R = new int[n2 + 1];
		for(int i = 0; i < n1; i++) L[i] = ls[left + i];
		for(int i = 0; i < n2; i++) R[i] = ls[mid + i];
		L[n1] = int.MaxValue; R[n2] = int.MaxValue;
		for(int k = left, i = 0, j = 0; k < right; k++) 
			if (L[i] < R[j]){
				ls[k] = L[i++];
				comp++;
			}
			else{
				ls[k] = R[j++];
				comp++;
			}
	}
}




Measured memory_bytes: 84440
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

map<int, string> m;

int strtoi(string str){
	int ret = 0;
	int k=str.find('m');
	if(k!=-1){
		if(k==0||(k!=0&&isdigit(str[k-1])==false))ret+=1000;
		else ret+=(str[k-1]-'0')*1000;
	}
	k=str.find('c');
	if(k!=-1){
		if(k==0||(k!=0&&isdigit(str[k-1])==false))ret+=100;
		else ret+=(str[k-1]-'0')*100;
	}
	k=str.find('x');
	if(k!=-1){
		if(k==0||(k!=0&&isdigit(str[k-1])==false))ret+=10;
		else ret+=(str[k-1]-'0')*10;
	}
	k=str.find('i');
	if(k!=-1){
		if(k==0||(k!=0&&isdigit(str[k-1])==false))ret+=1;
		else ret+=(str[k-1]-'0')*1;
	}
	return ret;
}

string itos(int t){
	string ret;
	int p=1000;
	while(p>0){
		if(t/p==1)ret += m[p];
		else if(t/p!=0){
			ret+=t/p+'0';
			ret+=m[p];
		}
		t%=p;
		p/=10;
	}
	return ret;
}

int main(){
	m[1] = "i";
	m[10] = "x";
	m[100] = "c";
	m[1000] = "m";
	int n;
	cin >> n;
	REP(i,n){
		string str1,str2;
		cin>>str1>>str2;
		cout<<itos(strtoi(str1)+strtoi(str2))<<endl;
	}
}

Measured memory_bytes: 1208
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

template <typename T>
class BinaryIndexedTree{
public:
	BinaryIndexedTree(int size) : size_(size){
		data_.resize(size + 1);
	}
	void Add(int index, T value){
		if (index < 0 || index >= size_) return;
		index++;
		while (index <= size_){
			data_[index] += value;
			index += index & -index;
		}
	}
	T Sum(int index){
		if(index < 0 || index >= size_) return 0;
		index++;
		T ret = 0;
		while(index > 0){
			ret += data_[index];
			index -= index & -index;
		}
		return ret;
	}
private:
	vector<T> data_;
	int size_;
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<BinaryIndexedTree<int>> bit(27, BinaryIndexedTree<int>(N));
	REP(i, N){
		int c = S[i];
		bit[c - 'a'].Add(i, 1);
	}

	int Q;
	cin >> Q;
	REP(_, Q){
		int type;
		cin >> type;
		if(type == 1){
			int i;
			char c;
			cin >> i >> c;
			i--;
			bit[S[i] - 'a'].Add(i, -1);
			S[i] = c;
			bit[S[i] - 'a'].Add(i, 1);
		}
		else{
			int l, r;
			cin >> l >> r;
			l -= 2; r--;
			int ret = 0;
			REP(i, 27){
				ret += 0 < (bit[i].Sum(r) - bit[i].Sum(l));
			}
			cout << ret << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 55800
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < 6; i++){
        if(S.at(i) == '1'){
            count++;
        }
        else{
            continue;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, m, x = i_map()
    num_list = i_row_list(n)

    money = INF

    for bit in list(product([0,1], repeat=n)):
        tmp_money = 0
        alg_list = [0] * m
        for i in range(n):
            if bit[i] == 1:
                tmp_money += num_list[i][0]
                for j in range(m):
                    alg_list[j] += num_list[i][j+1]
        for i in range(m):
            if alg_list[i] < x:
                tmp_money = INF
                break
        money = min(money, tmp_money)

    print(money if money != INF else -1)

if __name__ == '__main__':
    main()


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

int main() {
	int n, m;
	cin >> n >> m;
	int s[m];
	char c[m];
	for (int i = 0; i < m; i++) {
		cin >> s[i] >>c[i];
	}
	string ans = "";
	for (int i = 0; i < n; i++) {
		ans += "0";
	}
	if (n != 1) ans.at(0) = '1';
	for (int i = 0; i < m; i++) {
		ans.at(s[i]-1) = c[i];
	}
	for (int i = 0; i < m; i++) {
		if(ans.at(s[i]-1) != c[i]) {
			ans = "-1";
			cout << ans << endl;
			return 0;
		}
	}
	if (n != 1 && ans.at(0) == '0') {
		ans.at(0) = '1';
		ans = "-1";
		cout << ans << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int
main()
{
    int n,k;
    vector<int> p;

    cin >> n;
    cin >> k;

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

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

    int ans = 0;;
    for(int i=0;i<k;i++){
        ans += p[i];
    }

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


Measured memory_bytes: 3556
sss = input()
while not sss == '0 0':
	ss = sss.split(' ')
	H = int(ss[0])
	W = int(ss[1])
	for i in range(1, H+1):
		sh = ''
		for j in range(1, W+1):
			if i % 2 == 1:
				if j % 2 == 1: sh += '#'
				else: sh += '.'
			else:
				if j % 2 == 1: sh += '.'
				else: sh += '#'
		print(sh)
	print('')
	sss = input()


Measured memory_bytes: 7632
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt(),c = sc.nextInt();
		
            	if(a+b >= c){
            		System.out.println("Yes");
            	} else {
           			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<set>
using namespace std;
int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0)break;
    set<int> st;
    int a[100][100];
    int b[101];
    for(int i=0;i<n;i++){
      cin >> b[i];
      for(int j=0;j<b[i];j++){
	cin >> a[i][j];
      }
    }
    cin >> b[100];
    int S;
    for(int i=0;i<b[100];i++){
      cin >> S;
      st.insert(S);
    }
    int s=0;
    for(int i=0;i<n;i++){
      int c=0;
      for(int j=0;j<b[i];j++){
	c+=st.count(a[i][j]);
      }
      if(c==b[100]){
	if(s==0)s=i+1;
	else{
	  s=-1;
	  i=n;
	}
      }
    }
    if(s<=0)cout << -1 << endl;
    else cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

#define rep(i,b,e) for(auto i=b;i<=e;i++)

const long long P = 1e9+7;

int main(){
	int n,L,R;
	string s;
	cin>>n>>s;
	long long dp[n+1][n+1];
	memset(dp,0,sizeof(dp));

	dp[1][1]=1;

	rep(i,2,n){

		rep(k,2,i){
			dp[i-1][k] = (dp[i-1][k]+dp[i-1][k-1])%P;
		}

		rep(j,1,i){
			long long rangeSum =0;
			if(s[i-2]=='<'){
				L=1,R=j-1;	
			}
			else{
				L=j,R=i-1;
			}

			if(L<=R)
				dp[i][j] = (dp[i][j]+ dp[i-1][R]-dp[i-1][L-1]+P)%P;
		}
	}

	long long ans = 0;
	rep(i,1,n)
		ans = (ans+dp[n][i])%P;
	cout<<ans<<endl;
}


Measured memory_bytes: 74004
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,M,i;
    cin>>N>>M;
    if(M==1){
        cout<<0<<endl;
        return 0;
    }
    long long X[M],x[M-1];
    for(i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X,X+M);
    for(i=0;i<M-1;i++){
        x[i]=X[i+1]-X[i];
    }
    sort(x,x+(M-1));
    long long ans=0;
    for(i=0;i<M-N;i++){
        ans+=x[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0)
    {
        cout << 1 << endl;
    }
    else if (b == 0)
    {
        cout << 2 << endl;
    }
    else if (c == 0)
    {
        cout << 3 << endl;
    }
    else if (d == 0)
    {
        cout << 4 << endl;
    }
    else
    {
        cout << 5 << endl;
    }
}

Measured memory_bytes: 3200
#!/usr/bin/env python
# coding: utf-8

# In[5]:


N,A,B = map(int, input().split())


# In[6]:


ans = 0
for i in range(1,N+1):
    tmp = list(str(i))
    if sum(list(map(int, tmp))) >= A and sum(list(map(int, tmp))) <= B:
        ans += i
print(ans)


# In[ ]:






Measured memory_bytes: 3060
n=int(input())
a=input().split()
avg=0
max=-1000000
min=1000000
for i in range(n):
    a[i]=int(a[i])
    if a[i]>max:
        max=a[i]
    if a[i]<min:
        min=a[i]
    avg+=a[i]
print(str(min)+" "+str(max)+" "+str(avg))


Measured memory_bytes: 6328
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int a[300000],s[300000];

int main()
{
	int n=0,k=0;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);}
	
	for(int j=1;j<=k;j++)
	{
		memset(s,0,sizeof(s));
		for(int i=1;i<=n;i++)
		{
			int l=max(i-a[i],1),r=min(n,i+a[i]);
			s[l]+=1,s[r+1]-=1;
		}
		for(int i=1;i<=n;i++)a[i]=a[i-1]+s[i];
		bool fl=1;for(int i=1;i<=n;i++)if(a[i]!=n)fl=0;
		if(fl)break;
	}
	for(int i=1;i<=n;i++)printf("%d ",a[i]);return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
lli ans = 0;

int main(){
  cin >> n;
  for(lli i = 9;i <= n;i++){
    lli s = 0;
    for(lli x = 1;x <= i;x++){
      if(i%x == 0) s++;
    }
    if(s == 8 && i%2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int m=100000,i,w;
    scanf("%d",&w);
    for(i=0; i<w; i++){
        m*=21;
        m/=20;
        if((m%1000)!=0){
            m/=1000;
            m*=1000;
            m+=1000;
        }
    }
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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




int main() {
	vi(v,3);
	rep(i, 3)
		cin >> v[i];
	SORT(v);
	int result = v[2] - v[1];
	if ((v[2] - v[0] - result) % 2 == 1)
		result++;
	result += (v[1] - v[0] + 1) / 2;
	cout << result << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int MAX_N=2e5+10;
int bit[MAX_N+1],n;

int sum(int i){
  int s=0;
  while(i>0){
    s+= bit[i];
    i-= i& -i;
  }
  return s;
}

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


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

  int z = 26;
  vector<int> cnt(z,0);
  n = s.size();
  rep(i,n){
    cnt[s[i]-'a']++;
  }

  int odd =-1;
  rep(i,26){
    if(cnt[i]%2==1){
      if(odd == -1 && n%2==1) {
        odd = i;
      }
      else{
        cout << -1 << endl;
        return 0;
      }
    }
  }
  vector<int> pos;
  vector<int> num;
  deque<int> num_non_used[26];
  vector<int> used(z,0);
  rep(i,s.size()){
    int cmoji = s[i] -'a';
    if((cmoji == odd) && (used[cmoji]*2+1 == cnt[cmoji]) ){
      ++used[cmoji];
      num_non_used[cmoji].pb(i);
    }
    else{
      if(++used[cmoji] <= cnt[cmoji]/2){
        pos.pb(cmoji);
        num.pb(i);
      }
      else{
        num_non_used[cmoji].pb(i);
      }
    }
  }
  if(odd>=0) pos.pb(odd);
  vector<int> fin(n);
  rep(i,n){
    if(i<n/2){
      fin[i] = pos[i];
    }
    else{
      fin[i] = pos[pos.size()-1-(i - n/2)];
      num.pb(num_non_used[fin[i]].front());
      num_non_used[fin[i]].pop_front();
    }
  }



  // rep(i,fin.size()) cout << ((char) ('a' + fin[i]));
  // cout << endl;
  // rep(i,num.size()) cout << num[i];
  // cout << endl;

  ll ans =0;
  rep(j,n){
    // cout <<"j - sum " << j << " " << sum(num[j]+1) << endl;
    ans+= j- sum(num[j]+1);
    add(num[j]+1,1);
    // cout << ans << endl;
  }
    
  cout << ans << endl;  

  
  return 0;
    

}


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

int main()
{
    
   
   
    int n;
    cin>>n;
    int dp[n+1]={0};
    int s=0;
    for(int i=1;i<=n;i++)
    {
        int s=i*i;
        if(s>n)
          break;
        for(int j=1;j<=n;j++)
        {
            int s1=j*j;
            if(s+s1>n)
                break;
            for(int k=1;k<=n;k++)
            {
                  //cout<<i<<" "<<j<<" "<<k<<endl;
                  int s3=k*k;
                  int s4=i*j+j*k+i*k;
                  if(s+s1+s3+s4>n)
                    break;
                  else
                     dp[s+s1+s3+s4]+=1;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<dp[i]<<endl;
    }
    

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<long long> vl;

signed main() {
  string n;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i,int(n.size())) {
    if(n[i] == '7') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int h,w; 
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    rep(i,w+2) cout << '#';
    cout << endl;
    rep(i,h) {
        cout << '#' << a[i] << '#' << endl;
    }
    rep(i,w+2) cout << '#';
    cout << endl;
     
    return 0;   
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
    static boolean visited[];
    static int n, m;
    static int path[][];
    static int ans = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        path = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            path[a][b] = 1;
            path[b][a] = 1;
        }
        visited = new boolean[n];
        visited[0] = true;
        DPS(0);

        System.out.println(ans);

        sc.close();
    }

    static void DPS(int pos) {
        if (complete()) {
            ans++;
            return;
        }

        for (int i = 0; i < n; i++) {
            if (!visited[i] && path[pos][i] == 1) {
                visited[i] = true;
                DPS(i);
                visited[i] = false;
            }
        }
    }

    static boolean complete() {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (visited[i])
                cnt++;
        }
        return n == cnt;
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >>n >>k;
  
  int x[n];
  for (int i = 0; i < n; i++)
    cin >> x[i];
  
  int ans = 0;
  for (int i = 0; i < n; i++)
    ans += min(x[i], k-x[i]);
  ans *= 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int t;
        if (a > b) {
            t = a;
            a = b;
            b = t;
        }
        if (a > c) {
            t = a;
            a = c;
            c = t;
        }
        if (b > c) {
            t = b;
            b = c;
            c = t;
        }
        
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 26340
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    a, b = LS()
    target = "".join([a, b])
    target = int(target)

    n = 1
    flag = True
    while(n <= 100100):
        if target == n ** 2:
            print("Yes")
            flag = False
            break

        n += 1

    if flag:
        print("No")



solve()

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

int main(){
  int A,B;cin>>A>>B;
  int X;
  if(B<=9) X=10*A+B;
  else if(B==100) X=1000*A+B;
  else X=100*A+B;
  bool yes=false;
  for(int i=1;i<=320;i++){
    if(i*i==X) yes=true;
  }
  cout<<(yes?"Yes":"No")<<endl;
}



Measured memory_bytes: 3576
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 2e18;

void solve() {
	int N, W;
	cin >> N >> W;
	vector<long long> w(N + 1);
	vector<long long> v(N + 1); 
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<long long> > dp(N + 1, vector<long long>(W + 1, -INF));
	// long long dp[N + 1][W + 1];
	// for (int i = 0; i <= N; i++) {
	// 	for (int j = 0; j <= W; j++) {
	// 		dp[i][j] = -INF;
	// 	}
	// }
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j - w[i] < 0) {
				dp[i][j] = dp[i - 1][j];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j <= W; j++) {
		ans = max(ans, dp[N][j]);
	} 
	cout << ans << endl;
}

void solveOptimized() {
	int N, W;
	cin >> N >> W;
	vector<long long> w(N + 1);
	vector<long long> v(N + 1); 
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	vector<long long> dp(W + 1, -INF);
	dp[0] = 0;
	for (int i = 1; i <= N; i++) {
		vector<long long> dp_new(W + 1, -INF);
		for (int j = 0; j <= W; j++) {
			if (j - w[i] < 0) {
				dp_new[j] = dp[j];
			} else {
				dp_new[j] = max(dp[j], dp[j - w[i]] + v[i]);
			}
		}
		for (int j = 0; j <= W; j++) {
			dp[j] = dp_new[j];
		}
	}
	long long ans = 0;
	for (int j = 0; j <= W; j++) {
		ans = max(ans, dp[j]);
	} 
	cout << ans << endl;
}

int main() {
	solveOptimized();
	return 0;
}

Measured memory_bytes: 1804
import Control.Monad
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Char (isSpace)

main = do
  n <- readLn :: IO Int
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine 
  let bucket = makeBuckets as n
  let (a,b) = solve bucket 1 (0,0)
  putStrLn $ show a ++ " " ++ show b

solve :: VU.Vector Int -> Int -> (Int,Int) -> (Int,Int)
solve vec n (a,b) 
  | n == 9 = if a + b == 0 then (1,b+s') else (a,b+s')
  | otherwise = solve (VU.drop 400 vec) (n+1) (a+k,b+k)
    where 
      s = VU.sum $ VU.take 400 vec
      s' = VU.sum vec
      k = if s > 0 then 1 else 0

makeBuckets :: VU.Vector Int -> Int -> VU.Vector Int
makeBuckets xs n =
  VU.create $ do
    buckets <- VUM.replicate 4801 (0::Int)
    forM_ [0..n-1] $ \i -> do
      let rate = xs VU.! i
      v <- VUM.read buckets rate
      VUM.write buckets rate (v+1)
    return buckets

Measured memory_bytes: 508