akhauriyash/Code-Regression huggingface dataset:
W, H, D = 100.0, 50.0, 30.0

EPS = 1e-10
class Tank
  def initialize(board, tap)
    @time = 0.0

    @tap = tap
    @block = make_block(board)
  end

  def make_block(board)
    board.each_cons(2).map{|b1, b2| Block.new(b1.x, b2.x, b1.height, b2.height)}
  end

  def height(x)
    @block.find{|b| b.in?(x)}.water_height
  end

  def pour(time)
    difference = time - @time
    @tap.each do |t|
      block = @block.find{|b| b.in?(t.x)}
      pour_run(block, t.stream * difference)
    end
    @time = time
  end

  def pour_run(block, volume)
    overflow = block.pour(volume)
    return if @block.size == 1
    return unless overflow
    i = @block.index(block)
    if (block.left_height < block.right_height)
      left = @block[i - 1]
      left = merge(left, block) if (left.water_height - left.right_height).abs < EPS
      pour_run(left, overflow)
    elsif (block.left_height > block.right_height)
      right = @block[i + 1]
      right = merge(block, right) if (right.water_height - right.left_height).abs < EPS
      pour_run(right, overflow)
    end
  end

  def merge(left, right)
    i = @block.index(left)
    water = left.water + right.water
    block = Block.new(left.left_x, right.right_x, left.left_height, right.right_height)
    block.pour(water)
    @block.delete(right)
    @block[i] = block
  end
end

class Block
  attr_reader :left_x, :right_x, :left_height, :right_height
  attr_reader :volume, :water

  def initialize(left_x, right_x, left_height, right_height)
    @left_x, @right_x, @left_height, @right_height = [left_x, right_x, left_height, right_height].map(&:to_f)
    @volume = (@right_x - @left_x) * [@left_height, @right_height].min * D
    @water = 0.0
  end

  def in?(x)
    (@left_x ... @right_x).include?(x)
  end

  def water_height
    @water / (@right_x - @left_x) / D
  end

  def pour(volume)
    if @water + volume > @volume
      overflow = volume - (@volume - @water)
      @water = @volume
      return overflow
    end
    @water += volume
    nil
  end
end

class Tap
  attr_reader :x, :stream
  def initialize(x, stream)
    @x, @stream = [x, stream].map(&:to_f)
  end
end

class Board
  attr_reader :x, :height
  def initialize(x, height)
    @x, @height = [x, height].map(&:to_f)
  end
end

gets.to_i.times do
  board = Array.new
  board << Board.new(0, H)
  board.push( *gets.to_i.times.map{Board.new(*gets.split)} )
  board << Board.new(W, H)

  tap = gets.to_i.times.map{Tap.new(*gets.split)}

  tank = Tank.new(board, tap)

  list = Array.new
  check = Hash.new{Array.new}
  gets.to_i.times do
    p, t = gets.split.map(&:to_f)
    list << [p, t]
    check[t] = check[t] + [p]
  end
  result = Hash.new{|h, k| h[k] = Hash.new}
  list.transpose.last.sort.uniq.each do |t|
    tank.pour(t)
    check[t].each do |p|
      result[t][p] = tank.height(p)
    end
  end
  list.each do |p, t|
    p result[t][p]
  end
end

Measured memory_bytes: 6140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
  int n,m,x;
  vector<int> A;
  cin >> n >> m >> x;
  int cntto0=0,cnttoN=0;
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    A.push_back(a);
    if(a<x) cntto0++;
    else cnttoN++;
  }
  cout << min(cntto0,cnttoN) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,m,i,j;
  char x[999],y[999],tmp;
  for(;scanf("%d",&n),n;)
    {
      for(i=0;i<n;i++)
	{
	  scanf(" %c",&x[i]);
	  scanf(" %c",&y[i]);
	  //printf("i=%d ",i);
	}
      scanf("%d",&m);
      //      puts("test");
      for(j=0;j<m;j++)
	{
	  scanf(" %c",&tmp);
	  for(i=0;i<n;i++)
	    {
	      if(x[i]==tmp)
		{
		  putchar(y[i]);
		  break;
		}
	    }
	  if(i==n)
	    putchar(tmp);
	}
      puts("");
    }
  exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int table[1112];

int main(){
    REP(i, 1112){
        table[i] = i*i*i;
    }

    int z;
    while(std::cin >> z, z){
        int res = 0;
        for(int x=1;x<z;x++){
            int y = std::distance(table, std::upper_bound(table, table+1112, table[z]-table[x])) - 1;
            if(y != -1){
                res = std::max(res, table[x]+table[y]);
            }
        }

        std::cout << table[z] - res << std::endl;
    }
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void)
{
  int A, B;
  scanf("%d %d", &A, &B);
  if(A >= 13){
    printf("%d\n", B);
  }
  else if(A <= 5){
    printf("0\n");
  }
  else{
    printf("%d\n", B/2);
  }
  return 0;
}


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

