akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

using namespace std;

int h, w;
bool purple[500][500];
bool red[500][500];
bool blue[500][500];

int main()
{
	memset(purple,false,sizeof(purple));
	memset(red, false, sizeof(red));
	memset(blue, false, sizeof(blue));
	scanf("%d %d", &h, &w);
	for (int y = 0; y < h; ++y)
	{
		char tmpstr[501];
		scanf("%s", tmpstr);
		for (int x = 0; x < w; ++x)
		{
			purple[x][y] = ('#' == tmpstr[x]);
		}
	}

	for (int y = 1; y < h - 1; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			red[x][y] = true;
		}
	}

	
	for (int x = 0; x < w; ++x)
	{
		blue[x][0] = blue[x][h - 1] = true;
	}

	bool lastisblock = false;
	for (int x = 0; x < w; ++x)
	{
		bool isblock = false;
		for (int y = 0; y < h; ++y)
		{
			if (purple[x][y])isblock = true;
		}
		if (isblock)
		{
			if (lastisblock)
			{
				for (int y = 0; y < h; ++y)
				{
					if (purple[x][y])
					{
						red[x][y] = true;
						blue[x][y] = true;
					}
				}
				isblock = false;
			}
			else
			{
				for (int y = 0; y < h; ++y)
				{
					if (purple[x][y])
					{
						red[x][y] = true;
						blue[x][y] = true;
					}
					else
					{
						red[x][y] = false;
						blue[x][y] = true;
					}
				}
			}
		}
		lastisblock = isblock;
	}

	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			printf("%c",red[x][y] ? '#' : '.');
		}
		printf("\n");
	}
	printf("\n");
	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			printf("%c", blue[x][y] ? '#' : '.');
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 1408
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 55;

long long size[MAX];
long long patties[MAX];

long long recurse(int level, long long rem) {
    if (rem == 0)
        return 0;
    if (level == 0)
        return 1;
    if (rem >= size[level])
        return patties[level];
    
    long long ans = 0;
    rem--;
    ans += recurse(level - 1, min(size[level - 1], rem));
    rem -= size[level - 1];
    if (rem > 0) {
        ans++;
        rem--;
    }
    if (rem >= 0) {
        ans += recurse(level - 1, min(size[level - 1], rem));
        rem -= size[level - 1];
    }
    
    return ans;
}

