akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

const int N = 112345;
ll v[N];

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

	int n; cin >> n;

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

	if (v[n-1] != 2) {
		cout << -1 << endl;
		return 0;
	}

	ll cur = 2, car = 3;
	for (int i = n-2; i >= 0; i--) {
		if (cur%v[i]) {
			cur += v[i]-cur%v[i];
		}
		if (car%v[i]) {
			car += v[i]-car%v[i];
			car--;
		} else {
			car += v[i]-1;
		}
	}

	ll ans = cur, ans2 = car;

	for (int i = 0; i < n; i++) {
		cur -= cur%v[i];
		car -= car%v[i];
	}

	if (cur == 2) {
		assert(car == 2);
		cout << ans << " " << ans2 << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}

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

char s[SIZE][SIZE];
int t[SIZE][SIZE];
typedef pair<int, int> P;
int di[] = {0, 0, -1, 1};
int dj[] = {-1, 1, 0, 0};

int main(){
  int h, w;
  cin >> h >> w;
  long long result = 0;
  queue<P> q;
  
  
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++)
      scanf(" %c", &s[i][j]);
  
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++){
      int bl = 0, wh = 0;
      if (t[i][j]==0){
        q.push(P(i, j));
        t[i][j] = 1;
      }
      while( !q.empty() ){
        P p = q.front();
        q.pop();
        if(s[p.first][p.second] == '#')bl++; else wh++;
        for(int a=0; a<4; a++){
          int k = p.first + di[a];
          int l = p.second+ dj[a];
          if(0<=k && 0<=l && k<h && l<w){
            if(
              s[p.first][p.second] != s[k][l]
              && t[k][l] == 0
            ){
              q.push(P(k,l));
              t[k][l] = 1;
            }
          }
        }
      }
      result += (long long)bl * (long long)wh;
    }
  cout << result << endl;
}

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

void swap(int a[],int i,int j){
	int t=a[i];
	a[i]=a[j];
	a[j]=t;
}

void sort(int a[],int size){
	bool flag=true;
	while(flag){
		flag=false;
		for(int i=0;i<size-1;i++){
			if(a[i]<a[i+1]){
				swap(a,i,i+1);
				flag=true;
			}
		}
	}
}