int color = 1;
const int MAXH = 300;
const int MAXW = 300;
vector<vector<int>> checked(MAXH,vector<int>(MAXW,-1));
vector<string> s(MAXH);

int countstraw(int hmin, int hmax, int wmin, int wmax){
	int res = 0;
	for(int i = hmin; i <= hmax; i++){
		for(int j = wmin; j <= wmax; j++){
			if(s[i][j]=='#') res++;
		}
	}
	return res;
}
void dfs(int nowstraw, int hmin, int hmax, int wmin, int wmax){
	// nowstraw = countstraw(hmin,hmax,wmin,wmax);
	if(nowstraw==1){
		// 色を塗って終了
		for(int i = hmin; i <= hmax; i++){
			for(int j = wmin; j <= wmax; j++){
				checked[i][j] = color;
			}
		}
		color++;
		return;
	}
	else{
		// 縦に切る
		for(int i = hmin; i < hmax; i++){
			int nextstraw = countstraw(hmin,i,wmin,wmax);
			if(nextstraw < nowstraw && nextstraw > 0){
				dfs(nextstraw,hmin,i,wmin,wmax);
				dfs(nowstraw-nextstraw,i+1,hmax,wmin,wmax);
				return;
			}
		}
		
		// 縦がだめなら横に切る
		for(int i = wmin; i < wmax; i++){
			int nextstraw = countstraw(hmin,hmax,wmin,i);
			if(nextstraw < nowstraw && nextstraw > 0){
				dfs(nextstraw,hmin,hmax,wmin,i);
				dfs(nowstraw-nextstraw,hmin,hmax,i+1,wmax);
				return;
			}
		}
	}
}


int main(){
	int h,w,k;
	cin >> h >> w >> k;
	
	rep(i,h) cin >> s[i];
	
	dfs(k,0,h-1,0,w-1);
	
	rep(i,h){
		rep(j,w){
			cout << checked[i][j] << " ";
		}
		cout << endl;
	}
	

	return 0;
}


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

