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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

int n;
const int MAXN = 300002;
int A[MAXN];
LL l[MAXN], r[MAXN];

LL max_score()
{
	priority_queue<int, VI, greater<int>> pq1;	
	priority_queue<int> pq2;

	LL sum = 0;
	for(int i = 1; i <= 3 * n; ++i)
	{
		sum += A[i];
		pq1.push(A[i]);
		while(sz(pq1) > n)
		{
			sum -= pq1.top();
			pq1.pop();
		}
		l[i] = sum;
	}

	sum = 0;
	for(int i = 3 * n; i >= 0; --i)
	{
		sum += A[i];
		pq2.push(A[i]);
		while(sz(pq2) > n)
		{
			sum -= pq2.top();
			pq2.pop(); 
		}
		r[i] = sum;
	}

	LL ret = LLONG_MIN;
	for(int i = n; i <= 2 * n; ++i)
		ret = max(ret, l[i] - r[i + 1]);

	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;
	for(int i = 1; i <= 3 * n; ++i) cin >> A[i];
	
	cout << max_score() << endl;

	return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5;
const int mod = 1e9 + 7;
int n, a[20][20];
ll f[70000], g[70000];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];
	for (int i = 0; i < (1 << n); ++i) {
		ll t = 0;
		for (int j = 0; j < n; ++j)
			for (int k = j; k < n; ++k)
				if ((i >> j & 1) && (i >> k & 1)) t += a[j][k];
		g[i] = t;
		//cout << t << "/";
	}
	for (int i = 1; i < (1 << n); ++i) {
		int x = i & -i;
		int y = i - x;
		f[i] = max(f[i], g[x] + f[i - x]);
		for (int s = y; s; s = (s - 1) & y) {
			f[i]  = max(f[i], g[x + s] + f[i - x - s]);
			//if (g[x + s] > 0) cout << "/"; 
		}
	}
	cout << f[(1 << n) - 1];
}



Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t A = 0, B = 0, C = 0, K = 0;
  std::cin >> A >> B >> C >> K;

  int32_t value = 0;
  if (K >= A) {
    value += A * 1;
    K -= A;
  } else {
    value += K * 1;
    K = 0;
  }
  if (K >= B) {
    value += B * 0;
    K -= B;
  } else {
    value += K * 0;
    K = 0;
  }
  value -= K;

  std::cout << value << std::endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int cnt = 0;
    REP(i,0,n-1) {
        if (a[i] == i + 1) {
            swap(a[i], a[i+1]);
            ++cnt;
        }
    }
    if (a[n-1] == n) {
        swap(a[n-1], a[n-2]);
        ++cnt;
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 640
//
// Created by Hideaki Imamura on 2020-04-04.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N, K, C;
string S;

int main() {
    cin >> N >> K >> C >> S;

    int L[K+1], R[K+1];
    int l = 0, r = N - 1;
    for (int k = 1; k <= K; ++k) {
        while (S[l] == 'x') l++;
        L[k] = l + 1;
        l += C + 1;
        while (S[r] == 'x') r--;
        R[K - k + 1] = r + 1;
        r -= C + 1;
    }

    for (int k = 1; k <= K; ++k) {
        if (L[k] == R[k]) cout << L[k] << endl;
    }
    return 0;
}

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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int solve(int N, vi& a) {
    int mincost = 0x7fffffff;
    for (int y=-100; y<=100; ++y) {
        int cost = 0;
        rep(i, N) {
            cost += (a[i] - y) * (a[i] - y);
        }
        mincost = min(mincost, cost);
    }
    return mincost;
}

int main() {
    int N; cin >> N;
    vi a(N);
    rep(i,N) cin>>a[i];
    cout << solve(N, a) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(ll i=a;i < b;i++)
#define fe(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(auto it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define MAXN 100005
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define case(x) cout<<"Case #"<<x+1<<": "
#define endl "\n"
#define preturn(X) cout<<(X)<<endl; return 0
const int MOD = 1e9+7;
ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

int32_t main(){
    int n;
    cin>>n;
    vector<int> dp1(3,0), dp2(3,0);
    while(n--){
        int a,b,c;
        cin>>a>>b>>c;
        dp2[0] =  max(dp1[1],dp1[2]) + a;
        dp2[1] =  max(dp1[0],dp1[2]) + b;
        dp2[2] =  max(dp1[1],dp1[0]) + c;
        dp1 = dp2;
    }
    cout<<max({dp1[0],dp1[1],dp1[2]})<<endl;;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
signed main(){
	int w, h; cin >> w >> h;
	vvel s(h, vel(w));
	int sum1 = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
			sum1 += s[i][j];
		}
	}
	vvel sum(h + 1, vel(w, 0));
	dp = vvel(h + 1, vel(w +1,inf));
	rep(j, w) {
		for (int i = h - 1; i >= 0; i--) {
			sum[i][j] = sum[i + 1][j] + s[i][j];
		}
	}
	cout << abs(solve(sum, 0, 0, true)*2-sum1) << endl;
	return 0;
}


Measured memory_bytes: 27620
N = int(input())
T,X,Y =0,0,0
count = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(t-T) >= abs((x+y)-(X+Y)) and t%2==(x+y)%2:
        count+=1
T,X,Y=t,x,y        
print('Yes' if count==N else 'No' )        



Measured memory_bytes: 3060
m,d=map(int,input().split())
if d<22:
  print(0)
else:
  t=d//10
  o=d-(t*10)
  i=2
  ans=0
  k=2
  while i<t and i*2<=m:
    j=2
    while j*i<=m and j < 10:
      ans+=1
      j+=1
    i+=1
  while t*k<=m and k<=o:
    ans+=1
    k+=1
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int k[5];
  int w[5];
  rep(i,5){
    int q;
    cin >> q;
    k[i]=q;
    w[i]=((q-1)/10+1)*10;
  }
  int ans=10000000;
  rep(z,5){
    int e=0;
    rep(c,5){
      e+=w[c];
    }
    e=e-w[z]+k[z];
    ans=min(ans,e);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

void failure () {
  cout << -1 << endl;
  exit(0);
}

int arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;

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

  int mn = n - 1;
  ll ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] > 0) failure();
    if (-arr[i] == mn) {
    } else if (-arr[i] < mn) {
      ans += i + arr[i];
      mn = -arr[i];
    } else {
      failure();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4428
import java.util.*;

class Main{
	static long[]l=new long[51];
	static long[]b=new long[51];
	
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		l[0]=1;
		b[0]=1;
		for(int i=1;i<l.length;++i) {
			l[i]=l[i-1]*2+3;
			b[i]=b[i-1]*2+1;
		}
		System.out.println(f(s.nextInt(),s.nextLong()));
	}

	static long f(int i,long a){
		if(a==l[i])
			return b[i];
		if(a>l[i-1]+2)
			return b[i-1]+1+f(i-1,a-l[i-1]-2);
		if(a==l[i-1]+2)
			return b[i-1]+1;
		if(a>1)
			return f(i-1,a-1);
		return 0;
	}
}


Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i = 0;
		String sa = scan.nextLine();
		List<String> a_list = new ArrayList<String>();
		for(i = 0; i < sa.length(); i++) {
			a_list.add(sa.charAt(i) + "");
		}
		String sb = scan.nextLine();
		List<String> b_list = new ArrayList<String>();
		for(i = 0; i < sb.length(); i++) {
			b_list.add(sb.charAt(i) + "");
		}
		String sc = scan.nextLine();
		List<String> c_list = new ArrayList<String>();
		for(i = 0; i < sc.length(); i++) {
			c_list.add(sc.charAt(i) + "");
		}
		
		String card = a_list.get(0);
		a_list.remove(0);
		String winner = "";
		if(a_list.size() == 0) {
			winner = "A";
		}
		
		for(; ;) {
			if(card.equals("a")) {
				if(a_list.size() == 0) {
					winner = "A";
					break;
				}
				card = a_list.get(0);
				a_list.remove(0);
				
			} else if(card.equals("b")) {
				if(b_list.size() == 0) {
					winner = "B";
					break;
				}
				card = b_list.get(0);
				b_list.remove(0);
				
			} else if(card.equals("c")) {
				if(c_list.size() == 0) {
					winner = "C";
					break;
				}
				card = c_list.get(0);
				c_list.remove(0);
				
			}
		}
		
		System.out.println(winner);
	}
}

