akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#define ll long long int
using namespace std;
const ll SUB=1000000007;
int main()
{
	int n;
	cin>>n;
	int *t=new int[n];
	int *a=new int[n];
	for(int i=0;i<n;i++)cin>>t[i];
	for(int i=0;i<n;i++)cin>>a[i];
	if(t[n-1]!=a[0])
	{
		cout<<"0"<<endl;
		return 0;
	}
	ll ans=1;
	for(int i=1;i<n-1;i++)
	{
		if(t[i]!=t[i-1]&&a[i]!=a[i+1]&&t[i]!=a[i])
		{
			cout<<"0"<<endl;
			return 0;
		}
		if(t[i]!=t[i-1]&&t[i]>a[i])
		{
			cout<<"0"<<endl;
			return 0;
		}
		if(a[i]!=a[i+1]&&a[i]>t[i])
		{
			cout<<"0"<<endl;
			return 0;
		}
		if(t[i]!=t[i-1]||a[i]!=a[i+1])continue;
		ans*=(min(t[i],a[i])%SUB);
		ans%=SUB;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
from sys import stdin


X,N=[int(x) for x in stdin.readline().rstrip().split()]
P=[int(x) for x in stdin.readline().rstrip().split()]
l=[i for i in range(-1,102) if i not in P]
abslist = list(map(lambda a:abs(a-X),l))
print(l[abslist.index(min(abslist))])


Measured memory_bytes: 9188
#include <stdio.h>

int main() {
	int a,b,c,n;
	scanf("%d%d%d", &a,&b,&c);
	if(b/a>=c){
		n=c;
	}else{
		n=b/a;
	}
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 128
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const { r } = parseLines(lines);
  return (3 * r * r).toString();
};

const parseLines = (lines: string[]) => {
  const r = +lines[0];
  const obj = { r };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 11596
#include<stdio.h>

static const int N=100;

int min(int x,int y)
{return x < y ? x : y; }

int main()
{
  int i,j,k,l;
  int n,p[N+1],m[N+1][N+1];

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

  for(i=1;i<=n;i++)
  {
    m[i][i]=0;
  }
  for(l=2;l<=n;l++)
  {
    for(i=0;i<=n-l+1;i++)
    {
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++)
      {
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2104
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    cin>>n>>x>>y;
    ll b[n];
    mem(b, 0);
    if(x>y)swap(x, y);
    for(i=1; i<n; i++){
        for(j=i+1; j<=n; j++){
            h = min(abs(i-j), abs(x-i)+1+abs(y-j));
            b[h]++;
        }
    }
    for(i=1; i<n; i++)cout<<b[i]<<endl;
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define mod 1000000007
#define lli long long
#define fi first
#define se second
#define pb emplace_back
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(x,v) for(auto x : v)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MAXC 200005
// %

int main(int argc, char **argv)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size(), ans = MAXC;
    for (int i = 0; i < n-m+1; i++) {
        int temp = 0;
        for (int j = 0; j < m; j++) {
            if (s[i+j] != t[j]) {
                temp++;
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[][][][] data = new int[4][3][10][1];

		for (int i = 0; i < a; i++) {
			int building = sc.nextInt();
			int floor = sc.nextInt();
			int room = sc.nextInt();
			int person = sc.nextInt();
			data[building-1][floor-1][room-1][0] += person;
		}

		for (int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" " + data[i][j][k][0]);
				}
				System.out.println();
			}
			if(i != 3)
			System.out.println("####################");
		}
	}

}

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

int main() {
  ll N;
  cin >> N;
  ll sum = 0;
  ll j = 0;
  for (ll i = 1; i <= N; i++) {
    sum += i;
    if (sum >= N) {
      j = i;
      break;
    }
  }
  
  for (ll i = 1; i <= j; i++) {
    if (i == sum - N) continue;
    else cout << i << endl;
  }
}

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

#define endl '\n'
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f

typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
const int N = (1<<16) + 5;
 
ll a[20][20], sum[N], dp[N];

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

  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin >> a[i][j];
    }
  }
  //pre processing
  dp[0]=0;
  for(int p=1; p<(1<<n); p++){
    for(int i=0; i<n; i++){
      if(!(p&(1<<i))) continue;
      for(int j=i+1; j<n; j++){
        if(!(p&(1<<j))) continue;
        sum[p]+=a[i][j];
      }
    }
    dp[p]=-linf;
  }

  for(int p=0; p<(1<<n); p++){
    vector <ll> rem;
    for(int i=0; i<n; i++){ 
      if(!(p&(1<<i)))rem.pb(i);
    }
    for(int k=1; k<(1<<rem.size()); k++){
      int choice=0;
      for(int i=0; i<rem.size(); i++) if(k&(1<<i)) choice^=(1<<rem[i]); 
      dp[p+choice]=max(dp[p+choice], dp[p] + sum[choice]);
    }
  }

  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n; cin>>n;
    rep(i,n){
        int a,b; cin>>a>>b;
        int x = a*b;
        int l = -1, r = 1145141919;
        while(abs(r - l)>1){
            int mid = (r + l)/2;
            if(mid * mid <= x) l = mid;
            else r = mid;
        }
        int ans = 0;
        if(l * l == x) ans--;
        if(a == b) ans++;
        ans += (2 * l - 1) -1;
        if(l*r <x) ans++;
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 256
m, d = list(map(int, input().split()))
cnt = 0
if d<20:
    print(0)
else:
    for j in range(1, m+1):
        for i in range(20, d+1):
            if (i%10)*(i//10) == j and i%10 >1:
                cnt += 1
    print(cnt)

Measured memory_bytes: 3060
def main():
    N, X = (int(i) for i in input().split())
    ans = 0

    def dfs(n, x, ans):
        a = 1 + 4*(2**(n-1) - 1)
        if n == 1:
            return 1
        elif (n-1) >= x:
            return 0
        elif x == a//2:
            return 1 + 2*(2**(n-2) - 1)
        elif x == a//2 + 1:
            return 1 + 2*(2**(n-2) - 1) + 1
        elif x < a//2:
            ans += dfs(n-1, x-1, ans)
        elif x > a//2 + 1:
            ans += dfs(n-1, x-(a//2)-1, ans) + (1 + 2*(2**(n-2) - 1) + 1)
        return ans

    print(dfs(N+1, X, ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import collections
H, W = map(int, input().split())
S = [input() for _ in range(H)]

def f(sx, sy, gx, gy):
    q = collections.deque()
    q.append((sx, sy))
    dist = [[float("inf") for w in range(W)] for h in range(H)]
    dist[sx][sy] = 0
    dx = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    while len(q) != 0:
        h, w = q.popleft()
        d = dist[h][w]
        for x, y in dx:
            h2 = h + y
            w2 = w + x
            if h2 >= 0 and h2 < H and w2 >= 0 and w2 < W:
                if S[h2][w2] == "." and dist[h2][w2] == float("inf"):
                    dist[h2][w2] = d+1
                    q.append((h2, w2))
    return dist[gy][gx]
count = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            count += 1
ans = f(0, 0, W-1, H-1)
if ans == float('inf'):
    print(-1)
else:
    print(H*W-ans-1-count)

Measured memory_bytes: 3436
h,w = map(int, input().split())
grid = [list(input()) for i in range(h)]
for i in reversed(range(h)):
    if all(j=="." for j in grid[i]):
        grid.pop(i)
for i in reversed(range(w)):
    if all(j[i]=="." for j in grid):
        for j in grid:
            j.pop(i)
for i in grid:
    print("".join(i))

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 1e12;
	REP(i, 200000)
	{
		int ca = x - i;
		int cb = y - i;
		int cc = i * 2;
		chmax(ca, 0);
		chmax(cb, 0);
		chmax(cc, 0);
		chmin(ans, ca * a + cb * b + cc * c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
a1 = []
a2 = []
n.times do
  t = (gets.chomp.split.map(&:to_i))
  a1.push(t[0])
  a2.push(t[1])
end
a2.sort!
a1.sort!{|a,b|b<=>a}
now = 0
ans = 0

def c(f,a1,a2)
now = 0
we = a1[0]
sa = a2[0]
i = 0
ans = 0
ff = f
while(sa < we)
  i += 1 if f ^ ff
  if f
    ans += (now - sa).abs
    now = sa
    we = a1[i]
  else
    ans += (now - we).abs
    now = we
    sa = a2[i]
  end
  f = !f
end
ans += now.abs
end
p [c(false,a1,a2),c(true,a1,a2)].max



Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int main(void){
	int input[5];
	for(int i=0;i<5;i++){
		cin >> input[i];
	}
	for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
			if(input[i]>input[j]){
			int tmp = input[i];
			input[i] = input[j];
			input[j] = tmp;
			}
		}
	}
	for(int i=0;i<4;i++){
		cout << input[i] << " ";
	}
	cout << input[4] << endl;
	return 0;
}

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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M;
lld a[300002],sum[300002],tmp[300002];
lld d[300002],d1[300002],d2[300002];
struct data{
	lld a,b;
	data(){}
	data(lld a,lld b):a(a),b(b){}
};
struct CHT{
	int cr,cf;
	data line[300002];
	void init(){
		cr = cf = -1;
	}
	lld ccw(data x,data y,data z){
		return (x.a*y.b+y.a*z.b+z.a*x.b)-(x.b*y.a+y.b*z.a+z.b*x.a);
	}
	lld f(int num,lld x){
		return line[num].a*x+line[num].b;
	}
	lld getv(lld x){
		while(cf && f(cf-1,x) >= f(cf,x)) cf--;
		return f(cf,x);
	}
	void add(lld a,lld b){
		while(cr > 0 && ccw(line[cr-1],line[cr],data(a,b)) <= 0) cr--;
		cf = min(cf,cr);
		if(cr != cf) return;
		cr++; cf++;
		line[cr] = {a,b};
	}
}cht;

void setting(lld D[]){
	cht.init();
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	cht.add(0,0);
	for(lld i=1; i<=N; i++){
		D[i] = max(cht.getv(i)+(i*(i+1)/2)-sum[i],D[i-1]);
		cht.add(-i,D[i]+sum[i]+(i*(i-1)/2));
	}
}

void divide(int s,int e){
	if(s == e){
		//d[s] = max(d1[s-1]+d2[s+1]+1-a[s],d[s]);
		return;
	}
	int m = (s+e)>>1;
	lld res;
	divide(s,m);
	divide(m+1,e);
	cht.init();
	for(lld i=s-1; i<m; i++){
		cht.add(-i,d1[i]+sum[i]+(i*(i-1)/2));
	}
	for(lld i=m+1; i<=e; i++){
        tmp[i] = cht.getv(i)+(i*(i+1)/2)-sum[i]+d2[i+1];
	}
	res = -Linf;
	for(lld i=e; i>=m+1; i--){
        res = max(res,tmp[i]);
        d[i] = max(res,d[i]);
	}
	cht.init();
	for(lld i=m+2; i<=e+1; i++){
		cht.add(-i,d2[i]-sum[i-1]+(i*(i+1)/2));
	}
	res = -Linf;
	for(lld i=s; i<=m; i++){
        res = max(cht.getv(i)+(i*(i-1)/2)+sum[i-1]+d1[i-1],res);
		d[i] = max(res,d[i]);
	}
}

int main(){
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
        scanf("%lld",&a[i]);
        d[i] = -a[i];
	}
	setting(d1);
	reverse(a+1,a+N+1); setting(d2); reverse(a+1,a+N+1); reverse(d2+1,d2+N+1);
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	divide(1,N);
	scanf("%d",&M);
	for(int i=1; i<=M; i++){
		int x; lld y;
		scanf("%d %lld",&x,&y);
		printf("%lld\n",max(d1[x-1]+d2[x+1],d[x]+a[x]-y));
	}

	return 0;
}


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

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

    int cnt = 0;
    rep(i, s.size()) if(s[i] == 'o') cnt++;
    
    if(8-cnt <= 15-s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static boolean memo[];
	static int ans, min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		min = gcd(a[0], a[1]);
		for (int i = 2; i < n; i++) {
			min = gcd(min, a[i]);
		}
		System.out.println(min);
	}

	private static int gcd(int m, int n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}


Measured memory_bytes: 49464
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n, k;
  cin >> n >> k;
  
  int num = 1;
  for (int i=0; i<n; i++) {
    if (num * 2 <= num + k) num *= 2;
    else num += k;
  }
  
  cout << num << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,A,B;
    cin >> N >> A >> B;

    if(abs(A-B)%2==1 and A%2!=B%2) cout << "Borys" << endl;
    else if(abs(A-B+1)%2==1 and (N-A)%2==(N-B)%2) cout << "Alice" << endl;
    else cout << "Draw" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n;
  cout << 3 * n*n << endl;




  return 0;
}


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

#define Bye return 0
const int MAX = 1e6+1;

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

    int c[4];
    for (int i=0; i<4; i++)
        c[i] = 0;

    while(t--){
        string str; cin>>str;

        if(str == "AC") c[0]++;
        else if(str == "WA") c[1]++;
        else if(str == "TLE") c[2]++;
        else if(str == "RE") c[3]++;
    }

    printf("AC x %d\n", c[0]);
    printf("WA x %d\n", c[1]);
    printf("TLE x %d\n", c[2]);
    printf("RE x %d\n", c[3]);

    Bye;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  for(int a:A) {
    if(a%2) {
      continue;
    }
    if(a%3 && a%5) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
goukei = b[0..n-1].reverse
arr = []
all = 0
goukei.each do |i|
    all += i
    arr << all
end
goukei = arr.reverse
ans = 0
goal = 0
(0..n-1).each do |i|
    ans += a[i]
    an = ans + goukei[i]
    goal = [goal,an].max
end
puts goal


Measured memory_bytes: 14284
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
int A[100000];
int tmp[100000];

int isOK(int first)
{
	memcpy(tmp, A, sizeof(tmp));

	tmp[0] -= (first * 2) / 2;
	tmp[N - 1] -= (first * 2) / 2;

	for (int i = 1; i < N; i++)
	{
		tmp[i] -= tmp[i - 1];
	}

	return tmp[N - 1] <= 0;
}
signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int left = -1;
	int right = 1000000000;
	while (right - left > 1)
	{
		int mid = left + (right - left) / 2;
		if (isOK(mid))
			right = mid;
		else
			left = mid;
	}
	
	int ans = right;

	cout << (ans * 2);
	A[0] -= ans;
	for (int i = 1; i < N; i++)
	{
		cout << " " << (A[i - 1] * 2);
		A[i] -= A[i - 1];
	}
	cout << endl;
}











Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>> N >> K;
  vector<int> vec(N);
  for(int i=0;i< N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
   long long sum =0;
  for(int i=0;i<N-K;i++){
    sum += vec.at(i);
  }   
 cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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

int main() {
    char x;
    cin >> x;
    if (isupper(x)){
        cout << 'A' << endl;
    }else {
        cout << 'a' << endl;
    }
}



Measured memory_bytes: 3588
A=input().split()
i=0
for j in range(len(A)):
    if A[i]=="+":
        r=int(A[i-2])+int(A[i-1])
        A[i]=r
        del(A[i-2])
        del(A[i-2])
        i-=2
    if A[i]=="-":
        r=int(A[i-2])-int(A[i-1])
        A[i]=r
        del(A[i-2])
        del(A[i-2])
        i-=2
    if A[i]=="*":
        r=int(A[i-2])*int(A[i-1])
        A[i]=r
        del(A[i-2])
        del(A[i-2])
        i-=2
    i+=1

print(r)



Measured memory_bytes: 5596
import math

A, B, H, M = map(int, input().split())
H_mod = H % 12
hour_angle = 30 * H_mod + 30 * M / 60
min_angle = 6 * M
theta = abs(hour_angle - min_angle)
theta = min(theta, 360 - theta)
C = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(theta))
print(C ** (1 / 2))

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

#define INF 1000000007
//#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using namespace std;

inline int toInt(string s){
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T> inline string toString(T x){
    ostringstream sout;
    sout << x;
    return sout.str();
}

int main(void){

    int n;
    cin >> n;

    bool flg = false;
    ll ans = 0;
    FOR(i,0,n){
        ll a;
        cin >> a;
        if(flg)a++;
        if(a==1)flg = false;
        else if(a%2==1)flg = true;
        else flg = false;
        ans += a/2;
    }

    cout << ans << endl;

    return 0;
}


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

struct Card {
    char suit,value;
};

void trace(struct Card C[], int N){
    for(int i=0;i<N;i++){
        if(i>0) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

void BubbleSort(struct Card C[],int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i;j--){
            if(C[j].value<C[j-1].value){
                Card t = C[j]; C[j]=C[j-1];C[j-1]=t;
            }
        }
    }
}

void SelectionSort(struct Card C[], int N) {
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(C[j].value<C[minj].value){
                minj=j;
            }
        }
        Card t = C[i]; C[i]=C[minj];C[minj]=t;
    }
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    cin>>N;
    for(int i=0;i<N;i++) cin>>C1[i].suit>>C1[i].value;
    for(int i=0;i<N;i++) C2[i]=C1[i];
    
    BubbleSort(C1,N);
    SelectionSort(C2,N);
    
    trace(C1,N);
    cout << "Stable" << endl;
    trace(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main()
{
    int n=read();
    for(int i=n;i<=999;i++){
        int as=i/100;
        int qw=i/10%10;
        int zx=i%10;
        if(as==qw&&qw==zx){
            printf("%d\n",i);return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//使う使わないの2パターンのみ

ll dp[60][60][3000];
ll N,A;
int main(){
    cin>>N>>A;
    FOR(i, 0, 60) FOR(j, 0, 60) FOR(k, 0, 3000) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    FOR(i, 0, N){
        int x;cin>>x;
        FOR(j, 0, N){
            FOR(k, 0, N*50+1){
                if(dp[i][j][k]==0) continue;
                //使わない場合
                dp[i+1][j][k] += dp[i][j][k];
                //使う場合
                if(k+x>N*50) continue;
                dp[i+1][j+1][k+x] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    FOR(i, 1, N+1){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 84608
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000005,M=1e9+7;
int fac[N],inv[N],n,f[N],g[N],num,ans;
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
int C(int x,int y){
	if (x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
signed main(){
	scanf("%lld",&n);
	fac[0]=inv[0]=1;
	for (int i=1;i<N;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	g[0]=1;
	for (int i=1;i<=n;i++){
		g[i]=f[i-1];
		f[i]=(f[i-1]+g[i-1]*2)%M;
	}
	for (int i=1;i<=n;i++)(f[i]*=C(n,i))%=M;
	for (int i=1;i<=n;i++)(num+=f[i])%=M;num=ksm(num,M-2);
	for (int i=1;i<=n;i++)(ans+=f[i]*ksm(3*n*i%M,M-2))%=M;
	printf("%lld\n",ans*num%M);
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a)FOR(i,0,a)
	
using namespace std;
const ll MOD=1e9+7;
typedef pair<int,int> P;

int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  REP ( i,n){
    int a;
    cin>>a;
    x=max(x,a);
  }
  REP ( i,m){
    int a;
    cin>>a;
    y=min(y,a);
  }
  cout <<(y-x<1 ? "War":"No War")<<endl ;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int INF=1e+9;
int n,ans;
int a[21];


void dfs(int diff,int k);

int main(){
	
	while(cin>>n&&n!=0){

		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		ans=INF;
		dfs(0,0);
		cout<<ans<<endl;
	}
	
}

void dfs(int diff,int k){
	if(k==n){
		ans=min(ans,abs(diff));
	}else{
		dfs(diff+a[k],k+1);
		dfs(diff-a[k],k+1);
	}
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int h1, h2, k1, k2, a, b, c, d;
int p1, p2;

int main()
{
	in >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	p1 += a * h1 + c * (h1 / 10);
	p1 += b * h2 + d * (h2 / 20);
	p2 += a * k1 + c * (k1 / 10);
	p2 += b * k2 + d * (k2 / 20);
	if (p1 > p2) out << "hiroshi" << std::endl;
	else if (p1 < p2) out << "kenjiro" << std::endl;
	else out << "even" << std::endl;
	return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int q, h, s, d, n; cin >> q >> h >> s >> d >> n;
    int v1 = min({4*q, 2*h, s});
    int v2 = min(2*v1, d);
    cout << (long long)n/2 * v2 + (n%2) * v1 << endl;
}


Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Data.List
import           Data.IntMap.Strict             ( IntMap )
import qualified Data.IntMap.Strict            as IntMap

main :: IO ()
main = do
  [n, k, q] <- map (read :: String -> Int) . words <$> getLine
  as        <- replicateM q $ (read :: String -> Int) <$> getLine
  mapM_ (putStrLn . ans . (> 0)) $ solve n k q as
 where
  ans True  = "Yes"
  ans False = "No"
  cnt :: [Int] -> [(Int, Int)]
  cnt as' = IntMap.toDescList $ IntMap.fromListWith (+) (zip as' [1, 1 ..])
  solve n k q as = go [] n (cnt as)
   where
    go acc 0      _                  = acc
    go acc member []                 = go (k - q : acc) (member - 1) []
    go acc member ((a, c) : answers) = if member == a
      then go (k - q + c : acc) (member - 1) answers
      else go (k - q : acc) (member - 1) ((a, c) : answers)


Measured memory_bytes: 51580
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

void can_take(int n, vector<vector<int>> &dp, vector<int> const& w) {
  repr(i, n, 0) repr(j, n-i, 0) {
    int left = j, right = i + j; // [left, right]
    int len = i + 1;

    repr(k, right, left) {
      if (dp[left][k] && dp[k+1][right]) dp[left][right] = true;
    }

    if (len == 2 && abs(w[left] - w[right]) < 2) dp[left][right] = true;

    if (dp[left][right]) {
      left --, right ++;
      while (left >= 0 && left < n && right >= 0 && right < n) {
        if (abs(w[left] - w[right]) < 2) dp[left][right] = true;
        else break;
        left --, right ++;
      }
    }
  }
}


int main() {
  ll n;

  while (cin >> n && n != 0) {
    vector<int> w(n);
    repr(i, n, 0) cin >> w[i];
    vector<vector<int>> dp1(n, vector<int>(n, 0));
    vector<vector<int>> dp2(n, vector<int>(n));

    can_take(n, dp2, w);
    /*for (auto it : dp2) {
      for (auto itr : it) {
        cerr << itr << " ";
      }
      cerr << endl;
    }*/

    repr(i, n, 0) repr(j, n, i+1) {
      if (dp2[i][j]) dp1[i][j] = j - i + 1;
    }

/*    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cerr << dp1[i][j] << " ";
      }
      cerr << endl;
    }*/

    repr(i, n, 0) repr(j, n, i) repr(k, j, i) {
      dp1[i][j] = max(dp1[i][j], dp1[i][k] + dp1[k+1][j]);
    }
    cout << dp1[0][n-1] << endl;
  }
}


Measured memory_bytes: 3640
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();
        int area=a*b;
        int length=(a+b)*2;
        System.out.println(area+" "+length);
        sc.close();
    }
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] += 32;
  cout << s;
}

    


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(int, input().split()))

mx = 0
mn = 0
cnt = 0

a = [0] * 8
for i in range(N):
    if 1 <= aN[i] < 400:
        a[0] = 1
    elif 400 <= aN[i] < 800:
        a[1] = 1
    elif 800 <= aN[i] < 1200:
        a[2] = 1
    elif 1200 <= aN[i] < 1600:
        a[3] = 1
    elif 1600 <= aN[i] < 2000:
        a[4] = 1
    elif 2000 <= aN[i] < 2400:
        a[5] = 1
    elif 2400 <= aN[i] < 2800:
        a[6] = 1
    elif 2800 <= aN[i] < 3200:
        a[7] = 1
cnt = sum(a)

kami = len([i for i in aN if 3200 <= i])
if kami == 0:
    print(str(cnt) + " " + str(cnt)) 
else:
    if cnt == 0:
        mn = 1
        mx = kami
    else:
        mn = cnt
        mx = cnt + kami
    print(str(mn) + " " + str(mx))

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

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define mx			2050
#define inf			1e9
#define pb			push_back
#define mod			1234567

using namespace std;

typedef long long ll;

int n, m;
int can[100050];
int ball[100050];

int main(){
	int x, y;
	scanf("%d %d", &n, &m);
	repn(i, n) ball[i] = 1;
	can[1] = 1;
	rep(i, m){
		scanf("%d %d", &x, &y);
		ball[x]--;
		ball[y]++;
		if(can[x] == 1) can[y] = 1;
		if(ball[x] == 0) can[x] = 0;
	}
	int ret = 0;
	repn(i, n) ret += can[i];
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

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

    long long ans = 1001001001001;
    for (long long i=1; i<=sqrt(n); i++) {
        if (n%i != 0) continue;
        long long j = n/i;
        ans = min(ans, i+j-2);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ac=0,wa=0,tle=0,re=0;
	string s;
	while(n--)
	{
		cin>>s;
		if(s=="AC")
		ac++;
		else if(s=="TLE")
		tle++;
		else if(s=="WA")
		wa++;
		else if(s=="RE")
		re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}
	


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int l, r;
  cin >> l >> r;
  if(r-l >= 2019){
    cout << 0 << endl;
    return 0;
  }
  int mod = 2019;
  l %= mod;
  r %= mod;
  if(l >= r) r += mod;
  int ans = 1001001001;
  for(int i = l+1; i <= r; i++){
    for(int j = l; j < i; j++){
      int tmp = i*j % mod;
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    double L;
    cin >> L;
    cout << setprecision(25) << fixed;
    cout << pow(L/3,3) << endl;
}
    


Measured memory_bytes: 384
import io.StdIn.{readInt, readLine}
object Main extends App {
  val Array(n, d) = readLine.split(" ").map(_.toInt)
  val xys = for (_ <- 1 to n) yield readLine.split(" ").map(_.toLong)

  val ranges = xys.map(xy => math.sqrt(xy.head*xy.head + xy.last*xy.last))
  val result = ranges.count(_ <= d)
  println(result)
}

Measured memory_bytes: 69104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    vector <int> d(n);
    for(int i=0;i<n;++i) cin >> d[i];
    sort(d.begin(),d.end());
    int s=d[n/2-1];
    int e=d[n/2];
    int ans=e-s;
    cout << ans << endl;
}



Measured memory_bytes: 640
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

void p(const vec<Int> &a) {
    Int n = a.size();
    for (Int i = 0; i < n - 1; i++) {
        cout << setw(3) << a[i];
    }
    cout << setw(3) << a[n - 1] << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    Int n, k;
    cin >> n >> k;
    vec<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n <= k) {
        for (Int i = 0; i < n - 1; i++) {
            cout << n << ' ';
        }
        cout << n << endl;

        return 0;
    }

    for (Int i = 0; i < k; i++) {
        bool iscon = false;
        vec<Int> aa(n);
        for (Int j = 0; j < n; j++) {
            Int L, R;
            L = clamp(j - a[j], (Int)0, (Int)n);
            R = clamp(j + a[j], (Int)0, (Int)(n - 1));

            aa[L]++;
            if (R + 1 < n) {
                aa[R + 1]--;
            }
        }
        for (Int j = 1; j < n; j++) {
            aa[j] += aa[j - 1];
        }

        a = aa;

        for (Int j = 0; j < n; j++) {
            if (a[j] < n) {
                iscon = true;
                break;
            }
        }

        if (!iscon) {
            a.assign(n, n);
            break;
        }
    }

    for (Int i = 0; i < n - 1; i++) {
        cout << a[i] << ' ';
    }
    cout << a[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 6332
def main():
    N = int(input())
    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
              41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    prime_factors = {k: 0 for k in primes}

    for i in range(1, N+1):
        for p in primes:
            while i % p == 0:
                prime_factors[p] += 1
                i //= p
    retval = 0
    patterns = [[75], [25, 3], [15, 5], [5, 5, 3]]
    memo = []
    for pattern in patterns:
        stack = [(pattern, {})]
        while len(stack):
            remaining, used = stack.pop()
            if len(remaining) == 0:
                if used not in memo:
                    retval += 1
                    memo.append(used)
                continue
            for p in primes:
                if prime_factors[p] >= remaining[0] - 1 and p not in used:
                    next_used = {k: used[k] for k in used}
                    next_used[p] = remaining[0] - 1
                    stack.append((remaining[1:], next_used))
    print(retval)


if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{
  int N, L;
  cin >> N >> L;
  vector< string > S(N);
  for(int i = 0; i < N; i++) cin >> S[i];
  sort(begin(S), end(S));
  cout << accumulate(begin(S), end(S), string()) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define INF 10000000
using namespace std;
struct data{
    int x,y;
};
int H,W,N;
int ans[1001][1001];
char field[1001][1001];
long long int cou;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main(){
    data s;
    cin>>H>>W>>N;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>field[i][j];
            if(field[i][j]=='S'){
                s.x=i,s.y=j;
            }
        }

    }
    for(int l=1;l<=N;l++){
        data g;
        g.x=1,g.y=1;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                ans[i][j]=INF;
                if(field[i][j]==l+'0'){
                    g.x=i,g.y=j;
                    //cout<<l+'0'<<endl;
                }
            }
        }
        ans[s.x][s.y]=0;
        queue <data> q;
        q.push(s);
        while(!q.empty()){
            data now;
            now=q.front();
            q.pop();
            if(now.x==g.x&&now.y==g.y)break;
            int nex,ney;
            for(int i=0;i<4;i++){
                nex=now.x+dx[i];
                ney=now.y+dy[i];
                if(nex>=0&&nex<H&&ney>=0&&ney<W&&ans[nex][ney]==INF&&field[nex][ney]!='X'){
                    data nowne;
                    nowne.x=nex,nowne.y=ney;
                    q.push(nowne);
                    ans[nex][ney]=ans[now.x][now.y]+1;
                }
            }
        }
        cou+=ans[g.x][g.y];
        s=g;
    }
    cout<<cou<<endl;
return 0;
}

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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpii vector<pair<int,int> >
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mci map<char,int>  
#define pii pair<int,int>
#define pdd pair<double,double>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18
#define sp(x,y) fixed<<setprecision(y)<<x

void get_it_done(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
int gcd(int a, int b){ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void swap(int &a,int &b){
	a^=b;b^=a;a^=b;
}
const int N = 1e5+5;
int dp[N][105];
int n;
int maxWeight;
int weights[105],values[105];   

int build(int req,int idx){
    // cout<<idx<<endl;
    // deb(req);
    if(req<0) 
        return inf;
    if(req==0)
    {
        return 0;
    }
    if(idx==n) 
        return inf;
    // deb(dp[req][idx]);
    if(dp[req][idx]!=-1)
        return dp[req][idx];
    // cout<<1<<endl;
    int ans = inf;
    ans = min(build(req,idx+1),weights[idx]+build(req-values[idx],idx+1));
    return dp[req][idx] = ans;
}

int solve(){
    rloop(i,N-1,0){
        // deb(dp[i][0]);
        int temp = build(i,0);
        if(temp<=maxWeight){
            // cout<<temp<<endl;
            return i;
        }
    }
    return 0;
}

int32_t main(){
	get_it_done();
    int t=1;
    // cin >> t;
    while (t--){
        cin>>n>>maxWeight;
        loop(i,0,n){
            cin>>weights[i]>>values[i];
        }
        memset(dp,-1,sizeof(dp));
        cout<<solve()<<endl;

    }
}


Measured memory_bytes: 82304