int main(void) {
	// in = fopen("D.in", "rt");
	
	size[0] = 1, patties[0] = 1;
	for (int i = 1; i < MAX; i++) {
	    size[i] = 1 + size[i - 1] + 1 + size[i - 1] + 1;
	    patties[i] = patties[i - 1] + 1 + patties[i - 1];
    }
	
	int n;
    long long x;
    fscanf(in, "%d %lld", &n, &x);
    fprintf(out, "%lld\n", recurse(n, x));
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i32 n, x;
  scanf ("%" SCNi32 "%" SCNi32, &n, &x);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i64 *sum = (i64 *) calloc (n + 1, sizeof (i64));
  for (i32 i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  i64 ans = (i64) 5 * n * 1000000000 + (i64) 2 * n * x;
  for (i32 i = 1; i <= n; ++i) {
    i64 local = (i64) x * (n + i);
    for (i32 j = n, k = 1; j > 0 && local < ans; j -= i, ++k) {
      i32 b = j >= i ? j - i : 0;
      local += (sum[j] - sum[b]) * (k == 1 ? 5 : 2 * k + 1);
    }
    if (local < ans) {
      ans = local;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


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

int main()
{
	int a,b;
	cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
 
using namespace std;
 
#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
 
 
int main(){
  ll n;
  cin >> n;
  ll l0 = 2;
  ll l1 = 1;
  ll l2;
  rep(i, n-1){
    l2 = l1 + l0;
    l0 = l1;
    l1 = l2;
  }
  if(n==1){
    cout << l1 << endl;
    return 0;
  }
  cout << l2 << endl;
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define mod 1000000007
#define mx 100003
#define ss second
#define ff first
#define ld long double
#define pii pair<int, int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS;
    int n;
    cin >> n;
    int a[n + 2], dp[n + 2];
    memset(dp, 0, sizeof(dp));
    rep(i,1,n) cin >> a[i];
    dp[2] = abs(a[1] - a[2]);
    rep(i,3,n)
    {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
  ll a, b;
  cin >> a >> b;
  if(!(a % b)) {
    cout << "-1" << endl;
  } else {
    cout << a * (b-1) << endl;
  }

	return 0;
}

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

int main()
{
	int h[5];

	cin >> h[0];

	while (h[0]) {
		for (int i = 1; i < 5; i++)
			cin >> h[i];

		int f[3] = { 0, 0, 0 }, r[5] = { 0, 0, 0, 0, 0 };

		for (int i = 0; i < 5; i++)
			f[h[i] - 1] = 1;
		
		if ((f[0] + f[1] + f[2]) % 2 == 1)
			for (int i = 0; i < 5; i++)
				r[i] = 3;
		else {
			for (int j = 0; j < 3; j++) {
				if (!f[j]) {
					for (int i = 0; i < 5; i++) {
						if (h[i] == (j + 1) % 3 + 1)
							r[i] = 1;
						else
							r[i] = 2;
					}
				}
			}
		}

		for (int i = 0; i < 5; i++)
			cout << r[i] << endl;

		cin >> h[0];
	}

	return 0;
}


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

#define N_Max 200001
#define A_Max 1000001
using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long k,n;
  long long res;
  long long i,j;
  
  cin>>k>>n;
  long long a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  
  res=a[0]+k-a[n-1];
  for(i=1;i<n;i++){
    res=max(res,a[i]-a[i-1]);
  }

  res=k-res;
  
  cout<<res<<endl;
  
  return 0;
  
}      

Measured memory_bytes: 5188
H,W = map(int,input().split())
a = []
for i in range(H):
  a.append(input())

yoko = []
tate = []

for i in range(H):
  if a[i] != "."*W:
    yoko.append(i)
for i in range(W):
  c = 0
  for j in range(H):
    if a[j][i] == "#":
      c = 1
  if c == 1:
    tate.append(i)

for y in yoko:
  s = ""
  for t in tate:
    s += a[y][t]
  print(s)  

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

int main()
{
    int n, h, w;
    cin >> n >> h >> w;

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        ans += !!(1LL * (a / h) * (b / w));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll sum[n+1]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        sum[i+1] = sum[i] + a[i];
    }
    ll low = -1, up = 1e18;
    while(up-low>1){
        ll mid = (up+low)/2;
        ll cnt = 0;
        for(int i=0;i<n;i++){
            cnt += a+n - lower_bound(a,a+n,mid-a[i]);
        }
        if(cnt >= m) low = mid;
        else up = mid;
    }
    ll cnt = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll c = a+n - lower_bound(a,a+n,low-a[i]);
        cnt += c;
        ans += a[i] * c + sum[n] - sum[n-c];
        //cerr << i << " " << a[i] << " " << c << " " << endl;
    }
    cnt -= m;
    ans -= cnt*low;
    //cerr << low << " " << cnt << endl;
    cout << ans << endl;
}

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

#define Bye return 0
#define int long long

void solve(){
    int n; cin>>n;
    double dp[n+1][n+1];

    memset(dp, 0, sizeof dp);

    double p[n+1];
    for (int i=1; i<=n; i++)
        cin>>p[i];

    dp[0][0] = 1;

    for (int i=1; i<=n; i++){

        for (int j=0; j<=i; j++){

            if(j == 0)
                dp[i][j] = (1-p[i])*dp[i-1][j];
            else
                dp[i][j] = (1-p[i])*dp[i-1][j]
                                      +
                                p[i]*dp[i-1][j-1];
        }
    }

    double ans = 0.0;
    for (int i=(n/2)+1; i<=n; i++)
        ans += dp[n][i];
    cout << setprecision(9) << ans;
}

int32_t main() {
    solve();
    Bye;
}


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

int main () {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  int mi = max(A, C);
  int ma = min(B, D);
  if (ma-mi > 0) cout << ma - mi << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;

int t[4][4] = {
  {0, 1, 2, 3},
  {1, 0, 3, 2},
  {2, 3, 0, 1},
  {3, 2, 1, 0},
};

int mul[4][4] = {
  {1, 1, 1, 1},
  {1, -1, 1, -1},
  {1, -1, -1, 1},
  {1, 1, -1, -1},
};

int main(){
  int n;

  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      int a[4], b[4];

      for(int i = 0; i < 4; i++) cin >> a[i];
      for(int i = 0; i < 4; i++) cin >> b[i];

      int ans[4];
      memset(ans, 0, sizeof(ans));

      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
          int to = t[i][j];
          int cal = mul[i][j] * a[i] * b[j];
          ans[to] += cal;
        }
      }

      for(int i = 0; i < 4; i++){
        if(i != 0) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
import math
def kochcurve(n,p1x,p1y,p2x,p2y):
    if n==0:
        print("%5f %5f"%(p2x,p2y))
        return
    sx=(p2x-p1x)/3.0+p1x
    sy=(p2y-p1y)/3.0+p1y
    tx=(p2x-p1x)*2.0/3+p1x
    ty=(p2y-p1y)*2.0/3+p1y
    ux=math.cos(math.pi/3)*(tx-sx)-math.sin(math.pi/3)*(ty-sy)+sx
    uy=math.sin(math.pi/3)*(tx-sx)+math.cos(math.pi/3)*(ty-sy)+sy
    kochcurve(n-1,p1x,p1y,sx,sy)
    kochcurve(n-1,sx,sy,ux,uy)
    kochcurve(n-1,ux,uy,tx,ty)
    kochcurve(n-1,tx,ty,p2x,p2y)
    

n=input()
p1x=0.0
p1y=0.0
p2x=100.0
p2y=0.0
print("%5f %5f"%(p1x,p1y))
kochcurve(n,p1x,p1y,p2x,p2y)

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
   
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

bool prime(int n){
  bool x = true;
  for(int j=2;j*j<=n;j++)
    if(n%j==0) x = false;
  return x;
}

int main(){
  int N;
  cin >> N;
  int i;
  int count = 0;
  for(i=6;i<=55555;i+=5){
    if(prime(i)){
      cout << i << endl;
      count++;
    }
    if(count==N) break;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main()  {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)

	for i:=0; i<n; i++ {
		fmt.Scan(&a[i])
	}

	var max int64
	var val int64
	l := make([]int64, n)
	r := make([]int64, n)
	l[1] = a[0]
	r[n-2] = a[n-1]
	for i:=2; i<n; i++ {
		//fmt.Println(l[i-1], a[i-1], r[n-i], a[n-i])
		//fmt.Println(l[i-1], a[i])
		l[i] = gcd(l[i-1], a[i-1])
		r[n-1-i] = gcd(r[n-i], a[n-i])
	}

	for i:=0; i<n; i++ {
		if l[i] == 0 {
			val = r[i]
		} else if r[i] == 0 {
			val = l[i]
		} else {
			val = gcd(l[i], r[i])
		}
		//fmt.Println(i,r[i],l[i])
		max = int64(math.Max(float64(max), float64(val)))
	}

	fmt.Println(max)
}
func gcd(x int64, y int64) int64 {
	if x < y {
		x, y = y, x
	}

	if z := x%y; z == 0 {
		return y
	} else {
		return gcd(y, z)
	}
}


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

string findSum(string str1, string str2)
{
    if (str1.length() > str2.length())
        swap(str1, str2);

    string str = "";

    int n1 = str1.length(), n2 = str2.length();
    int diff = n2 - n1;

    int carry = 0;

    for (int i = n1 - 1; i >= 0; i--)
    {
        int sum = ((str1[i] - '0') +
                   (str2[i + diff] - '0') +
                   carry);
        str.push_back(sum % 10 + '0');
        carry = sum / 10;
    }

    for (int i = n2 - n1 - 1; i >= 0; i--)
    {
        int sum = ((str2[i] - '0') + carry);
        str.push_back(sum % 10 + '0');
        carry = sum / 10;
    }

    if (carry)
        str.push_back(carry + '0');

    string s_str = "";
    for (int i = str.length() - 1; i >= 0; i--)
    {
        s_str.push_back(str[i]);
        str[i] = '\0';
    }

    return s_str;
}

int main(void)
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string a, b;
        cin >> a >> b;
        if (80 < a.length() || 80 < b.length())
        {
            cout << "overflow" << endl;
        }
        else
        {

            string s = findSum(a, b);
            if (80 < s.length())
            {
                cout << "overflow" << endl;
            }
            else
            {
                cout << s << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0) {
    cout << "Possible" << endl;
  } else if (b % 3 == 0) {
    cout << "Possible" << endl;
  } else if ((a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#import<cstdio>
main(){int K,i=scanf("%d",&K)-2,n=(K+3)/4*2,j,k;for(printf("%d\n",n);++i<n;puts(""))for(j=-1;++j<n;printf("%d ",((k=i%2*n+(i+j)%n)>=K?k-n:k)%K+1));}


Measured memory_bytes: 1152
h,w = map(int,input().split())
aij = [[int(i) for i in input().split()] for j in range(h)]

move = []

"""
for i in range(w-1,-1,-1):
    print(i)
""" 
 
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if aij[i][j] % 2 == 1:
                if j == w-1:
                    if i == h-1:
                        break
                    move.append([[i+1,j+1],[i+1+1,j+1]])
                    aij[i+1][j] += 1
                else:
                    move.append([[i+1,j+1],[i+1,j+1+1]])
                    aij[i][j+1] += 1
    else:
        for j in range(w-1,-1,-1):
            if aij[i][j] % 2 == 1:
                if j == 0:
                    if i == h-1:
                        break
                    move.append([[i+1,j+1],[i+1+1,j+1]])
                    aij[i+1][j] += 1
                else:
                    move.append([[i+1,j+1],[i+1,j+1-1]])
                    aij[i][j-1] += 1


print(len(move))

for i in range(len(move)):
    for j in range(len(move[i])):
        print(*move[i][j],end='')
        if j == 1:
            continue
        print(end=' ')
    print()

Measured memory_bytes: 101980
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}


int main(){
    ll N;
    cin >> N;
    ll T[N+2],A[N+2],sum_min_T[N+2], min_T[N+2],sum_min_A[N+2], min_A[N+2];

    llRep(i,N){
        cin >> T[i] >> A[i];
    }
    sum_min_T[0] = 0;
    min_T[0] = 0;
    sum_min_A[0] = 0;
    min_A[0] = 0;

    llRep(i,N){
        sum_min_T[i] = max(T[i], min_T[i-1]);
        sum_min_A[i] = max(A[i], min_A[i-1]);

        ll multiply;
        if ((sum_min_T[i]/T[i]) * T[i] >= sum_min_T[i]){
            multiply = (sum_min_T[i]/T[i]);
        }else{
            multiply = (sum_min_T[i]/T[i])+1;
        }
        ll multiply2;
        if ((sum_min_A[i]/A[i]) * A[i] >= sum_min_A[i]){
            multiply2 = (sum_min_A[i]/A[i]);
        }else{
            multiply2 = (sum_min_A[i]/A[i])+1;
        }
            min_A[i] = A[i] * max(multiply,multiply2);
            min_T[i] = T[i] * max(multiply,multiply2);
    }

    cout << min_T[N] + min_A[N] << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}

}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  readInt
  s <- map (filter (/= ' ')) . words <$> getLine
  if length (group $ sort s) == 3 then putStrLn "Three" else putStrLn "Four"


Measured memory_bytes: 508
#include <stdio.h>
int main(){
  int i,j,a;
  int ice_number[10];
  while(1){
    scanf("%d",&i);
    if(i == 0){
      break;
    }
    memset(ice_number,0,sizeof(ice_number));
    for(j=0;j<i;j++){
      scanf("%d",&a);
      ice_number[a]++;
    }
    for(a=0;a<10;a++){
      for(j=0;j<ice_number[a];j++){
	printf("*");
      }
      if(ice_number[a] == 0){
	printf("-");
      }
      printf("\n");
    }
  }
  return (0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	
	ll l = lcm(n, m);
	ll g = gcd(n, m);
	
	for(ll i = 0; i < g; ++i){
		if(s[i * n / g] != t[i * m / g]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
	
	return 0;
}



Measured memory_bytes: 512
import operator as op
from functools import reduce
import math
	

def ncr(n, r):
	if n < r:
		return 0
	else :
		return (math.factorial(n)) / (math.factorial(n-r)*math.factorial(r))

def countPairs(str_arr, N):
	str_cnt = [0]
	str = str_arr[0]
	j = 0
	for i in range(N):
		if(str_arr[i]==str):
			str_cnt[j] += 1
		else:
			str = str_arr[i]
			j += 1
			str_cnt.append(0)
			str_cnt[j] += 1
	count = 0
	for i in range(len(str_cnt)):
		count += ncr(str_cnt[i],2)
	print(int(count))

def main():
	N = int(input())
	str_arr = []
	for i in range(N):
		str = input()
		str_arr.append(sorted(str))
	str_arr = sorted(str_arr)
	countPairs(str_arr, N)


main()

Measured memory_bytes: 27880
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a % 2 == 0 && a == b && b == c)
    {
        cout << "-1\n";
        return 0;
    }
    int ans = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        int temp_a = (b + c) / 2,temp_b = (a + c) / 2,temp_c = (a + b) / 2;
        a = temp_a;
        b = temp_b;
        c = temp_c;
        ans++;
    }
    cout << ans << "\n";

    return 0;
}

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

using namespace std;
const int N = 1e5 + 3;
vector<int> job[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (m >= a)
			job[m - a].push_back(b);
	}
	long long res = 0;
	priority_queue<int> pq;
	for (int i = m; i >= 0; --i) {
		for (auto v: job[i])
			pq.push(v);
		if (pq.size()) {
			res += pq.top();
			pq.pop();
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 5632
from collections import Counter
s = input()
d = Counter(s)
n = len(s)
if n%3==0:
  if all(v==n//3 for v in d.values()):
    print('YES')
  else:
    print('NO')
else:
  if all(v==n//3 or v==n//3+1 for v in d.values()):
    print('YES')
  else:
    print('NO')

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

int main() {
	int a, b, c, i;
	cin >> i;
	for (int n = 0; n < i; n++) { 
		cin >> a >> b >> c; 
	if (a*a == b*b + c*c) { cout << "YES" << endl; }
	else if (b*b == a*a + c*c) { cout << "YES" << endl; }
	else if (c*c == a*a + b*b) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(){
  int n,mi=1e9,ma=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    mi=min(mi,a[i]);
    ma=max(ma,a[i]);
  }
  cout<<ma-mi<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long max = (1L << n);
		int k = sc.nextInt();
		long base = 0;
		for (int i = 0; i < k; i++) {
		    base += (1L << sc.nextInt());
		}
		StringBuilder sb = new StringBuilder();
		for (long i = 0; i < max; i++) {
		    if ((base & i) != base) {
		        continue;
		    }
		    sb.append(i).append(":");
		    long x = i;
		    for (int j = 0; j <= 18 && x > 0; j++) {
		        if (x % 2 == 1) {
		            sb.append(" ").append(j);
		        }
		        x >>= 1;
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 72452
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()
H = lmi()

AB = llmi(M)
adj = collections.defaultdict(set)
for a, b in AB:
    a = a - 1
    b = b - 1
    adj[a].add(b)
    adj[b].add(a)

ans = 0
for i, h in enumerate(H):
    flag = True
    for j in adj[i]:
        if H[j] >= h:
            break
    else:
        ans += 1
print(ans)


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

int gcd(int x, int y){return y == 0 ? x : gcd(y, x % y);}

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

	int mx = 0;
	int g;
	scanf("%d", &g);
	mx = max(mx, g);
	for (int i=1; i<n; ++i) {
		int x;
		scanf("%d", &x);
		mx = max(mx, x);
		g = gcd(g, x);
	}

	if (k <= mx && (mx - k) % g == 0) {
		puts("POSSIBLE");
	} else {
		puts("IMPOSSIBLE");
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int sum = 0; //print
	
	void search(char[][] board, int i) {
		out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
			if(board[i][j] == board[0][0]) {
				for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
					if(board[i][k] == board[0][1]) {
						int interval = k - j;//1???????????¨2??????????????????
						int cnt = 2;//?????????????????¢?´¢???????????????
						for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
							if(board[i][m] == board[0][cnt]) {
								cnt = cnt + 1;
								if(cnt == board[0].length) {
									sum = sum + 1;
									break out;
								}
							} else {
								break;
							}
						}
					}
				}
			}				
		}
	}

	
	
	void doIt() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		board[0] = sc.next().toCharArray();
		for(int i = 1; i <= n; i++) {
			board[i] = sc.next().toCharArray();
			new Main().search(board, i);
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 27996
a,b,c,x,y=gets.split.map(&:to_i)

ans=a*x+b*y
0.upto([x,y].max) do |i|
    price=c*(2*i)+a*[(x-i),0].max+b*[(y-i),0].max
    ans=[price,ans].min
end
puts ans


Measured memory_bytes: 14368
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define PII pair<int,int>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
//#define int long long 
string S[10005];
int n;
int ans=0;
int head_B=0,tail_A=0,both=0;
signed main()
{cin>>n;
  rep(i,1,n)  
  {
    cin>>S[i];
   for(int j=1;j<S[i].size();j++) if(S[i][j-1]=='A'&&S[i][j]=='B') ans++;
   if(S[i][0]=='B'&&S[i][S[i].size()-1]=='A') {both++;continue;}
   if(S[i][0]=='B') head_B++;
   if(S[i][S[i].size()-1]=='A') tail_A++;
  }
//  ans+=min(tail_A,head_B);
  if(both)
  { ans+=both-1;
    if(tail_A) {tail_A--;ans++;}
	if(head_B) {head_B--;ans++; }
   ans+=min(tail_A,head_B);
   cout<<ans;
  }
  else
  {ans+=min(tail_A,head_B);
   cout<<ans;
  }
   
}

Measured memory_bytes: 768
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val points = readLine()!!.split(" ").map { it.toInt() }
    var answer = Double.MAX_VALUE
    for (i in points.min()!!..points.max()!!) {
        var candidate = 0.0
        for (j in 0 until n) {
            candidate += Math.pow(points[j]-i.toDouble(), 2.0)
        }
        answer = Math.min(candidate, answer)
    }
    println(answer.toInt())
}


Measured memory_bytes: 37692
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,x;
    cin >> a >> b >> x;
    if(x < a) {
      cout << "NO" << endl;return 0;
    }
    if(x > a+b){
      cout << "NO" << endl;return 0;

    }
    cout << "YES" << endl;return 0;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int ans;
char a[4];
int b[26];

int main()
{
    scanf("%s",a);
    for(int i = 0; i< 4; i++)
    {
        b[a[i]-'A']++;
    }
    ans = 0;
    for(int i = 0; i< 26; i++)
    {
        if(b[i] == 2)
            ans++;
    }
    if(ans == 2)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

int main(){
    int i, j, n, lc = 0, rc = 0;
    string s, res = "";
    cin >> n;
    cin >> s;
    for(i=0; i<n; i++){
        if(s[i] == '('){
            lc++;
        }else if(lc > 0){
            lc--;
        }else{
            rc++;
        }
    }
    for(j=0; j<rc; j++){
        res += '(';
    }
    res += s;
    for(j=0; j<lc; j++){
        res += ')';
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int n, k, x, y; cin >> n >> k >> x >> y;
	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (i > k)res += y;
		else res += x;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
// agc040_a
#include <iostream>
#include <bits/stdc++.h>
#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    UI a[s.length() + 1];
    UL o = 0;
    for (size_t i = 0; i < s.length() + 1; i++)
        a[i] = 0;

    for (size_t i = 0; i < s.length(); i++)
    {
        if ((i == 0 && s[i] == '<'))
        {
            a[i] = 0;
            for (size_t j = 0; j < s.length(); j++)
            {
                if (s[j] == '>')
                    break;
                a[j + 1] = a[j] + 1;
            }
        }
        else if (i == s.length() - 1)
        {
            if (s[i] == '>')
            {
                a[i + 1] = 0;
                for (long j = i; j >= 0; j--)
                {
                    if (s[j] == '<')
                        break;
                    a[j] = (a[j] < a[j + 1] + 1) ? a[j + 1] + 1 : a[j];
                }
                for (size_t j = i + 1; j < s.length(); j++)
                {
                    if (s[j] == '>')
                        break;
                    a[j + 1] = (a[j + 1] < a[j] + 1) ? a[j] + 1 : a[j + 1];
                }
            }
            else
                break;
        }
        else if ((s[i] == '>' && s[i + 1] == '<'))
        {
            a[i + 1] = 0;
            for (long j = i; j >= 0; j--)
            {
                if (s[j] == '<')
                    break;
                a[j] = (a[j] < a[j + 1] + 1) ? a[j + 1] + 1 : a[j];
            }
            for (size_t j = i + 1; j < s.length(); j++)
            {
                if (s[j] == '>')
                    break;
                a[j + 1] = (a[j + 1] < a[j] + 1) ? a[j] + 1 : a[j + 1];
            }
        }
    }

    for (size_t i = 0; i < s.length() + 1; i++)
    {
        o += a[i];
    }
    cout << o << endl;
    return 0;
}


Measured memory_bytes: 2820
N, M, Q = map(int, input().split())
ABCD = [tuple(map(int, input().split())) for _ in range(Q)]


max_score = 0


def search(A):
    global max_score

    if len(A) == N:
        score = 0
        for a, b, c, d in ABCD:
            if A[b - 1] - A[a - 1] == c:
                score += d
        max_score = max(score, max_score)
        return

    for a_next in range(A[-1], M + 1):
        search(A + [a_next])


for i in range(1, M + 1):
    search([i])


print(max_score)

Measured memory_bytes: 9220
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

void nibai(int &a, int &b, int &c);

int main(){
	int a, b, c;
   	int K;

	cin >> a >> b >> c;
	cin >> K;

	for(int i = 0; i < K; i++){
		nibai(a, b, c);
	}

	if(a < b && b < c && a < c){
		cout << "Yes" << "\n";
	}	
	else{
		cout << "No" << "\n";
	}

}

void nibai(int &a, int &b, int &c){
	if(a >= b){
		b *= 2;
		return;
	}
	if(b >= c){
		c *= 2;
		return;
	}
	return;
}


Measured memory_bytes: 3648
// 2020-09-20 02:31:45
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  int n, q;
  cin >> n >> q;
  int r = n, b = n;
  vector<int> h(n, n), w(n, n);
  ll ans = ll(n - 2) * (n - 2);
  rep(qi, q) {
    int c, x;
    cin >> c >> x;
    if (c == 1) {
      if (x < r) {
        REP(i, x, r) h[i] = b;
        ans -= b - 2;
        r = x;
      } else {
        ans -= h[x] - 2;
      }
    } else {
      if (x < b) {
        REP(i, x, b) w[i] = r;
        ans -= r - 2;
        b = x;
      } else {
        ans -= w[x] - 2;
      }
    }
  }
  cout << ans << '\n';
}

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

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    m1 = 0
    m2 = 0
    la = []
    for i in range(n):
        a = ri()
        if m1 <= a:
            m2 = m1
            m1 = a
        elif m2 < a:
            m2 = a
        la.append(a)
    for a in la:
        if a == m1:
            print(m2)
        else:
            print(m1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12540
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};

int solve(){
 double l;cin>>l; 
 double k=l/3;
 cout<<fixed<<setprecision(10)<<k*k*k<<endl;
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())

if C*2 >= A+B:
    print(A*X+B*Y)
else:
    print(min(C*2*max(X,Y), C*2*min(X,Y) + A*(X-min(X,Y)) + B*(Y-min(X,Y))))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5 + 100;

int n,h,w;
void nhap()
{
    cin >> n;
    cin >> h >> w;
}

void solve()
{
    cout << (n - h + 1) * (n - w + 1);
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n,k,pattern = 1;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		if(i == 0){
			pattern *= k;
		}
		else{
			pattern *= k-1;
		}
	}
	cout << pattern << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	double a=0,max=0,min=0;
	int i=0;
	while(scanf("%lf",&a)!=EOF){
	if(i==0){
		max=a;
		min=a;
		i=1;
	}
	if(a>=max){
		max=a;
	}
	if(a<=min){
		min=a;
	}
	}
	printf("%lf\n",max-min);
return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class UnionFind{
  int n;
  vector<int> data;
public:
  UnionFind(int _n):n(_n),data(_n,-1){}
  bool link(int a, int b){ //if new link, then true.
    int ra=find_root(a);
    int rb=find_root(b);
    if(ra!=rb){
      if(data[rb]<data[ra]) swap(ra,rb);
      data[ra]+=data[rb];
      data[rb]=ra;
    }
    return (ra!=rb);
  }
  bool check(int a, int b){ //if same set, then true.
    return (find_root(a)==find_root(b));
  }
  int find_root(int a){
    return ((data[a]<0)?a:(data[a]=find_root(data[a])));
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];

  UnionFind uf(N);
  rep(i,M){
    int x, y;
    cin >> x >> y;
    uf.link(x, y);
  }
  
  map<int,vector<int>> memo;
  rep(i,N){
    memo[uf.find_root(i)].push_back(i);
  }

  ll ret = 0;
  vector<ll> v;
  FOR(it,memo){
    vector<ll> tmp;
    rep(i,(it->second).size()){
      tmp.push_back(a[(it->second)[i]]);
    }
    sort(ALLOF(tmp));
    rep(i,tmp.size()){
      if(i==0) ret += tmp[i];
      else v.push_back(tmp[i]);
    }
  }

  sort(ALLOF(v));
  int x = memo.size();
  int y = v.size();
  int cnt = x-2;
  if(x == 1){
    cout << 0 << endl;
    return 0;
  }
  if(y < cnt){
    ret = -1;
  }else{
    rep(i,cnt){
      ret += v[i];
    }
  }

  if(ret < 0){
    cout << "Impossible" << endl;
  }else{
    cout << ret << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, val;
    map<int, int> cnt;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[i+1] += val;
    }
    ll ans = 0;
    for(auto& p: cnt) {
        ans += p.second / 2;
        p.second %= 2;
        if (cnt.count(p.first+1) > 0) {
            int mn = min(p.second, cnt[p.first+1]);
            ans += mn;
            p.second -= mn;
            cnt[p.first+1] -= mn;
        }

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




Measured memory_bytes: 4992
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

vi eratosthenes(const int &n) {
  vi v(n);
  iota(v.begin() + 2, v.end(), 2);
  for (int i = 2; i * i < n; i++) {
    if (v[i]) {
      for (int j = i * 2; j < n; j += i) {
        v[j] = false;
      }
    }
  }
  return v;
}

vi genPrimes(const int &n) {
  vi primes = eratosthenes(n);
  primes.erase(remove(all(primes), 0), primes.end());
  return primes;
}

void solve() {
  vi primes = genPrimes(50000);
  vi c(50001);
  rep(i, primes.size()) {
    for (int j = i; primes[i] + primes[j] <= 50000; j++) {
      c[primes[i] + primes[j]]++;
    }
  }
  int n;
  while (cin >> n, n) {
    cout << c[n] << endl;
  }
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

void solve()
{
    int ans = 0;
    vector<int> a(5);
    for (int i=1; i<=5; i++) {
        int x;
        cin>>x;
        if (x) {
            a[x-1] = 1;
        }
    }   
    for (int i=0; i<5; i++) {
        if (a[i]==0) {
            ans = i+1;
        }
    }
    cout << ans << "\n";
}

int main()
{
    fastIO;
    int t=1;
    // cin>>t;
    while (t--) {
        solve();    	
    }
    return 0;
}

Measured memory_bytes: 3612
n = int(input())
li_b = list(map(int, input().split()))
li_a = [9999999] * n

for idx, b in enumerate(li_b):
    if idx == 0:
        li_a[0] == b
    if idx == n - 1:
        li_a[-1] == b
    else:
        li_a[idx] = min(li_a[idx], b)
        li_a[idx + 1] = min(li_a[idx + 1], b)
print(sum(li_a))


Measured memory_bytes: 3060