Measured memory_bytes: 21844
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

from itertools import combinations

N,K=map(int,input().split())
a=list(map(int,input().split()))

minc=10**12
ai=[i for i in range(N)]
for i in combinations(ai,K):
    ac=a[:]
    cost=0
    i=list(i)
    for j in range(1,K):
        costt=max(max(ac[:i[j]])-ac[i[j]]+1,0)
        ac[i[j]]+=costt
        cost+=costt
    minc=min(cost,minc)
print(minc)

Measured memory_bytes: 41052
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
const int inf = 1 << 30;

int main() {
    int N, K; cin >> N >> K;
    vector<int> X(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
    }
    int ans = inf;
    for (int i = 0; i < N - K + 1; ++i) {
        int l = X[i], r = X[i + K - 1];
        ans = min({ans, abs(l) + abs(r - l), abs(r) + abs(l - r)});
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Sequence as Sq
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

readIntBS = fst . fromJust . BS.readInt

main :: IO ()
main = do
  n <- readLn :: IO Int
  dat <- reverse . sortBy (comparing (\[_,_,h] -> h)) . map (map read . words) . lines <$> getContents :: IO [[Int]]

  let
    ([x1,y1,h1]:rest) = dat
    solve cx cy = (all (\[x,y,h] -> h == max (height - abs (x-cx) - abs (y-cy)) 0) rest, height)
      where
        height = h1 + abs (x1-cx) + abs (y1-cy)

    (ax,ay,ah) = head [(x,y,h) | x<-[0..100], y<-[0..100], let (t,h) = solve x y, t]
  

  printf "%d %d %d\n" ax ay ah


Measured memory_bytes: 1020
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		
		if (X%(Y+Z) >= Z) System.out.println(X/(Y+Z));
		else if (X%(Y+Z) < Z) System.out.println(X/(Y+Z)-1);
		
	}
}


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