#define ll long long int
#define endl '\n'
const long long inf=1e18;
ll dp[105][100005];
ll val[105],wt[105];
void testCase()
{
   
    //ll t; cin>>t; while(t--)
    {
       ll n,w;
       cin>>n>>w;

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


       

       for(int i=0;i<=n;i++)
       {
           for(int j=0;j<=100000;j++)
           {
               
               if(j==0)
               {
                   dp[i][j]=0;
               }
               else
               if(i==0)
               {
                   dp[i][j]=inf;
               }
               else
               {
                   if(j>=val[i-1])
                   {
                       dp[i][j]=min(dp[i-1][j-val[i-1]]+wt[i-1],dp[i-1][j]);
                   }
                   else{
                       dp[i][j]=dp[i-1][j];
                   }
               }
               
           }
       }
       ll ans=-1;
       for(int i=100000;i>=0;i--)
       {
           if(dp[n][i]<=w)
           {
               ans=i;
               break;
           }
       }
       cout<<ans;
    }      
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

vector<int> G[100100];
vector<int> K;
vector<int> ANS;
int N, M;

void topology(){
    queue<int> S;
    REP(i,N){
        if(K[i] == 0){
            ANS[i] = 0;
            S.push(i);
        }
    }

    while(!S.empty()){
        int v = S.front();
        S.pop();
        for(auto&& n : G[v]){
            K[n]--;
            if(K[n] == 0){
                ANS[n] = v+1;
                S.push(n);
            }
        }
    }
}

int main(){
    cin >> N >> M;
    K.resize(N, 0);
    REP(i,N+M-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        K[b] += 1;
    }

    ANS.resize(N);

    topology();

    REP(i,N){
        cout << ANS[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7040
def main():
    N = int(input())
    X = []
    for _ in range(N):
        x, y = map(int,input().split())
        X.append([x,y])

    d = [[(0,0)] * N for _ in range(N)]
    b = set()
    for i in range(N):
        for j in range(N):
            d[i][j] = (X[i][0] - X[j][0], X[i][1] - X[j][1])
            if not (X[i][0] - X[j][0] == 0 and X[i][1] - X[j][1] == 0):
                b.add((X[i][0] - X[j][0], X[i][1] - X[j][1]))
    
    cnt = 0
    for a in b:
        tmp = 0
        for i in range(N):
            tmp += d[i].count(a)

        cnt = max(cnt, tmp)
    
    print(1 + (N - 1 - cnt))
            


if __name__ == "__main__":
    main()

Measured memory_bytes: 73836
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll rec(ll n, ll x) {
    if (n == 0) return 1;
    if (x == 1) return 0;
    ll len = (1LL << (n + 1)) - 3;
    ll Pnum = (1LL << n) - 1;
    if (x <= len + 1) return rec(n - 1, x - 1);
    else if (x == len + 2) return Pnum + 1;
    else if (x <= (len + 1) * 2) return Pnum + 1 + rec(n - 1, x - len - 2);
    else return Pnum * 2 + 1;    
}

int main(void) {
    ll n, x;
    cin >> n >> x;

    cout << rec(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
A = []
for i in range(3):
  A.append(list(map(int,input().split())))
N = int(input())
for a in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if b == A[i][j]:
        A[i][j]=0

for i in range(3):
  if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
    print("Yes");exit()

for j in range(3):
  if A[0][j]==0 and A[1][j]==0 and A[2][j]==0:
    print("Yes");exit()
    
if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
  print("Yes");exit()
if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes");exit()
print("No")

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++) scanf("%u",&A[i]);

  
  for(i=0;i<=VMAX+1;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX+1;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }


  for(i=1;i<=n;i++){
    printf("%u",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
  return 0;
}




Measured memory_bytes: 9568
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  ll sum(0);
  vector<int> amari(N,0);
  for(int i(0);i<N;i++){
    if(A[i] == 0) continue;
    if(A[i]%2==0){
      if(i != 0 && amari[i-1] == 1){
        amari[i] = 1;
      }
      sum += A[i]/2;
    } else{
      if(i != 0 && amari[i-1] == 1) sum += A[i]/2+1;
      else{
        sum += A[i]/2;
        amari[i] = 1;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4580
#include<stdio.h>
int isPrime(int a){
	int i;
	if(a==1) return 0;
	if(a==2) return 1;
	if(a%2==0) return 0;
	for(i=3;i*i<=a;i=i+2){
		if(a%i==0) return 0;
	}
	return 1;
}

int main(){
	int n;
	scanf("%d",&n);
	while(isPrime(n)==0) n++;
	printf("%d",n);
}

Measured memory_bytes: 128
n = int(input())
r=[0]*(n+1)
c=[0]*(n+1)
for i in range(n):
    r[i+1], c[i+1] = map(int, input().split())

dp = [[float('inf') for i in range(n+1)] for j in range(n+1)]

for i in range(n+1):
    dp[i][i] = 0

# print("")
for l in range(2, n+1):
    for i in range(1, n-l+2):
        # print("l=", l, "i=", i)
        tmp_list = [r[i] * c[i+l-1] * r[j+1] + dp[i][j] + dp[j+1][i+l-1] for j in range(i, i+l-1)]
        dp[i][i+l-1] = min(tmp_list)

print(dp[1][n])


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

using namespace std;

int main() {
	int n;
	cin >> n;
	string str_n = to_string(n);
	int a = 0;
	if (str_n[0] == '1') {
		a += 900;
	} else {
		a += 100;
	}
	if (str_n[1] == '1') {
		a += 90;
	} else {
		a += 10;
	}
	if (str_n[2] == '1') {
		a += 9;
	} else {
		a += 1;
	}

	cout << a << endl;
	return 0;
}

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

int64_t	isqrt(int64_t N)
{
	int64_t	q;
	for (q = 1; q * q <= N; ++q);
	return q - 1;
}

int	digit(int64_t num)
{
	int	d = 1;
	while (num /= 10)
		++d;
	return d;
}

int	main()
{
	int64_t	N;
	cin >> N;
	int64_t	root = isqrt(N);
	for (int64_t A = root; A > 0; --A) {
		if (N % A == 0) {
			cout << digit(N / A) << endl;
			return 0;
		}
	}
	return 0;
}



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

int main() {
  int S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (S % 10 == 1) cnt++;
    S /= 10;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
n = int(input())
aa = list(map(int,input().split()))
ma = max(aa)
ans = 0

if len(aa) == 2:
 print(ma,min(aa))
else:
 if ma % 2 == 0:
  for a in aa:
   if abs(ma//2 - a) <= abs(ma//2 - ans):
    ans = a
 else:
  for a in aa:
   if min([abs(ma // 2 - a),abs(ma //2 - a + 1)  ]) <= min([abs(ma // 2 - ans),abs(ma //2 - ans + 1)  ]):
    ans = a
 print( "{} {}".format(ma,ans))

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int dp[105][100005];

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

    int n;
    cin >> n;

    vector< int > v;
    v.pb(1);
    int t = 6;
    while( t <= n ) {
        v.pb(t);
        t *= 6;

    }
    t = 9;
    while( t <= n ) {
        v.pb(t);
        t *= 9;

    }

    for( int i = 0; i < v.size(); ++i ) {
        for( int j = 1; j <= n; ++j ) {
            if( i == 0 ) {
                dp[i][j] = dp[i][j - 1] + 1;

            } else {
                if( j >= v[i] ) {
                    dp[i][j] = min(dp[i - 1][j], dp[i][j - v[i]] + 1);

                } else {
                    dp[i][j] = dp[i - 1][j];

                }
            }
        }
    }
    cout << dp[v.size() - 1][n] << endl;
    return 0;
}



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

#define ll long long
int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  
  X = abs(X);
  
  ll step;
  
  if (D < (X+ K-1)/K) {
    if (X > 0) {
      cout << (X-D*K) << endl;
      return 0;
    } else {
      cout << abs(X + D*K) << endl;
      return 0;
    }
  }
  
  step = (X - (X % D)) / D;
  if ((step - K) % 2 == 0) {
    cout << X % D << endl;
  } else {
    cout << abs(X % D - D) << endl;
  }

  
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
using namespace std;
const int N = 2e5 + 5;
int n;
struct BIT {
    int a[N] = {};
    void add(int x, int val) {
        for (int i = x; i <= n; i += lowbit(i))
            a[i] += val;
    }
    int sum(int x) {
        int ret = 0;
        for (int i = x; i; i -= lowbit(i))
            ret += a[i];
        return ret;
    }
} b[2];
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int q;
    cin >> n >> q;
    long long ans = 1ll * (n - 2) * (n - 2);
    b[0].add(1, 1);
    b[1].add(1, 1);
    while (q--) {
        int opt, x;
        cin >> opt >> x;
        opt--;
        int h = b[opt].sum(n + 1 - x);
        ans -= n - h - 1;
        int f = b[opt ^ 1].sum(h + 1);
        if (f < n + 1 - x) b[opt ^ 1].add(h + 1, n + 1 - x - f);
        // for (int i = 1; i <= n; i++)
        //     cout << b[0].sum(i) << " \n"[i == n];
        // for (int i = 1; i <= n; i++)
        //     cout << b[1].sum(i) << " \n"[i == n];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int, int>;
const int MX = 100005;
int n, h, w, a, r[MX], c[MX];
P pr[MX];
long long ans;
int p[MX*2], m[MX*2];
int find(int x){return p[x] ? p[x] = find(p[x]) : x;}
void uni(P pr){
	int f, x, y, z;
	tie(z, f) = pr;
	x = find(r[f]); y = find(h+c[f]);
	if(!m[x] || !m[y]) ans += z;
	if(x != y){
		if(p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		m[x] = max({m[x], m[y]});
	}else if(!m[x]) m[x] = z;
	
}

int main(){
	scanf("%d%d%d", &n, &h, &w);
	rep(i,n){
		scanf("%d%d%d", r+i, c+i, &a);
		pr[i] = P(a,i);
	}
	sort(pr,pr+n, greater<P>());
	rep(i,n) uni(pr[i]);
	printf("%lld\n", ans);
}

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

int main() {
	long long n,c;cin>>n>>c;
	long long x[n],v[n],vsr[n],vsl[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>v[i];
	}
	long long maxkr[n];
	vsr[0]=v[0];
	maxkr[0]=vsr[0]-x[0];
	for(int i=1;i<n;i++){
		vsr[i]=vsr[i-1]+v[i];
		long long kr=vsr[i]-x[i];
		if(maxkr[i-1]<kr){
			maxkr[i]=kr;
		}else{
			maxkr[i]=maxkr[i-1];
		}
	}
	long long maxkl[n];
	vsl[n-1]=v[n-1];
	maxkl[n-1]=v[n-1]-(c-x[n-1]);
	for(int i=n-2;i>=0;i--){
		vsl[i]=vsl[i+1]+v[i];
		long long kl=vsl[i]-(c-x[i]);
		if(maxkl[i+1]<kl){
			maxkl[i]=kl;
		}else{
			maxkl[i]=maxkl[i+1];
		}
	}
	long long maxkr2[n],maxkl2[n];
	maxkr2[0]=v[0]-2*x[0];
	for(int i=1;i<n;i++){
		vsr[i]=vsr[i-1]+v[i];
		long long kr=vsr[i]-2*x[i];
		if(maxkr2[i-1]<kr){
			maxkr2[i]=kr;
		}else{
			maxkr2[i]=maxkr2[i-1];
		}
	}
	maxkl2[n-1]=v[n-1]-2*(c-x[n-1]);
	for(int i=n-2;i>=0;i--){
		vsl[i]=vsl[i+1]+v[i];
		long long kl=vsl[i]-2*(c-x[i]);
		if(maxkl2[i+1]<kl){
			maxkl2[i]=kl;
		}else{
			maxkl2[i]=maxkl2[i+1];
		}
	}
	long long ans=0;
	if(ans<maxkr[n-1])ans=maxkr[n-1];
	if(ans<maxkl[0])ans=maxkl[0];
	for(int i=0;i<n-1;i++){
		long long value=maxkr2[i]+maxkl[i+1];
		if(ans<value)ans=value;
		value=maxkr[i]+maxkl2[i+1];
		if(ans<value)ans=value;
	}
	cout<<ans<<endl;
//	for(int i=0;i<n;i++){
//		cout<<maxkr[i]<<endl;
//	}


	return 0;
}

Measured memory_bytes: 6528
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<ll> p;
    p.pb(a*c);
    p.pb(a*d);
    p.pb(b*c);
    p.pb(b*d);
    sort(p.rbegin(),p.rend());
    cout << p[0] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int sum = 0;
	bool can = false;
	for (int i = a; i < a * b; i += a) {
		if (i % b == c) {
			can = true;
			break;
		}
	}
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
} 

Measured memory_bytes: 380
#include <cstdio>
int main()
{
    int w;
    while (scanf("%d",&w)&&w!=-1) {
        int res;
        if (w<=10) res=1150;
        else if (w>10&&w<=20) res=1150+(w-10)*125;
        else if (w>20&&w<=30) res=1150+1250+(w-20)*140;
        else res=1150+1250+1400+(w-30)*160;
        printf("%d\n",4280-res);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 10000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int ans[MAX + 5];

int getV(int i, int j, int k) {
    return i * i + j * j + k * k + i * j + i * k + k * j;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, i, j, k, val;
    cin >> n;
    for (i = 1; i <= 100; ++i) {
        for (j = 1; j <= 100; ++j) {
            for (k = 1; k <= 100; ++k) {
                val = getV(i, j, k);
                if (val <= n) {
                    ans[val]++;
                }
            }
        }
    }
    for (i = 1; i <= n; ++i) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (max(a, c) < min(b, d)) cout << min(b, d) -  max(a, c)<< endl;
    else cout << 0 << endl;
    return 0; 
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 01.01.2020 20:48:47       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].emplace_back(y, 1);
    g[y].emplace_back(x, 2);
  }
  long long ans = 0;
  vector<int> col(n, -1);
  for (int st = 0; st < n; st++) {
    if (col[st] != -1) {
      continue;
    }
    vector<int> que(1, st);
    col[st] = 0;
    bool eq = false;
    for (int b = 0; b < (int) que.size(); b++) {
      for (auto& p : g[que[b]]) {
        int to = p.first;
        int nc = (col[que[b]] + p.second) % 3;
        if (col[to] == -1) {
          que.push_back(to);
          col[to] = nc;
        } else {
          if (col[to] != nc) {
            eq = true;
          }
        }
      }
    }
    if (eq) {
      int sz = (int) que.size();
      ans += (long long) sz * sz;
      continue;
    }
    vector<int> cc(3, 0);
    for (int x : que) {
      cc[col[x]] += 1;
    }
    if (*min_element(cc.begin(), cc.end()) == 0) {
      int ed = 0;
      for (int x : que) {
        ed += (int) g[x].size();
      }
      ans += ed / 2;
      continue;
    }
    ans += (long long) cc[0] * cc[1] + (long long) cc[1] * cc[2] + (long long) cc[2] * cc[0];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    ll cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o') cnt++;
    }
    ll more=15-s.size();
    if(more+cnt>=8) cout<<"YES"<<endl;
    else cout<<"NO";
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      println(Array.fill(N * (N - 1) / 2)(sc.nextInt).sum / (N - 1))
      solve(sc)
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 102444
//
// Created by watemus on 05.06.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

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

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

template<typename T>
using uset = unordered_set<T>;

template<typename T1, typename T2>
using umap = unordered_map<T1, T2>;

#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
constexpr ld PI = acos(-1);

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
    int n;
    cin >> n;
    int tn = n;
    int ans = 0;
    for (int div = 2; div * div <= n; div++) {
        int cnt = 0;
        while (tn % div == 0) {
            tn /= div;
            cnt++;
        }
        int cur = 0;
        for (int i = 1; cnt - i >= 0; i++) {
            cnt -= i;
            cur++;
        }
        ans += cur;
    }
    cout << ans + (tn != 1) << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}



Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
constexpr int MOD = 1e9 + 9;
using matrix = vector<vector<ll>>;

ll h, w, n;
int cs = 1;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

vector<ll> prod(const matrix &a, const vector<ll> &x)
{
    vector<ll> ret(w, 0);
    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < w; j++)
        {
            ret[i] += a[i][j] * x[j] % MOD;
            ret[i] %= MOD;
        }
    }
    return ret;
}

matrix modmul(matrix const &l, matrix const &r)
{
    matrix ret(l.size(), vector<ll>(r[0].size()));
    for (int i = 0; i < l.size(); i++)
    {
        for (int k = 0; k < r.size(); k++)
        {
            for (int j = 0; j < r[0].size(); j++)
            {
                ret[i][j] += l[i][k] * r[k][j] % MOD;
                ret[i][j] %= MOD;
            }
        }
    }
    return ret;
}

matrix modpow(matrix x, ll n)
{
    matrix ret(x.size(), vector<ll>(x.size(), 0));
    for (int i = 0; i < x.size(); i++)
        ret[i][i] = 1;
    while (n)
    {
        if (n & 1)
        {
            ret = modmul(ret, x);
        }
        x = modmul(x, x);
        n /= 2;
    }
    return ret;
}

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

    while (cin >> w >> h >> n, h || w || n)
    {
        cout << "Case " << cs << ": ";
        cs++;
        bool f = false;
        set<ll> st = {h};
        map<ll, vector<ll>> mp;
        for (int i = 0; i < n; i++)
        {
            ll x, y;
            cin >> y >> x;
            if (x == 1)
                continue;
            st.insert(x);
            y--;
            mp[x].push_back(y);
            if (x == h && y == w)
            {
                f = true;
            }
        }
        if (f)
        {
            cout << 0 << endl;
            continue;
        }
        vector<vector<ll>> id(w, vector<ll>(w, 0));
        for (int i = 0; i < w; i++)
        {
            id[i][i] = 1;
            if (i)
                id[i][i - 1] = 1;
            if (i + 1 < w)
                id[i][i + 1] = 1;
        }
        vector<ll> x(w, 0);
        x[0] = 1;
        ll pre = 1;
        for (auto v : st)
        {
            x = prod(modpow(id, v - pre), x);
            for (auto y : mp[v])
                x[y] = 0;
            pre = v;
        }
        cout << x[w - 1] << endl;
    }
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(a) begin(a),end(a)
#define INF 999999999
#define debug(x) cerr << #x << ":" << x << '\n'
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int  ui;

int main() {
	int n;
	cin >> n;
	if(n <= 111) cout << 111 << '\n';
	else if(n <= 222) cout << 222 << '\n';
	else if(n <= 333) cout << 333 << '\n';
	else if(n <= 444) cout << 444 << '\n';
	else if(n <= 555) cout << 555 << '\n';
	else if(n <= 666) cout << 666 << '\n';
	else if(n <= 777) cout << 777 << '\n';
	else if(n <= 888) cout << 888 << '\n';
	else cout << 999 << '\n';
}

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

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> x;
    for(int i = 0; i < 5; i++)
    {
        ll tmp;
        cin >> tmp;
        x.push_back((n - 1)/tmp + 1);
    }
    
    cout << *max_element(x.begin(), x.end()) + 4 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) ((long long)x%modulo)


int main(){
	int A,B,C;
	cin>>A>>B>>C;
	map<int,int> m;
	m[A]++;m[B]++;m[C]++;
	if(m[5]==2&&m[7]==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int main() {
	string str;
	
	while (cin>>str) {
		string ans;
		
		int n = (int)str.sz;
		for_(i, 0, n) {
			if (str[i]=='@') {
				i++;
				int len = str[i]-'0';
				i++;
				for_(j, 0, len) {
					ans += str[i];
				}
			} else {
				ans += str[i];
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll d; cin >> d;

    vector<ll> c(26);
    for (ll i = 0; i < 26; ++i) {
        cin >> c[i];
    }

    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; ++i) {
        for (ll j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    vector<ll> t(d);
    for (ll i = 0; i < d; ++i) {
        ll idx = 0;
        ll mx = 0;
        for (ll j = 0; j < 26; ++j) {
            if (mx < s[i][j]) {
                mx = s[i][j];
                idx = j;
            }
        }
        t[i] = idx;
    }

    vector<ll> score(d, 0);
    vector<vector<ll>> last(d, vector<ll>(26, 0));

    auto re_score = [&](ll start) {
        for (ll i = start; i < d; ++i) {
            score[i] = (i - 1 >= 0 ? score[i - 1] : 0) + s[i][t[i]];

            if (i - 1 >= 0) {
                last[i] = last[i - 1];
            } else {
                for (ll j = 0; j < 26; ++j) {
                    last[0][j] = 0;
                }
            }

            last[i][t[i]] = i + 1;

            ll j = i + 1;

            for (ll k = 0; k < 26; ++k) {
                score[i] -= c[k] * (j - last[i][k]);
            }
        }
    };

    re_score(0);

    ll mx_score = score[d - 1];
    for (int r = 0; r < 10; ++r) {
        for (ll i = 0; i < d; ++i) {
            for (ll j = 0; j < 26; ++j) {
                ll tmp = t[i];

                t[i] = j;
                re_score(i);

                if (mx_score >= score[d - 1]) {
                    t[i] = tmp;
                    re_score(i);
                } else {
                    mx_score = score[d - 1];
                }
            }
        }
    }

    for (ll i = 0; i < d; ++i) {
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(a==0)
		return b;
	else
		return gcd(b%a,a);
}
int a[201][201];
int main()
{
	int n,sum=0;
	cin>>n;
/*	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			a[i][j]=gcd(i,j);
			cout<<i<<" "<<j<<" "<<a[i][j]<<endl;
		}*/
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			a[i][j]=gcd(i,j);
			for(int k=1;k<=n;k++)
			{
				sum+=gcd(a[i][j],k);
			}
		}

	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 3792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));
    bool f;
    if(y < 2019){
        f = false;
    }else if(y == 2019){
        if(m <= 4){
            f = false;
        }else{
            f = true;
        }
    }else{
        f = true;
    }
    cout << (f? "TBD":"Heisei") << endl;
    return 0;
}


Measured memory_bytes: 256
// epsを付ける方法
// A<B A<B-epsとする
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	long double a,b,c;
	cin >> a >> b >> c;
	long double eps = 1.0e-14;
	if(sqrt(a)+sqrt(b)+eps<sqrt(c)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int H[N];
  int A[M],B[M];
  for(int i=0;i<N;i++) cin >> H[i];
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
  }
  vector<int> R[N+1];
  for(int i=0;i<M;i++){
    R[A[i]-1].push_back(B[i]);
    R[B[i]-1].push_back(A[i]);
  }
  int count = 0;
  for(int i=0;i<N;i++){
    int check=0;
    for(vector<int>::iterator j=R[i].begin();j!=R[i].end();j++){
      if(H[*j-1]>=H[i]){
        check=1;
      }
    }
    if(check==0) {
      count ++;
    }
  }
  cout << count;
}


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

struct UnionFind{
    vector<int> tree;

    UnionFind(int n): tree(n+1, -1) {};
    int root(int i) {return tree[i] < 0 ? i : tree[i] = root(tree[i]); }

    bool unite(int i, int j){
        i = root(i), j = root(j);
        if(i == j) return false;
        tree[i] += tree[j], tree[j] = i;
        return true;
    }
};


int main(){
    int n, m;

    while(cin >> n >> m, n != 0){
        vector<vector<int> > graph(n);

        bool flag = true;
        UnionFind uf(n);

        for(int i = 0;i < m;i++){
            int a, b;
            cin >> a >> b;
            a--;
            b--;
            graph[a].push_back(b);
            graph[b].push_back(a);
            flag = (flag && uf.unite(a, b));
        }

        for(int i = 0;i < n;i++){
            if(graph[i].size() >= 3){
                flag = false;
                break;
            }
        }

        if(flag){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 6708
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int gcd (long long int a, long long int b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

long long int lcd(long long int a, long long int b) {
    return (a * b) / gcd(a, b);
}

long long int fact(long long int N) {
    long long int result = 1;
    while(N > 0) {
        result = result * N % MOD;
        N--;
    }
    return result;
}

long long int cnk(long long int n, long long int k) {
    return fact(n) / (fact(k) * fact(n - k));
}

long long int binpow(long long int a, long long int n) {
    long long int result = 1;
    while(n != 0) {
        if(n % 2 == 1) {
            result = result * a % MOD;
        }
        a = a * a % MOD;
        n /= 2;
    }
    return result;
}

long long int powermod(long long int base, long long int power) {
    if (power == 0) {
        return 1;
    }
    else {
        long long int cur = powermod(base, power / 2);
        cur = cur * cur;
        cur = cur % MOD;
        if (power % 2 == 1)
            cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

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

    long long int a, b, x;
    long double V, y;
    cin >> a >> b >> x;
    V = a * a * b;
    if(x <= V / 2.0) {
        cout << fixed << setprecision(7) << atan(b * b * a / (2.0 * x)) * (180.0/3.141592653589793238463);
    }
    else {
        //y = (2.0 * x - V) / (a * a);
        V -= 2*x - V;
        x -= 2*x - V;
        cout << fixed << setprecision(7) << atan(V / (a*a*a)) * (180.0/3.141592653589793238463);
    }
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
l = []
for i, k in enumerate(a):
    if k == m:
        l.append(i)

if len(l) == 1:
    for i in range(n):
        if i != l[0]:
            print(m)
        else:
            a[l[0]] = 0
            print(max(a))
else:
    for i in range(n):
        print(m)


Measured memory_bytes: 20456
import sys


def main():
    n = int(sys.stdin.readline())
    notices = []
    for i in range(n):
        notices.append(tuple(map(int, sys.stdin.readline().split())))
    buildings = [[[0] * 10 for i in range(3)] for j in range(4)]
    for b, f, r, v in notices:
        buildings[b-1][f-1][r-1] += v
    separator = '####################'
    for index, building in enumerate(buildings):
        for floor in building:
            print(' ' + ' '.join(map(str, floor)))
        if index != len(buildings)-1:
            print(separator)
    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 5612
#include <cstdio>
#include <cmath>

int main()
{
    int a, b, C;

    scanf("%d %d %d", &a, &b, &C);

    printf("%lf\n", (double)1/2*a*b*sin(C*M_PI/180.0));
    printf("%lf\n", (double)a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180.0)));
    printf("%lf\n", (double)b*sin(C*M_PI/180.0));
    return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll A,B,N;

int main(){
    cin>>A>>B>>N;

    ll ans=A*min(N,B-1)/B;

    cout<<ans<<endl;
}

Measured memory_bytes: 3620
n, m = map(int, input().split())

ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m >= 3:
        ans = m - 2
elif n >= 3 and m == 1:
    ans = n - 2
elif n >= 3 and m >= 3:
    ans = (n-2) * (m-2)

print(ans)


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T >> Q;
	if (T[0] == Q[2] && T[1] == Q[1] && T[2] == Q[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	
}

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

#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007

using namespace std;

int main() {
    ios
    ll n; cin>>n;
	cout<<n*n*n;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

void solve(int w, int h, vector<vector<int> > block)
{
	vector<vector<bool> > check(h+2, vector<bool>(w+2, false));
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			if(block[i][j] == 0 || check[i][j])
				continue;

			int left = INT_MAX;
			int right = INT_MIN;
			queue<pair<int,int> > queueYX;
			queueYX.push(make_pair(i, j));
			while(!queueYX.empty()){
				int y = queueYX.front().first;
				int x = queueYX.front().second;
				queueYX.pop();
				if(check[y][x])
					continue;
				check[y][x] = true;
				if(y == h || block[y+1][x] != block[y][x] && block[y+1][x] != 0){
					left = min(left, x);
					right = max(right, x);
				}
				if(block[y+1][x] == block[y][x])
					queueYX.push(make_pair(y+1, x));
				if(block[y][x-1] == block[y][x])
					queueYX.push(make_pair(y, x-1));
				if(block[y][x+1] == block[y][x])
					queueYX.push(make_pair(y, x+1));
			}

			queueYX.push(make_pair(i, j));
			int totalX = 0;
			int num = 0;
			vector<vector<bool> > currCheck(h+2, vector<bool>(w+2, false));
			while(!queueYX.empty()){
				int y = queueYX.front().first;
				int x = queueYX.front().second;
				queueYX.pop();
				if(currCheck[y][x])
					continue;
				currCheck[y][x] = true;
				totalX += x;
				++ num;
				if(block[y-1][x] != 0)
					queueYX.push(make_pair(y-1, x));
				if(block[y+1][x] == block[y][x])
					queueYX.push(make_pair(y+1, x));
				if(block[y][x-1] == block[y][x])
					queueYX.push(make_pair(y, x-1));
				if(block[y][x+1] == block[y][x])
					queueYX.push(make_pair(y, x+1));
			}

			if(left*num - num/2 >= totalX || totalX >= right*num + num/2){
				cout << "UNSTABLE" << endl;
				return;
			}
		}
	}

	cout << "STABLE" << endl;
}

int main()
{
	for(;;){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0)
			break;

		vector<vector<int> > block(h+2, vector<int>(w+2, 0));
		for(int i=1; i<=h; ++i){
			for(int j=1; j<=w; ++j){
				char tmp;
				cin >> tmp;
				if(tmp != '.')
					block[i][j] = tmp - '0';
			}
		}

		solve(w, h, block);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (2147483647)
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)

void solve()
{
    ll sum=0;
    ll n;cin>>n;ll x=1;
    while(n){
        sum+=x;
        n/=2;x*=2;
    }
    cout<<sum<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		if (s[i] == '+') {
			ans++;
		}
		else if (s[i] == '-') {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(n >= 1 && n <= 9 && m >= 1 && m <= 9) cout << n*m;
    else cout << -1;


    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
int main() {
	int n;
	cin >> n;
	cout << fixed << setprecision(10) << double((n + 1) / 2) / n << endl;
}


Measured memory_bytes: 256
Imports System.Collections.Generic
Public Class Program
  Shared Sub Main()
    Dim nq As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim n As Long = nq(0)
    Dim q As Long = nq(1)
    Dim vs(0 To n - 2, 0 To 1) As Long
    For i As Long = 0 To n - 2
      Dim ab As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
      vs(i, 0) = ab(0)
      vs(i, 1) = ab(1)
    Next
    Dim op(0 To q - 1, 0 To 1) As Long
    Dim x(0 To n - 1) As Long
    For i As Long = 0 To q - 1
      Dim px As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
      op(i, 0) = px(0)
      op(i, 1) = px(1)
      x(op(i, 0) - 1) += op(i, 1)
    Next
    Dim edge(0 To n - 1) As List(Of Long)
    Dim ans(0 To n - 1) As Long
    Dim visited(0 To n - 1) As Boolean
    For i As Long = 0 To n - 1
      edge(i) = New List(Of Long)()
      ans(i) = 0
      visited(i) = False
    Next
    For i As Long = 0 To n - 2
      edge(vs(i, 0) - 1).Add(vs(i, 1) - 1)
      edge(vs(i, 1) - 1).Add(vs(i, 0) - 1)
    Next
    Dim targetRoot As List(Of Long) = New List(Of Long)()
    targetRoot.Add(0)
    While targetRoot.Count > 0
      Dim r As List(Of Long) = New List(Of Long)(targetRoot)
      targetRoot.Clear()
      For Each i As Long In r
        ans(i) += x(i)
        visited(i) = True
        For Each j As Long In edge(i)
          If Not visited(j) Then
            ans(j) = ans(i)
            targetRoot.Add(j)
          End If
        Next
      Next
    End While
    Console.WriteLine(String.Join(Of Long)(" ", ans))
  End Sub
End Class

Measured memory_bytes: 67180