int main(){
	int N;
	cin >> N;
	int d[N];
	for(int i=0;i<N;i++){
		cin >> d[i];
	}
	
	sort(d,N);
	
	int ans=1;
	for(int i=0;i<N-1;i++){
		if(d[i]!=d[i+1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
X = int(input())


def calculate(x):
    if x == 2:
        return 2

    while not condition(x):
        x = x + 1

    return x

def condition(x):
    result = True
    for i in range(2,x):
        if x % i == 0:
            result = False
            break

    return result


result = calculate(X)

print(result)


Measured memory_bytes: 2940
a = []
N = int(input())
a = list(map(int, input().split()))
ave = c = 0

for i in range(N):
  ave += a[i]
ave_l = int(ave / N)
ave_u = ave_l + 1

s_l = s_u = 0
for i in range(N):
  s_l += (a[i] - ave_l)**2
  s_u += (a[i] - ave_u)**2

ans = min(s_l, s_u)
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll dp[K+1][N+1];
    fill(dp[0], dp[K+1], 0);
    rep(i, K){
        deque<int> que;
        rep(j, N){
            if(!que.empty() && que.front() <= j-M) que.pop_front();
            while(!que.empty() && dp[i][que.back()] <= dp[i][j]) que.pop_back();
            que.push_back(j);
            if(j >= i) dp[i+1][j+1] = dp[i][que.front()]+A[j]*(i+1);
        }
    }
    ll ans = 0;
    rep(i, N+1) chmax(ans, dp[K][i]);
    cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

vector<pair<ll, int> > primeFactorize(ll n) {
  vector<pair<ll, int> > res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    res.push_back(make_pair(i, 0));
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    auto v = primeFactorize(n);
    int res = 0;
    rep (i, v.size()) {
        for (int j = 1; ; ++j) {
            res++;
            int cnt = j * (j + 1) / 2;
            if (cnt >= v[i].second) {
                if (cnt > v[i].second) res--;
                break;
            }
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3652
#include <stdio.h>
#define N 100000

int partition(int *,int,int);

int main(){
  
  int i,j,n,A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  int  a= partition(A,0,n-1);
  
  for(i=0;i<n;i++){
    if(i>=1)printf(" ");
    if(i==a)printf("[");
    printf("%d",A[i]);
    if(i==a)printf("]");
  }printf("\n");
  return 0;
}

int partition(int A[],int p,int r){
  int tmp,j;
  int  x=A[r];
  int i = p-1; //partition ( A, p, r )　配列 A[ p..r ] 
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      tmp =A[j];
     A[j]=A[i];
     A[i]=tmp;
     }
 } tmp =A[i+1];
     A[i+1]=A[r];
     A[r]=tmp;
     return i+1;
}





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


int main(){
  ll N;cin>>N;
  ll tmp1 = 0,tmp2 = 1;
  while(1){
    if(tmp1 + pow(26,tmp2) >= N) break;
    tmp1 = tmp1 + pow(26,tmp2);
    tmp2++;
  }
  ll t = N - tmp1 - 1;
  string s = "";
  while(N){
    ll cnt = N%26;
    if(cnt==0)cnt+=26;
    cnt--;
    s += 'a'+cnt;
    N = (N-cnt)/26;
  }
  reverse(all(s));
  cout<<s<<endl;
}

Measured memory_bytes: 4040
def counting_sort(source)
  source = [nil] + source
  target = [nil]
  counts = []

  1.upto(source.size - 1) do |i|
    value = source[i]
    counts[value] = (counts[value] || 0) + 1
  end

  counts.size.times do |i|
    counts[i] ||= 0
  end

  1.upto(counts.size - 1) do |i|
    counts[i] = counts[i] + counts[i - 1]
  end

  (source.size - 1).downto(1) do |i|
    value = source[i]
    pos = counts[value]
    target[pos] = value
    counts[value] -= 1
  end

  target[1..-1]
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  source = gets.split.map(&:to_i)

  puts counting_sort(source).join(' ')
end

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

int main() {

	string s; cin >> s;
	ll k; cin >> k;
	bool allSame = true;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] != s[0]) allSame = false;
	}
	ll ans = 0;
	if (allSame) {
		ans = k * s.size() / 2;
		cout << ans << endl;
		return 0;
	}
	ll cnt = 1;
	for (ll i = 1; i < s.size(); i++) {			
		if (s[i] == s[i - 1]) {
			cnt++;
		}
		else {
			ans += cnt / 2;
			cnt = 1;
		}			
	}
	ans += cnt / 2;
	ans *= k;
	if (s[0] == s[s.size() - 1]) {
		ll leftCnt = 0;
		ll rightCnt = 0;
		ll i = 1;
		while (true) {
			if (s[i] == s[0]) leftCnt++;
			else break;
				i++;
		}
		i = 1;
		while (true) {
			if (s[s.size() - 1 - i] == s[s.size() - 1]) rightCnt++;
			else break;
			i++;
		}
		if (0 < leftCnt) leftCnt++;
		if (0 < rightCnt) rightCnt++;
		ans -= (leftCnt / 2 + rightCnt / 2 - (leftCnt + rightCnt) / 2) * (k - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3544
def resolve():
    from collections import defaultdict
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[input()] += 1
    M = int(input())
    for _ in range(M):
        d[input()] -= 1
    res = 0
    for _,v in d.items():
        if v > res:
            res = v
    print(res)
resolve()

Measured memory_bytes: 38256
h, w, k = map(int, input().split())
pic = [list(input()) for _ in range(h)]

ptns = []
for i in range(2**(h+w)):
    tmp = []
    for j in range(h+w):
        if i>>j & 1:
            tmp.append(1)
        else:
            tmp.append(0)
    ptns.append(tmp)

import copy
from itertools import chain

ans = 0
for ptn in ptns:
    tmp = copy.deepcopy(pic)
    for x in range(h):
        for y in range(w):
            if ptn[y] == 1:
                tmp[x][y] = 0
        if ptn[w+x] == 1:
            tmp[x] = [0]
    tmp = list(chain.from_iterable(tmp))

    if tmp.count('#') == k:
        ans += 1
print(ans)


Measured memory_bytes: 9976
#include <stdio.h>

void judge(double);

int main(void){
  double weight;

  while( scanf("%lf" ,&weight) != EOF ) judge(weight);
  
  return 0;
}

void judge(double weight){

  if( weight <= 48 ) printf("light fly\n");
  else if( 48 < weight && weight <= 51 ) printf("fly\n");
  else if( 51 < weight && weight <= 54 ) printf("bantam\n");
  else if( 54 < weight && weight <= 57 ) printf("feather\n");
  else if( 57 < weight && weight <= 60 ) printf("light\n");
  else if( 60 < weight && weight <= 64 ) printf("light welter\n");
  else if( 64 < weight && weight <= 69 ) printf("welter\n");
  else if( 69 < weight && weight <= 75 ) printf("light middle\n");
  else if( 75 < weight && weight <= 81 ) printf("middle\n");
  else if( 81 < weight && weight <= 91 ) printf("light heavy\n");
  else printf("heavy\n");

}

Measured memory_bytes: 608
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		sc.close();

		ArrayList<Integer> listA = new ArrayList<>();
		ArrayList<Integer> listB = new ArrayList<>();
		listA.add(1);
		listA.add(3);
		listA.add(5);
		listA.add(7);
		listA.add(8);
		listA.add(10);
		listA.add(12);

		listB.add(4);
		listB.add(6);
		listB.add(9);
		listB.add(11);

		if(listA.contains(x) && listA.contains(y)) {
			System.out.println("Yes");
		}else if(listB.contains(x) && listB.contains(y)) {
			System.out.println("Yes");
		}else if(x == 2 && y == 2) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

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

int main() {
	int a,b;char c;
	while(cin>>a>>c>>b,c!='?'){
		switch(c){
			case '+':cout<<a+b<<endl;break;
			case '-':cout<<a-b<<endl;break;
			case '*':cout<<a*b<<endl;break;
			case '/':cout<<a/b<<endl;break;
		}
	}
}

Measured memory_bytes: 3080
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<ll, ll>;

struct Item {
  int v;
  ll w, m;
};

pair<ll, bool> upper_bound(const vector<P>& ps, int i, ll W) {
  ll res = 0;
  bool integer = true;
  for (; i < ps.size() && W > 0; i++) {
    if (ps[i].snd > W) {
      res += __int128(ps[i].fst) * W / ps[i].snd;
      integer = false;
    } else {
      res += ps[i].fst;
    }
    W -= ps[i].snd;
  }
  return make_pair(res, integer);
}

void dfs(const vector<P>& ps, ll& best, int i, ll V, ll W) {
  if (W < 0) return;
  if (i >= ps.size()) {
    if (V > best) best = V;
    return;
  }
  auto ub = upper_bound(ps, i, W);
  if (V + ub.fst <= best) return;
  if (ub.snd) {
    best = V + ub.fst;
    return;
  }
  dfs(ps, best, i + 1, V + ps[i].fst, W - ps[i].snd);
  dfs(ps, best, i + 1, V, W);
}

ll solveKnapsackBB(ll W, const vector<Item>& items) {
  vector<P> ps;
  for (auto& item : items) {
    ll num = item.m;
    for (ll k = 1; num > 0; k <<= 1) {
      ll mul = min(num, k);
      if (mul * item.w > W) break;
      ps.emplace_back(mul * item.v, mul * item.w);
      num -= mul;
    }
  }
  sort(ps.begin(), ps.end(), [&](const P& a, const P& b) {
    auto x = __int128(a.fst) * b.snd;
    auto y = __int128(b.fst) * a.snd;
    if (x != y) return x > y;
    return a.fst > b.fst;
  });
  ll best = 0;
  dfs(ps, best, 0, 0, W);
  return best;
}

int main() {
  int N;
  ll X, D;
  while (cin >> N >> X >> D) {
    vector<ll> m(N);
    cin >> m[0];
    vec<int, 2> G(N);
    for (int i = 1; i < N; i++) {
      int p;
      cin >> m[i] >> p;
      --p;
      G[p].push_back(i);
    }
    vector<int> sz(N);
    vector<ll> msum(N);
    function<void(int)> dfs = [&](int v) {
      sz[v] = 1;
      msum[v] = m[v];
      for (int u : G[v]) {
        dfs(u);
        sz[v] += sz[u];
        msum[v] += msum[u];
      }
    };
    dfs(0);
    vector<Item> items;
    for (int i = 0; i < N; i++) {
      ll lim = D;
      if (i == 0) lim = X / msum[0];
      items.push_back({sz[i], msum[i], lim});
    }
    cout << solveKnapsackBB(X, items) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	int n;
	cin>>n;
	ll m=0,a=0,r=0,c=0,h=0;
	rep(i,n){
		string s;
		cin>>s;
		if(s[0]=='M') m++;
		if(s[0]=='A') a++;
		if(s[0]=='R') r++;
		if(s[0]=='C') c++;
		if(s[0]=='H') h++;
	}
	ll ans=0;
	ans+=m*a*r;
	ans+=m*a*c;
	ans+=m*a*h;
	ans+=m*r*c;
	ans+=m*r*h;
	ans+=m*c*h;
	ans+=a*r*c;
	ans+=a*r*h;
	ans+=a*c*h;
	ans+=r*c*h;
	cout<<ans<<endl;
}





Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (M, D) = listOfInt()
    var ans = 0
    for (d10 in 2..9) {
        for (d1 in 2..9) {
            if (d10 * 10 + d1 <= D && d10 * d1 <= M) {
                ans++
            }
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37640
#include<bits/stdc++.h> 
typedef long long int ll;
#define pb push_back
#define MP make_pair

using namespace std;
int ans=0;
void dfs(int vi[] , vector<int> a[] , int x,int & w)
{
    if(vi[x]==0)
    {
        w=w+1;
    }
    vi[x]=1;
   
    if(w>ans)
    {
        ans=w;
    }
    for(int c:a[x])
    {
        if(vi[c]==0)
        {
            dfs(vi,a,c,w);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,e,v,u,i;
    cin>>n>>e;
    vector<int> a[n+1];
    for(i=0;i<e;i++)
    {
        cin>>u>>v;
        a[u].pb(v);
        a[v].pb(u);
    }
    
    int vi[n+1];
    for(i=0;i<n+1;i++)
    {
        vi[i]=0;
    }
    int y=1;
    int qq=0;
    dfs(vi,a,y,qq);
    int w=0;
    int su=0;
    /* for(i=0;i<n+1;i++)
    {
        if(vi[i]==1)
        {
            w++;
        }
    }
    su=su+w;
    ans=max(ans,w);*/
    
    int c=1;
    for(int i=1;i<n+1;i++)
    {
        if(vi[i]==0)
        {
            qq=0;
            dfs(vi,a,i,qq);
            c++;
        }
      /*  w=0;
            for(i=0;i<n+1;i++)
    {
        if(vi[i]==1)
        {
            w++;
        }
    }
    w=w-su;
    su=su+w;
     ans=max(ans,w);*/
    }
    //cout<<c<<" ";
    cout<<ans;

    
     return 0;
}


Measured memory_bytes: 24696
#include<iostream>
using namespace std;
int main()
{
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	if (c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 > 999)
	{
		cout << "1" << endl;
	}
	else 
	{
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
bool b[1000][1000][1000];
int main(){
  int n;
  cin >>n;
  int count=0;
  for(int i=0;i<n;i++){
    int p[3];
    for(int j=0;j<3;j++){
      cin >>p[j];
    }
    sort(p,p+3);
    if(b[p[0]][p[1]][p[2]]){
      count++;
    }else{
      b[p[0]][p[1]][p[2]]=true;
    }
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 7120
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		String s = sc.next();
		String t = sc.next();

		// 計算
		int result = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == t.charAt(i)) result++;
        }
        
		// 出力
		System.out.println(result);
	}

}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if (a>b){
        cout<<"a > b"<<endl;
    }
    else if (a<b){
        cout<<"a < b"<<endl;
    }
    else if (a==b){
        cout<<"a == b"<<endl;
    }
}



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

int main(void) {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
  	if (t <= k / 2) ans += t * 2;
    else ans += (k - t) * 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define piii pair<pii, int>
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R){int val=rng()%R;assert(val >= 0);return val;}

const long double PI = atan(1.0) * 4;
const int64_t INF64 = 3e18;
const int32_t INF32 = 2e9 + 7;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;


//-------------------DEBUGGING-------------------------
void my_debugger(string s,int LINE_NUM){cerr<<endl;}
template<typename start,typename... end>
void my_debugger(string s,int LINE_NUM,start x,end... y) 
{
    if(s.back()!=',') {s+=',';cerr<<"LINE("<<LINE_NUM<<"): ";}
    int i=s.find(',');
    cerr<<s.substr(0,i)<<" = "<<x;
    s=s.substr(i+1);
    if(!s.empty()) cerr<<", ";
    my_debugger(s,LINE_NUM,y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__,__LINE__,__VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------


int32_t main()
{
      getFaster;
      //files_init();
      int tests = 1;
      //cin >> tests;
      rep(ii, 0, tests)
      {
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            int ans=b*d;
            ans=max(ans,a*c);
            ans=max(ans,b*d);
            ans=max(ans,a*d);
            ans=max(ans,b*c);
            cout<<ans<<endl;
            
      }
      return 0;
}


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

int main() {
	int N, M, a, b, c = 0;
	cin >> N >> M;
	vector<int> d(N);
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		d[a - 1]++;
		d[b - 1]--;
	}
	bool ans = true;
	for (int& i : d) {
		c += i;
		if (c % 2) {
			ans = false;
			break;
		}
	}
	if (ans) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 640
program eee
implicit none
 
integer(8) :: n, w, i, j, k
integer(8),allocatable,dimension(:) :: ww, vv
integer(8),allocatable,dimension(:,:) :: dp
! 初期値の設定
read*, n, w
allocate(ww(n),vv(n))
do i=1, n
	read*, ww(i), vv(i)
end do
k=sum(vv)
allocate(dp(0:n,0:k))
dp=w*n+1
dp(0,0)=0
! end 初期値の設定
 
do i=1,n
	do j=0,k
		if(j>=vv(i)) then					!追加可能パターン
        	dp(i,j)=dp(i-1,j-vv(i))+ww(i)	!i-1の場合の、価値j-v(i)から参照
        end if
        dp(i,j)=min(dp(i,j),dp(i-1,j))		!追加したものとしていないものの比較を行う
    end do
end do
 
do j=k,0,-1
    if(dp(n,j)<=w) then
    	write(*,'(i0)') j
        return
    end if
end do
 
end program


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int i,i0,i1,n,m,ans,dp[100005][13];
char s[100005];
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    dp[0][0]=1;
    for(i=0;i<len;i++)
    {
        for(i0=0;i0<13;i0++)
        {
            if(s[i+1]=='?')
            {
                for(i1=0;i1<=9;i1++)
                {
                    dp[i+1][(i0*10+i1)%13]+=dp[i][i0];
                    dp[i+1][(i0*10+i1)%13]%=mod;
                }
            }
            else
            {
                dp[i+1][(i0*10+s[i+1]-'0')%13]+=dp[i][i0];
                dp[i+1][(i0*10+s[i+1]-'0')%13]%=mod;
            }   
        }
    }
    printf("%lld\n",dp[len][5]);
    return 0;
}

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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int m, n;
	static int[] dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
	static int[][] field = new int[92][92];
	
	public static void main(String[] args) {
		for(int i = 0; i < field.length; i++) 
			fill(field[i], 0);
		
		while(read())
			System.out.println(solve());
	}
	
	static boolean read() {
		m = sc.nextInt(); n = sc.nextInt();
		if(m == 0)
			return false;
		
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= m; j++) 
				field[i][j] = sc.nextInt();
		
		return true;
	}
	
	static int solve() {
		int ans = 0;
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= m; j++)
				if(field[i][j] == 1)
					ans = max(ans, rec(j, i, 1));
			
		
		return ans;
	}
	
	static int rec(int x, int y, int step) {
		int ret = 0;
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if(field[ny][nx] == 1) {
				field[y][x] = 0;
				ret = max(ret, rec(nx, ny, step + 1));
				field[y][x] = 1;
			} else {
				ret = max(ret, step);
			}
		}
		return ret;
	}
}

Measured memory_bytes: 12000
import numpy as np

H, W = map(int, input().split())
G = []
for _ in range(H):
    G.append([1 if x == '.' else 0 for x in input()])
G = np.array(G)

North = np.cumsum(np.ones_like(G), axis=0)
North *= (1 - G)
North = np.maximum.accumulate(North, axis=0) * G

South = np.cumsum(np.ones_like(G), axis=0)
South *= np.flipud(1 - G)
South = np.maximum.accumulate(South, axis=0)
South = (H - np.flipud(South)) * G

West = np.cumsum(np.ones_like(G), axis=1)
West *= (1 - G)
West = np.maximum.accumulate(West, axis=1) * G

East = np.cumsum(np.ones_like(G), axis=1)
East *= np.fliplr(1 - G)
East = np.maximum.accumulate(East, axis=1)
East = (W - np.fliplr(East)) * G

print(np.amax(South - North + East - West) - 1)


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

int main() {
  vector<int64_t> V(3);
  int c = 1;
  
  cin >> V.at(0) >> V.at(1) >> V.at(2);
  sort(V.begin(), V.end());
    
  for(int i = 0; i < 3; i++){
    c = c * (V.at(i) % 2);
  }
  if (c == 0){
    cout << 0 << endl;
  }
  else{
    cout << V.at(0) * V.at(1) << endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll read(){
  ll a;
  cin>>a;
  return a;
}
int main(){
  vector<ll> vec;
  for(int i=0;i<3;i++) vec.push_back(read());
  sort(vec.begin(),vec.end());
  if(vec[0]==vec[1]&&vec[1]==vec[2]) cout<<"No"<<endl;
  else if(vec[0]==vec[1]||vec[1]==vec[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  cout << (x >= a && x <= a + b ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
tmp = gets.chomp.split(' ')
A = tmp[0].to_i == 1 ? 14 : tmp[0].to_i
B = tmp[1].to_i == 1 ? 14 : tmp[1].to_i

if A == B
  puts "Draw"
elsif A > B
  puts "Alice"
else
  puts "Bob"
end


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




int main() {
  ll N,K;
  cin >> N >> K;
  ll ans = 0;
  for(ll i = K; i <= N+1; i++) {
    ll l = i*(2*N-i+1)/2;
    l%=mod;
    ll r = i*(i-1)/2;
    r%=mod;
    if(l-r<=0) l+=mod;
    ans += l - r + 1;
    ans %= mod;
  }
  
    
  

  
  cout << ans << endl;
}


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

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

  vector<int> v;
  for (int i = 1; i * i <= M; ++i) {
    if (M % i != 0)
      continue;
    v.push_back(i);
    v.push_back(M / i);
  }

  int ans = 0;
  rep(i, v.size()) if ((ll)N * v[i] <= M) ans = max(ans, v[i]);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
const int INF=0x3f3f3f3f,maxn=12;
long long n,m,d,k;
int main()
{
    cin>>n>>k>>d;
    n=abs(n);
    long long sum=n/d;
    long long t=n%d;
    if(sum>k)
    {
        cout<<n-k*d<<endl;
    }
    else
    {
        int x=k-sum;
        if(x%2==0)
        {
            cout<<n%d<<endl;
        }
        else
        {
            cout<<d-n%d<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
n = STDIN.gets.chomp.to_i
v = STDIN.gets.chomp.split(" ").map{|x| x.to_i}
c = STDIN.gets.chomp.split(" ").map{|x| x.to_i}

diff = []
for i in 0..(n-1) do
  diff[i] = v[i] - c[i]
end

diff.select!{|n| n > 0}
if diff.size == 0
  puts 0
  exit
end

puts diff.inject(:+)

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)(n); i++)
#define reps(i,s,e) for(int i=s; i<(int)(e); i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

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

const int INT_BIG = 1<<28;

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << (N/X + ((N%X != 0) ? 1 : 0)) * T << endl;
}

Measured memory_bytes: 3632
function main()
    x = pread(Int)
    println(1 - x)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 182224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> A(n);
    vector<int> B(n);
    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=0;i<n;i++)
        cin>>B[i];
    reverse(B.begin(),B.end());
    int left=0;
    int right=n-1;
    int ll=-1;
    int rr=n;
    int lb=-1;
    int rb=n;
    for(int i=0;i<n;i++)
    {
        if(A[i]==B[i])
        {
            rr=i;
            if(ll==-1)
                ll=i;
        }
    }
    lb=ll;
    rb=rr;
    while(lb<=rb&&(left<ll||right>rr))
    {
        //cout<<"Hel0"<<endl;
        if(left<ll)
        {
            if(A[left]!=B[lb]&&A[lb]!=B[left])
            {
                swap(B[lb],B[left]);
                lb++;
            }
            left++;
        }
        if(right>rr)
        {
            if(A[right]!=B[rb]&&A[rb]!=B[right])
            {
                swap(B[rb],B[right]);
                rb--;
            }
            right--;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(A[i]==B[i])
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(auto const&e:B)
        cout<<e<<" ";
    cout<<"\n";
    return 0;
}

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

const int MAXN = 2e5 + 5;

int N;
string s;
int dp[MAXN][5];
	
void load() {
	cin >> s;
}

int rec(int pos, int len) {
	int &ref = dp[pos][len];
	if (ref != -1)
		return ref;
	if (pos == len)
		return ref = 1;
	for (int i = 1; i <= min(pos - len, 4); i++)
		if (s.substr(pos - len - i + 1, i) != s.substr(pos - len + 1, len))
			ref = max(ref, rec(pos - len, i) + 1);
	return ref;
}

int solve() {
	memset(dp, -1, sizeof dp);
	s = ' ' + s;
	N = s.size();
	int sol = 0;
	for (int i = 1; i <= min(N - 1, 4); i++)
		sol = max(sol, rec(N - 1, i));
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> l(n, 0);
    int start = -1;

    for (int i = 0; i < n; i += 1) {
        cin >> l[i];
        if (i > 0 and l[i] + l[i - 1] >= k) {
            start = i - 1;
        }
    }

    if (start == -1) {
        cout << "Impossible\n";
        return 0;
    }

    vector<int> sol;

    for (int i = 1; i <= start; i += 1)
        sol.push_back(i);
    for (int i = n - 1; i > start + 1; i -= 1)
        sol.push_back(i);
    sol.push_back(start + 1);

    cout << "Possible\n";
    for (auto val : sol)
        cout << val << "\n";
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
//#include <stdio.h>
//#include <iostream>
//#include <string.h>
//#include <math.h>
//#include <stdlib.h>
//#include <limits.h>
//#include <algorithm>
//#include <queue>
//#include <vector>
//#include <set>
//#include <map>
//#include <stack>
//#include <bitset>
//#include <string>
//#include <time.h>
using namespace std;
long double esp=1e-11;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p,c) memset(p,c,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3fll;
const int MOD =1000000007ll;
const int maxn=100100;
int sg[maxn];
vector<int>node[maxn];
void dfs(int u,int fa)
{
	for(auto v:node[u])
		if(v!=fa)
		{
			dfs(v,u);
			sg[u]^=sg[v]+1;
		}
}
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("in1.txt", "w", stdout);
    //::iterator iter;                  %I64d
    //for(int x=1;x<=n;x++)
    //for(int y=1;y<=n;y++)
    //scanf("%d",&a);
    //printf("%d\n",ans);
    int n;
    scanf("%d",&n);
    for(int x=1;x<n;x++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		node[u].pb(v);
		node[v].pb(u);
	}
	dfs(1,0);
	if(sg[1])puts("Alice");
	else puts("Bob");
    return 0;
}


Measured memory_bytes: 12416
#include<iostream>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C - (A - B) >= 0) {
		cout << C - (A - B) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    long long int n,w;
    cin >> n >> w;
    vector <long long int> wt(n);
    vector <long long int> val(n);
    for (int i=0;i<n;i++){
        cin >> wt[i] >> val[i];
    }
    // sort(wt.begin(), wt.end());
    // sort(val.begin(), val.end());

    long long dp[n+1][w+1];
    for(int i=0;i<n+1;i++){
        for (int j=0;j<w+1;j++){
            if (i == 0 || j == 0){
                dp[i][j] = 0;
            }else if (wt[i-1] > j){
                dp[i][j] = dp[i-1][j];
            }else if (wt[i-1] <= j){
                dp[i][j] = max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
            }
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD_Q 1e9 + 7
#define MOD_A 998244353

 #define int long long


int MIN = I64_MAX;

void solve()
{

  int N;
  cin>>N; 

  // vector<vector<double> > dist (N,vector<double>(N,0));
  vector<vector<double> > data (N,vector<double>(2,0));

  for (int i = 0; i < N; i++)
  {
    double x,y;
    cin>>x>>y;
    data[i][0] = x;
    data[i][1] = y;
  }

  double dist_sum;
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      dist_sum += sqrt(pow(data[i][0] - data[j][0],2) + pow(data[i][1] - data[j][1],2));
    } 
  }

  int N_fact = 1;
  int N_sum = 0;
  for (int i = 1; i <= N; i++)
  {
    N_fact = N_fact*i;
    N_sum = N_sum + i;
  }

  int edge = 0;
  int last = 1;

  for (int i = N -1; i > 0; i--)
  {
    edge += last * i;
    last = edge;
  }

  edge*= N;
  N_sum = edge/(N)/(N-1)*2;
  
  // cout<<N_sum<<endl;
  std::cout<<std::fixed<<std::setprecision(10);
  cout<<dist_sum*double(N_sum)/double(N_fact)<<endl;

  
  



  
  


  
  return;  
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val a = Array(n) { sc.nextLong() }

    val sums = Array(n + 1) { 0L }
    for (i in 1..n) {
        sums[i] += sums[i - 1] + a[i - 1]
    }

    var best = -1L
    for (k in 1 until n) {
        val L = sums[k]
        var R = sums[n] - sums[k]
        var ans = L - R
        if (ans < 0) ans = -ans

        if(best == -1L || best > ans) best = ans
    }

    println(best)

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 80188
import java.util.*;

public class Main{
    public static void main(String[] args){
  String[] lines = getStdin();
  
String[] str = lines[0].split(" ");
int a = Integer.parseInt(str[0]);
int b = Integer.parseInt(str[1]);
  
  if (a > b){
      System.out.println("a > b");
  } else if(a < b){
      System.out.println("a < b");
  } else if ( a == b){
      System.out.println("a == b");
  }
    }
    
    private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}


Measured memory_bytes: 26056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> c(n,0);
  for(int x=1;x*x<=n*2;x++)
    for(int y=1;(x+y)*(x+y)<=n*2;y++)
      for(int z=1;(x+y+z)*(x+y+z)<=n*2;z++)
        if(x*x+y*y+z*z+x*y+y*z+z*x<=n)
          c.at(x*x+y*y+z*z+x*y+y*z+z*x-1)++;
  for(int i=0;i<n;i++)
    cout<<c.at(i)<<endl;
}

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

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,w;
	cin >> n >> w;
	vector<int> dp(w+1);
	for (int i=0; i<n; ++i){
		int a,wi;
		cin >> wi >> a;
		for (int j=w-wi; j>=0; --j){
			if (dp[j] != 0 or j == 0) dp[j+wi] = max(dp[j+wi],dp[j]+a);
		}
	}
	cout << *max_element(dp.begin(),dp.end());
	return 0;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n;
cin >> n;
vector<int> h(n);
rep(i,n) cin >> h.at(i);
bool ans = true;
for(int i = 1; i < n; i++){
  if(h.at(i)-h.at(i-1)>=1)h.at(i)--;
  else if(h.at(i)-h.at(i-1) < 0) ans = false;
}
cout <<(ans?"Yes":"No")<< endl;
}


Measured memory_bytes: 3780
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
N = len(S)

for i in range(N-1):
    if S[i] == S[i+1]:
        print(i+1,i+2)
        exit()
for i in range(N-2):
    if S[i] == S[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)


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

const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,1,0,-1 };
bool vi[100][100];
int ans[100][100];

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int res = 0;
	rep(i, h)rep(j, w) if (s[i][j] == '#') res++;
	auto bfs = [&](int a, int b) {
		queue<P> que;
		que.push(P(a,b));
		vi[a][b] = true;
		ans[a][b] = 0;
		while (que.size()) {
			P p = que.front(); que.pop();
			rep(i, 4) {
				int nx = p.first + dx[i], ny = p.second + dy[i];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
				if (s[nx][ny] == '#') continue;
				if (vi[nx][ny]) continue;
				vi[nx][ny] = true;
				ans[nx][ny] = ans[p.first][p.second] + 1;
				que.push(P(nx, ny));
			}
		}
		return;
	};
	bfs(0, 0);
	if (!vi[h-1][w-1]) {
		cout << -1 << endl;
		return 0;
	}
	cout << h * w - ans[h - 1][w - 1] - 1 - res << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
cost=[0]*(N+1)
cost[0]=abs(A[0]-0)#0からA[0]の距離
for i in range(1,N):#from 1 to N
    cost[i]=abs(A[i]-A[i-1])+cost[i-1]#累積和
    #cost[1]=abs(A[1]-A[0])+cost[0] 今までの距離+現在の距離
#cost[0:N]
cost[N]=abs(A[N-1])+cost[N-1]#今までの距離+現在の距離(0から最後のところまでの距離)

print(cost[N]-cost[1]+abs(A[1]-0))
for i in range(1,N-1):
    ans=cost[i-1]+cost[N]-cost[i+1]+abs(A[i+1]-A[i-1])
    print(ans)
print(cost[N-2]+abs(0-A[N-2]))



Measured memory_bytes: 14172
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,a,b = LI()
    r = 0
    x = LI()

    t = x[0]
    x.sort()
    i = x.index(t)
    if i == n-1 or i == 0:
        for j in range(n-1):
            if (x[j+1] - x[j]) * a < b:
                r += (x[j+1] - x[j]) * a
            else:
                r += b
        return r

    if (x[i+1]-x[0])*a < b:
        r += ((t - x[0]) + (x[i+1] - x[0]))*a
        for j in range(i+2,n):
            if (x[j] - x[j-1]) * a < b:
                r += (x[j] - x[j-1]) * a
            else:
                r += b
        return r
    if (x[-1]-x[i-1])*a < b:
        r += ((x[-1] - t) + (x[-1] - x[i-1]))*a
        for j in range(i-1):
            if (x[j+1] - x[j]) * a < b:
                r += (x[j+1] - x[j]) * a
            else:
                r += b
        return r

    for j in range(i+2,n):
        if (x[j] - x[j-1]) * a < b:
            r += (x[j] - x[j-1]) * a
        else:
            r += b
    for j in range(i-1):
        if (x[j+1] - x[j]) * a < b:
            r += (x[j+1] - x[j]) * a
        else:
            r += b
    r += b

    return r


print(main())


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

int main() {
  string s;
  cin >> s;  
  int sum;
  
  if(s.at(0) == '1'){
    sum++;
  } 
  
  if(s.at(1) == '1'){
    sum++;
  } 

  if(s.at(2) == '1'){
    sum++;
  } 
  
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}

int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  rep(i,b){
    rep(j,a)
      cout << 1;
    rep(j,w-a)
      cout << 0;
    cout << endl;
  }
  rep(i,h-b){
    rep(j,a)
      cout << 0;
    rep(j,w-a)
      cout << 1;
    cout << endl;
  }
}

Measured memory_bytes: 1280
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Second Sum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

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

/* global variables */

pii ps[MAX_N];
msi xset;

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++)
    scanf("%d", &ps[i].first), ps[i].second = i;
  sort(ps, ps + n);

  ll sum = 0;
  xset.insert(-1), xset.insert(-1);
  xset.insert(n), xset.insert(n);

  for (int i = n - 1; i >= 0; i--) {
    int j = ps[i].second;
    msi::iterator mit = xset.lower_bound(j);
    msi::iterator sit = mit, tit = mit;
    int xi = *(--sit), wi = *(--sit);
    int yi = *tit, zi = *(++tit);
    // 、Ci = (xi − wi) × (yi − i) + (i − xi) × (zi − yi)
    ll ci = (ll)(xi - wi) * (yi - j) + (ll)(j - xi) * (zi - yi);
    sum += ci * ps[i].first;
    xset.insert(j);
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 6656
n = int(input())
a = list(map(int,input().split()))
flag = True
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 !=0 and a[i] % 5 != 0:
      flag = False

if flag == True:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#import"cstdio"
int n,m;
void d(long a,int f){if(a<=n)m+=f==7,a*=10,d(a+3,f|1),d(a+5,f|2),d(a+7,f|4);}
main(){scanf("%d",&n);d(0,0);printf("%d",m);}

Measured memory_bytes: 128
#! usr/bin/perl

use strict;
use warnings;


chomp(my $N = <STDIN>);
my %cards;
foreach (0..$N-1)
{
chomp (my $card = <STDIN>);
++$cards{$card};}
chomp(my $M = <STDIN>);
foreach  (0..$M-1)
{
chomp (my $card = <STDIN>);
--$cards{$card};
}


my @result = sort{
$cards{$b} <=> $cards{$a};
} keys %cards;

$cards{$result[0]}<0 ? print "0\n" :
print "$cards{$result[0]}\n";


Measured memory_bytes: 640