ll cnt;
int A[1000000];
vector<int> G;

void inserionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	for (int i = 1; ; ) {
		if (i > n)
			break;
		G.push_back(i);
		i = 3 * i + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--)
		inserionSort(A, n, G[i]);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	cnt = 0;
	shellSort(A, n);
	cout << G.size() << endl;

	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i == 0)
			printf("\n");
		else
			printf(" ");
	}
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}
}


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

int main(int argc, char** argv) {
  std::vector<int> money_chips {100, 101, 102, 103, 104, 105};
  int input_money {};
  std::cin >> input_money;
  int count = input_money / 100;
  int mod = input_money % 100;
  int top = 5*count;
  if (mod <= top) {
    std::cout << "1\n";
  } else {
    std::cout << "0\n";
  }
}


Measured memory_bytes: 384
using System;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;


namespace aizu
{
	public class EntryPoint
	{
		public static string[] Split(string line)
		{
			return Regex.Split(line, " ");
		}
		public static int[] SplitToInt(string line)
		{
			return Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDouble(string line)
		{
			return Regex.Split(line, " ").Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLong(string line)
		{
			return Regex.Split(line, " ").Select(x => long.Parse(x)).ToArray();
		}
		public static void Main()
		{
			var line0 = Console.ReadLine();
			var len = int.Parse(line0);
			
			var line = Console.ReadLine();
			
			var v = SplitToLong(line);
			
			long max = v[0];
			long min = v[0];
			long sum = v[0];
			
			if (len != v.Length)
			{
				throw new ApplicationException();
			}
			
			
			for (int i = 1; i < v.Length; i++)
			{
				if (v[i] > max)
				{
					max = v[i];
				}
				if (v[i] < min)
				{
					min = v[i];
				}
				sum += v[i];
			}
			Console.WriteLine(string.Format("{0} {1} {2}", min, max, sum));
		}
	}


}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> ball(n, 1); // ボールの個数
  vector<bool> red(n, false); // 赤いボールが入っている可能性があるかどうか
  red.at(0) = true;
  
  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    
    if(red.at(x)){
      if(ball.at(x) == 1){
        red.at(x) = false;
      }
      red.at(y) = true;
    }
    ball.at(x)--;
    ball.at(y)++;
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(red.at(i)) ans++;
  }
  
  cout << ans << '\n';
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin >> n >> m >> k;
	vector<int> col(n + 1);
	vector<int> row(m + 1);
	vector<set<int>> rem(n + 1);
	vector<vector<int>> pos(m + 1);
	for (int i = 1;i <= k;i++) {
		int x,y;
		cin >> x >> y;
		col[x]++;
		row[y]++;
		pos[y].emplace_back(x);
		rem[x].insert(y);
	}
	int mx = *max_element(row.begin(),row.end());
	int cnt = 0;
	for (int i = 1;i <= m;i++) {
		if (row[i] != mx) {
			for (auto&x : pos[i]) {
				rem[x].erase(i);
			}
		}
		else ++cnt;
	}
	int ans = mx;
	mx = *max_element(col.begin(),col.end());
	ans += mx;
	bool flag = false;
	for (int i = 1;i <= n;i++) {
		if (col[i] == mx && (int)rem[i].size() < cnt) {
			flag = true;
			break;
		}
	}
	if (!flag) ans --;
	cout << ans;
} 

Measured memory_bytes: 50184
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> A = new HashSet<>();
		for(int i = 0; i < N; i++)
			A.add(sc.nextInt());
		System.out.println(A.size() == N ? "YES" : "NO");

	}

}

Measured memory_bytes: 101276
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   string a,b;
    cin>>a>>b;
    cout<<b+a<<endl;
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

const long long mod = 1000000007;

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

  string s;
  cin >> s;

  vector <int> hand, feet;
  for (int i = 0; i < N; i++) {
    if (s[i] == '0') {
      if (i == 0 || s[i - 1] != '0') {
        feet.push_back(1);
        hand.push_back(0);
      } else {
        feet.back()++;
      }
    }

    if (s[i] == '1') {
      if (i == 0 || s[i - 1] != '1') {
        hand.push_back(1);
        feet.push_back(0);
      } else {
        hand.back()++;
      }
    }
  }

  int ct = 0;
  int best = 0;
  int current = 0;
  for (int i = 0; i < hand.size(); i++) {
    if (hand[i] == 0) {
      if (ct < K) {
        ct++;
        current += feet[i];
      } else {
        current += feet[i];
        current -= feet[i - 2 * K];
        current -= hand[i - 2 * K - 1];
      }
    } else {
      current += hand[i];
    }

    best = max(best, current);
  }

  cout << best << endl;

  return 0;
}


Measured memory_bytes: 1404
# -*- coding: utf-8 -*-
'''
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp
???????¨???????
???????¢??????¨??????
http://prdc.hatenablog.com/entry/2017/09/02/125842
'''
import bisect

n = int(input())
L = []

for i in range(n):
    a = int(input())
    z = bisect.bisect_left(L, a)
    if z >= len(L):
        L.append(a)
    else:
        L[z] = a

print(len(L))

Measured memory_bytes: 9680
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    int ans=0,id;
    int N,M;
    ll A,B,C,W;
    int a[100];
    bool f=false;
    ll sum=0;
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    REP(i,(signed)S.size()){
        if(a[(int)S[i]%26]==0)a[(int)S[i]%26]++;
        else{f=true;break;}
    }
    f?cout<<"no":cout<<"yes";


    //cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

string strSort(string str){
    int n = str.length();
    for (int i=0; i<n; i++) {
        for (int j=i; j<n; j++) {
            if (str[i] > str[j]) {
                swap(str[i], str[j]);
            }
        }
    }
    return str;
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    string str;
    map<string, int> map;
    long answer = 0;
    for (int i=0; i<n; i++) {
        cin >> str;
        str = strSort(str);
        answer += map[str];
        map[str]++;
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 11904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A>9||B>9) {
			System.out.println(-1);
		}
		else
			System.out.println(A*B);
	}

}


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

using namespace std;

const int N = 1024;

int a[N];

int main() {
  int x, n;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i);
  sort(a, a+n);
  int ans = 0;
  while (ans < n && x >= a[ans]) {
    x -= a[ans++];
  }
  if (ans == n && x != 0)
    --ans;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf("%d %d %d" , &b1, &b2, &b3);
	
	if ((b1 == b2) && (b1 != b3)){
		printf("Open\n");
	}
	
	else {
		printf("Close\n");
	}
	
	return (0);
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<int>> grid(2*K, vector<int>(2*K, 0));
    for (int i = 0; i < N; i++) {
        int x, y;
        char c;
        scanf("%d %d %c", &x, &y, &c);
        if (c == 'W') y += K;
        x %= 2*K;
        y %= 2*K;
        grid[x][y]++;
        grid[(x+K)%(2*K)][y]--;
        grid[x][(y+K)%(2*K)]--;
        grid[(x+K)%(2*K)][(y+K)%(2*K)]++;
        if (x >= K) {
            grid[0][y]++;
            grid[0][(y+K)%(2*K)]--;
        }
        if (y >= K) {
            grid[x][0]++;
            grid[(x+K)%(2*K)][0]--;
        }
        if (x >= K && y >= K) grid[0][0]++;
    }
    for (int i = 1; i < 2*K; i++) grid[0][i] += grid[0][i-1];
    for (int i = 1; i < 2*K; i++) grid[i][0] += grid[i-1][0];
    for (int i = 1; i < 2*K; i++) {
        for (int j = 1; j < 2*K; j++) {
            grid[i][j] = grid[i][j] +  grid[i-1][j]+grid[i][j-1]-grid[i-1][j-1];
        }
    }
    /*
    for (int i = 0; i < 2*K; i++) {
        for (int j = 0; j < 2*K; j++) {
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }
    */
    int ans = 0;
    for (int i = 0; i < 2*K; i++) {
        for (int j = 0; j < K; j++) {
            ans = max(ans, grid[i][j]+grid[(i+K)%(2*K)][j+K]);
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int a[maxn], b[maxn];

int main(){
   	int n;
   	cin >> n;
   	for(int i = 0; i < n + 1; ++i){
		cin >> a[i];
   	}
   	for(int i = 0; i < n; ++i){
		cin >> b[i];
   	}
   	LL ans = 0;
   	for(int i = 0; i < n; ++i){
		if(b[i] >= a[i]){
			b[i] = b[i] - a[i];
			ans = ans + a[i];
			a[i] = 0;
		}
		else{
			ans = ans + b[i];
			a[i] = a[i] - b[i];
			continue;
		}
		
		if(b[i] >= a[i + 1]){
			b[i] = b[i] - a[i + 1];
			ans = ans + a[i + 1];
			a[i + 1] = 0;
		}
		else{
			ans = ans + b[i];
			a[i + 1] = a[i + 1] - b[i];
			continue;
		}
   	}
   	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
const int N = 10000000;
int lp[N+1];
vector<int> pr;
void sieve(){
for (int i=2; i<=N; ++i) {
    if (lp[i] == 0) {
        lp[i] = i;
        pr.push_back (i);
    }
    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
        lp[i * pr[j]] = pr[j];
}
}
int cal(int n){
	int ans = 1;
	while(n != 1){
		int cur = lp[n];
		int pw = 1;
		while(cur == lp[n]){
			pw++;
			n/=lp[n];
		}
		ans *= pw;
	}
	return ans;
}
void solve(){
	int n; cin >> n;
	int ans = 0;
	rep(i,1,n){
		ans += i*cal(i);
	}
	cout << ans;
}
int32_t main()
{
	sieve();
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int tst=1; while(tst--){
     solve();
   }
}

Measured memory_bytes: 89620
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
/* Data Structure */
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <queue>

using namespace std;

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define debug cerr << "======= GOT_HERE ======\n"
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef map<int,int> mii;
typedef map<long long,long long> mll;
typedef set<int> si;
typedef set<long long> sll;

long long n,k,m;

const int mod = 1e9+7;

ll perm(ll n)
{
	ll ans = 1;
	while(n)
	{
		ans*=n;
		ans%=mod;
		n--;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	ll ans = 1;
	if(m>n) swap(m,n);
	if(n-m>1)
	{
		cout << "0" << endl;
		return 0;
	}
	if(n==m)
	{
		ans*=perm(n);
		ans%=mod;
		ans*=perm(m);
		ans%=mod;
		ans*=2;
		ans%=mod;
	}
	else
	{
		ans*=perm(n);
		ans%=mod;
		ans*=perm(m);
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int h,n;
    cin >> h >> n;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        h -= a;
    }
    if(h <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())


int N, M;
vi used;
vvi edges;

int dp(int now, int length){
    // if (used[now]) return 0;
    if (length == N) {
        used[now] = 0;
        return 1;
    }

    int ans=0;
    // used[now] = 1;

    for (int i = 0; i < N; i++) {
        if (edges[now][i] && used[i] == 0) {
            used[i] = 1;
            ans += dp(i, length+1);
        }
    }

    used[now] = 0;

    return ans;
}

void solve(){
    cin >> N >> M;
    used = vi(N,0);
    used[0] = 1;
    edges = vvi(N, vi(N,0));

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }


    cout << dp(0, 1) << endl;

    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

vs makestr(string s,int k){
    vs v(s.length()*s.length()+100,"");
    string t;
    int p=0;
    for(int i=0;i<s.length();i++){
        t="";
        for(int j=0;i+j<s.length();j++){
            t+=s[i+j];
            if(t.length()>k)break;
            v[p]=t;
            // cout<<"t:"<<t<<"/"<<endl;
            p++;
        }
    }
    return v;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    string s;
    
    int k;
    cin>>s>>k;
    vs v=makestr(s,k);
    set<string> se;
    for(int i=0;i<v.size();i++){
        if(v[i].size()>0)se.insert(v[i]);
    }
    vs ans;
    for(auto it=se.begin();it!=se.end();it++){
        ans.push_back(*it);
    }
    Sort(ans);
    cout<<ans[k-1]<<endl;
    
//////////////////////////////////////////////////////
return 0;}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int x;cin>>x;
    if(x%2==1)cout<<(x/2+1)*(x/2)<<endl;
    else cout<<(x/2)*(x/2)<<endl;
}

Measured memory_bytes: 3604
n = int(input())
a_list = list(map(int, input().split()))
if 0 in a_list:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[i])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 21776
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s, x;
  cin>>s>>x;
  cout<<"A"<<x[0]<<"C"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll int
#define inf 999999999999
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define read(x)  freopen("input.txt","r",stdin);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100000+9
using namespace std;
vector<pair<ll,ll> >v[mx];
ll vis[mx],n,clor[mx];
void dfs(ll u,ll clr=-1){

ll a,b;
for(auto i:v[u]){

    if (i.F==clr) continue;
        if(i.S&1){
            clor[i.F]=1-clor[u];
        }
        else {
            clor[i.F]=clor[u];

        }
        dfs(i.F,u);

}
}


int main(){//read(x);
fast;
ll a,b,c,d,e,f,g,h,l,i,j=0,k,t;

    cin>>n;
    for(i=1;i<n;i++){
        cin>>a>>b>>c;
        v[a].pb(mp(b,c));
        v[b].pb(mp(a,c));
    }

    memset(clor,-1,n+1);
    clor[1]=0;
    dfs(1,0);

    for(i=1;i<=n;i++)cout<<clor[i]<<endl;
}






Measured memory_bytes: 12292
import sys
from decimal import Decimal, getcontext
getcontext().prec = 32


def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


L = Decimal(I())

a = L / Decimal(3)
b = L / Decimal(3)
c = L - a - b

print(a * b * c)


Measured memory_bytes: 61548
#include<iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int m, n;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<vector<int> > v;

int dfs(int x, int y, int step){
    int ans = step;
    for(int i=0; i < 4; i++){
        int nx = x+dx[i], ny = y+dy[i];
        if(0 <= nx && nx < n && 0 <= ny && ny < m && v[nx][ny] == 1){
            v[nx][ny] = 0;
            ans = max(dfs(nx, ny, step+1), ans);
            v[nx][ny] = 1;
        }
    }
    return ans;
}

int main(){
    while(cin >> m >> n, m || n){
        v.clear();
        int ans = 0;

        for(int i=0; i < n; i++){
            vector<int> vv(m);
            for(int j=0; j < m; j++){
                scanf("%d", &vv[j]);
            }
            v.push_back(vv);
        }

        for(int i=0; i < n; i++){
            for(int j=0; j < m; j++){
                if(v[i][j] == 1){
                    v[i][j] = 0;
                    ans = max(ans, dfs(i, j, 1));
                    v[i][j] = 1;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1312
count=0
n=int(input())
for i in range(1,n+1,2):
    k=1
    num=1
    while(k*k<=i):
        if(i%k==0):
            num+=1
        if(i//k!=i and i%(i//k)==0):
            num+=1
        k+=1
    if(num==8):
        count+=1
print(count)

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

void dfs(int v, vector<vector<int>> &g, vector<int> &sum,
		vector<int> &counter) {
	for (int next : g.at(v)) {
		if (sum.at(next) < 0) {
			sum.at(next) = sum.at(v) + counter.at(next);
			dfs(next, g, sum, counter);
		}
	}
}

int main() {
	int n, q;

	cin >> n >> q;
	vector<vector<int>> g(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g.at(a).push_back(b);
		g.at(b).push_back(a);
	}
	vector<int> counter(n);
	while (q--) {
		int p, x;
		cin >> p >> x;
		p--;
		counter.at(p) += x;
	}

	vector<int> sum(n, -1);
	sum.at(0) = counter.at(0);
	dfs(0, g, sum, counter);

	for (int i = 0; i < n; i++) {
		cout << sum.at(i) << (i < n - 1 ? " " : "\n");
	}
}


Measured memory_bytes: 30464
def main():
    H, W = (int(i) for i in input().split())
    N = int(input())
    a = [int(i) for i in input().split()]
    a_idx = [[i+1,cnt] for i,cnt in enumerate(a)]
    a_idx.sort(key=lambda x:x[1],reverse=True)
    a_ins = []
    for val,cnt in a_idx:
        a_ins.extend([val]*cnt)

    c = [[0] * W for i in range(H)]
    a_i = 0
    for i in range(H):
        if i%2 == 0:
            for j in range(W):
                c[i][j] = a_ins[a_i]
                a_i += 1
        else:
            for j in range(W)[::-1]:
                c[i][j] = a_ins[a_i]
                a_i += 1

    for val in c:
        print(*val)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43376
from collections import deque

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    graph[r].append((l, r, -d))
    graph[l].append((r, l, d))

max_int = 10 ** 10
point = [None for _ in range(n)]

for v in range(n):
    Q = deque()
    if point[v] is not None:
        continue
    Q.extend(graph[v])
    while Q:
        next_v, v, d = Q.popleft()
        if point[v] is None:
            point[v] = 0
        if point[next_v] is not None:
            if point[next_v] != point[v] + d:
                print('No')
                exit()
            else:
                continue
        point[next_v] = point[v] + d
        Q.extend(graph[next_v])
print('Yes')

Measured memory_bytes: 70828
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ000
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            int i = 1;

            while ((line = Console.ReadLine()) != "0")
            {
                Console.WriteLine("Case {0}: {1}", i++, line);
            }
        }
    }
}

Measured memory_bytes: 5804
const main = (A,B) => {
    K = Math.floor((A+B)/2)
    if(Math.abs(A-K) === Math.abs(B-K)) {
        return K
    }else{
        return "IMPOSSIBLE"
    }

}


const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")[0]
const AB = input.split(" ").map( x => Number(x))
console.log(main(AB[0],AB[1]))

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

int main()
{

	int a,b,c,x,y;
	int price=0;
	cin >> a >> b >> c >> x >> y;

	int ab=min(x,y);
	if ((a+b)<c*2)
	{
		price+=(a+b)*ab;
	}
	else
	{
		price+=c*2*ab;
	}
	x-=ab;
	y-=ab;

	if (a<c*2)
	{
		price+=a*x;
	}
	else
	{
		price+=c*2*x;
	}

	if (b<c*2)
	{
		price+=b*y;
	}
	else
	{
		price+=c*2*y;
	}
	cout << price << endl;
}






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



int main() {
	int h1,s1,h2,s2;
	cin >> h1 >> s1 >> h2 >> s2;
	int i=0;
	while(h1>0 && h2>0){
		if(i%2==0){
			h2 = h2-s1;
		}else {
			h1 = h1-s2;
		}	
		i++;
	}
	if(h1<=0) cout <<"No\n";
	else cout << "Yes\n";
	return 0;
}

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

#define pb push_back
#define ll long long
int mo =  1e9+7;
// int dp[1000][1000];
using namespace std;


int main(int argc, char const *argv[])
{
	// ios::sync_withss_stdio(false);
	// cin.tie(0);
	// cout.tie(0);

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

	long long dp[n+1][k+1];
	long long sumarr[n+1][k+1];
	memset(dp, 0 , sizeof(dp));

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

	dp[0][0] = 1;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= k; ++j)
		{
			if (j == 0)
			{
				sumarr[i-1][j] = dp[i-1][j]%mo;
			} 
			else{
				sumarr[i-1][j] = ((sumarr[i-1][j-1])%mo + (dp[i-1][j])%mo)%mo; 
			}
		}
		for (int j = 0; j <= k; ++j)
		{
			// int sum = 0;
			// for (int k = 0; k <= min(j , a[i-1]); ++k)
			// {
			// 	sum += dp[i-1][j-k];
			// }
			int t = min(j, a[i-1]);
			if(t == j){
				dp[i][j] = sumarr[i-1][j];
			}
			else{
				dp[i][j] = (sumarr[i-1][j] - sumarr[i-1][j-t-1]+ mo)%mo;

			}
		}
	}

	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= k; ++j)
	// 	{
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	printf("%lld\n", dp[n][k]);
	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= k; ++j)
	// 	{
	// 		printf("%lld ", sumarr[i][j]);
	// 	}
	// 	printf("\n");
	// }
}




Measured memory_bytes: 158080
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		while (true) {
			int n = s.nextInt();
			int m = s.nextInt();

			if (n == 0 && m == 0)
				break;

			int[] taro = new int[n];
			int[] hana = new int[m];

			for (int i = 0; i < n; i++)
				taro[i] = s.nextInt();

			for (int i = 0; i < m; i++)
				hana[i] = s.nextInt();

			Arrays.sort(taro);
			Arrays.sort(hana);

			int a = -1, b = -1;
			boolean flag = false;

			outer: for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					int temp;
					temp = taro[i];
					taro[i] = hana[j];
					hana[j] = temp;

					int sumt = 0;
					int sumh = 0;

					for (int x = 0; x < n; x++)
						sumt += taro[x];

					for (int y = 0; y < m; y++)
						sumh += hana[y];

					if (sumt == sumh) {
						a = hana[j];
						b = taro[i];
						flag = true;
						break outer;
					}

					temp = taro[i];
					taro[i] = hana[j];
					hana[j] = temp;
				}
			}

			System.out.println(flag ? a + " " + b : -1);
		}

		s.close();
	}
}

Measured memory_bytes: 21236
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////

struct Edge {
    int to;
    ll cost;
};

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

    vector<vector<Edge>>  e(n);
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        ll w;
        cin >> w;
        e[u].emplace_back(Edge{v, w});
        e[v].emplace_back(Edge{u, w});
    }

    // 根を0（1）とする
    // 根から偶数なら0
    // 根から奇数なら1
    vector<int> ans(n);
    ans[0] = 0;

    auto rec = [&](auto &&rec, int now, int before, int c) -> void {
        for (int i = 0; i < e[now].size(); i++) {
            int next = e[now][i].to;
            ll cost = (e[now][i].cost+c)%2;
            if (next == before) continue;
            ans[next] = cost;
            // cout << next << ' ' << ans[next] << endl;
            rec(rec, next, now, cost);
        }
    };

    rec(rec, 0, -1, 0);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8960