akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let ab: i32 = read();
    let x: i32 = read();
    let y: i32 = read();

    let mut sum: i32 = 0;

    if (a+b) < ab*2 {
        sum += a*x + b * y;
    } else {
        if x > y {
            sum += ab*y*2;

            let all_ab = sum + ab * (x-y) * 2;
            let not_all_ab = sum + a * (x-y);
            sum = cmp::min(all_ab, not_all_ab);
        } else if x == y {
            sum += ab*y*2;
        } else {
            sum += ab*x*2;

            let all_ab = sum + ab * (y-x) * 2;
            let not_all_ab = sum + b * (y-x);
            sum = cmp::min(all_ab, not_all_ab);
        }
    }

    println!("{}", sum);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
from math import floor

while True:
    e = int(input())
    if e == 0:
        break

    ans = 10 ** 10
    z = 0
    while z ** 3 <= e:
        y = floor((e - z **3) ** 0.5)
        x = e - y ** 2 - z ** 3
        ans = min(ans, x + y + z)
        z += 1
    print (ans)


Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

#define MAXN 100000
int a[MAXN];

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  forr(i,0,25)
    cin >> c[i];
  vector< vector<int> > s(d, vector<int>(26));
  forr(i,0,d-1)
    forr(j,0,25)
      cin >> s[i][j];
  vector<int> t(d);
  forr(i,0,d-1) {
    cin >> t[i];
    t[i]--;
  }

  vector<int> last(26,-1);
  int sc = 0;
  forr(i,0,d-1) {
    int tt = t[i];
    last[tt] = i;
    forr(j,0,25) sc -= c[j]*(i-last[j]);
    sc += s[i][tt];
    cout << sc << endl;
  }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

const int D=50;

int main(){
    ll n, k; cin>>n>>k;
    vector<ll> bitcnt(D+10, 0);
    for(int i=0; i<n; i++){
        ll a; cin>>a;
        for(int j=0; j<=D; j++){
            if((1LL<<j) & a) bitcnt[j]++; 
        }
    }

    ll ans=0;
    for(int d=D; d>=-1; d--){
        // digit = -1 は X = K のとき

        // digit 桁目について、K = 1 でなければならない
        if(d!=-1 && !(k & (1LL<<d))) continue;

        ll sum=0;
        for(int i=D; i>=0; i--){
            ll mask=(1LL<<i);
            
            if(i>d){
                // d より上位の桁なので K に合わせる
                if(k & mask) sum+=mask*(n-bitcnt[i]);
                else sum+=mask*bitcnt[i];
            }
            else if(i==d){
                // X = 0 でなけらばならない
                sum+=mask*bitcnt[i];
            }
            else{
                // d より下位の桁なので、貪欲に決められる
                sum+=mask*max(bitcnt[i], n-bitcnt[i]);
            }
        }

        chmax(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  vector<int> a(n);
  int maxi=0;
  r(i,n){
    cin>>a.at(i);
    maxi=max(maxi,a.at(i));
  }

  ll sum,min_sum=1<<30;
  for(int i=-100;i<=100;i++){
    sum=0;
    r(j,a.size()){
      sum+=(i-a.at(j))*(i-a.at(j));
    }
    //cout<<sum<<endl;
    min_sum=min(min_sum,sum);
  }

  cout<<min_sum<<endl;


  return 0;
}


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

int main() {
    string s; cin >> s;
    int na = 0, nb = 0, nc = 0;
    for (char c : s) {
        if (c == 'a') ++na;
        if (c == 'b') ++nb;
        if (c == 'c') ++nc;
    }
    if (na < nb) swap(na, nb);
    if (na < nc) swap(na, nc);
    if (nb < nc) swap(nb, nc);
    na -= nc;
    nb -= nc;
    nc = 0;
    if (na > 1) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
}


Measured memory_bytes: 512
import java.util.*;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] A = new long[N];
        long[] sum = new long[N];
        HashMap<Long, Long> map = new HashMap<>();

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            if(i==0){
                sum[i] = A[i];
            }
            else{
                sum[i] = sum[i - 1] + A[i];
            }
            if(map.containsKey(sum[i]%M)){
                map.put(sum[i]%M, map.get(sum[i]%M) + 1);
            }
            else{
                map.put(sum[i]%M, 1L);
            }
        }
        long ans = 0;
        for(long key : map.keySet()){
            if(key==0){
                ans += map.get(key);
            }
            ans += (map.get(key) * (map.get(key) - 1)) / 2;
        }
        System.out.println(ans);
               
    }
}

Measured memory_bytes: 61112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    cout<<(1000-(n%1000))%1000<<"\n";
    return 0;
}


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

using namespace std;

int main() {
    string S; cin >> S;
    for(int i = 0; i < (1 << 3); ++i) {
        long int sum = S[0] - '0';
        string ans = "+++";
        for(int j = 0; j < 3; ++j) {
            if((1 & i >> j) == 1) {
                sum -= S[j+1] - '0';
                ans[j] = '-';
            }
            else sum += S[j+1] - '0';
        }
        if(sum == 7) {
            cout << S[0] << ans[0] << S[1] << ans[1] << S[2] << ans[2] << S[3] << "=7" << endl;
            break;
        }    
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int main(){
	while(1){
		int n,k;
		cin>>n>>k;
		if(!n) break;
		vb a(n+1);
		bool flag=0;
		for(int i=0;i<k;i++){
			int s;
			cin>>s;
			if(s) a[s-1]=1;
			else flag=1;
		}
		a[n]=!a[n-1];
		vi b;
		int S=0;
		for(int i=1;i<=n;i++) if(a[i]!=a[i-1]){
			b.push_back(i-S);
			S=i;
		}
		int ans=0;
		for(int i=0;i<b.size();i++) if(a[0]==(i%2==0)){
			if(flag){
				ans=max(ans,b[i]+1);
				if(i-2>=0&&b[i-1]==1) ans=max(ans,b[i-2]+b[i]+1);
			}
			else ans=max(ans,b[i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3108
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>
#include <vector>
#include <chrono>

using namespace std;

constexpr int D = 365;
constexpr int LIMIT = 1950;
std::chrono::system_clock::time_point start;

int score(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i]-1];

		last[t[i] - 1] = i+1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i+1 - last[j]);
		}
	}

	return S;
}

int score_alpha(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t, const int& k) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i] - 1];

		last[t[i] - 1] = i + 1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}

	for (size_t i = t.size(); i < min(int(t.size() + k), D); i++) {
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}
	return S;
}

vector<int> greedy(const vector<int>& c, const vector<vector<int>>& s, const int& k) {
	vector<int> t;
	t.reserve(D);

	for (size_t i = 0; i < D; i++) {
		int mscore = INT32_MIN, idx = 1;
		
		for (size_t j = 0; j < 26; j++) {
			t.push_back(j+1);
			int dscore = score(c, s, t);
			dscore = score_alpha(c, s, t, k);

			if (dscore > mscore) {
				mscore = dscore;
				idx = j+1;
			}
			t.pop_back();
		}

		t.push_back(idx);
	}

	return t;
}

vector<int> local(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& init) {
	vector<int> t(init);
	int mscore = score(c, s, t);

	auto end = std::chrono::system_clock::now();
	while (std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() < LIMIT) {
		int ri = rand() % D;
		int rc = rand() % 26;

		vector<int> nt(t);
		nt[ri] = rc + 1;
		int nscore = score(c, s, nt);

		if (mscore < nscore) {
			mscore = nscore;
			copy(nt.begin(), nt.end(), t.begin());
		}
		end = std::chrono::system_clock::now();
	}
	return t;
}

int main() {
	start = std::chrono::system_clock::now();
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int ig;
	cin >> ig;

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		//c[i] = rand() % 100;
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
			//s[i][j] = rand() % 20000;
		}
	}

	vector<int> bt = greedy(c, s, 0);
	int sc = score(c, s, bt);

	for (int i = 1; i < 10; i++) {
		auto t = greedy(c, s, i);
		auto tsc = score(c, s, t);
		if (sc < tsc) {
			sc = tsc;
			bt = t;
		}
	}
	
	bt = local(c, s, bt);

	for (size_t i = 0; i < D; i++) cout << bt[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  long long result = 0;
  long long k = 0;
   cin >> S;
  long long N = S.length();
  vector<long long> A(N);
  vector<string> T(N);
  for(long long a = 0;a < N;a++)T.at(a) = S[a];
  
  A.at(0) = stoi(T.at(N - 1));
  k = 10;
  for(long long a = 1;a < N;a++){
    
    A.at(a) = (A.at(a-1) + stoi(T.at(N - a - 1)) * k) % 2019;
    if(A.at(a) == 0)result++; 
    k = (k * 10) % 2019;
  }
  sort(A.begin(),A.end());
  k = 0;
  for(long long a = 1;a < N;a++){ 
    
    if(A.at(a-1) == A.at(a)){
      k++;
      result += k;
      
    }else{
     k = 0; 
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 11304
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  ll n; cin >> n;
  int  ac = 0,wa = 0,tle = 0,re = 0;
  rep(i,n){
    string s; cin >> s;
    if(s.at(0) == 'A') ac++;
    if(s.at(0) == 'W') wa++;
    if(s.at(0) == 'T') tle++;
    if(s.at(0) == 'R') re++;
  }

  printf("AC x %d\n",ac);
  printf("WA x %d\n",wa);
  printf("TLE x %d\n",tle);
  printf("RE x %d\n",re);
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.gir","r",stdin);freopen ("kmp.cik","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum=INT_MAX,a,b,tut[N],dp[N],top2,last;

int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	fo(i,1,n)
		top2+=ar[i];
	top2/=2;

	ll top=0;
	fo(i,2,n-1)
	{
		top+=ar[i];
		i++;
	}
	top=top2-top;
	last=top;
	// cout<<top2<<sp<<top<<endl;
	cout<<last*2<<sp;

	fo(i,1,n-1)
	{
		if(i==n)
			return cout<<(ar[i]-top)*2,0;
		last=ar[i]-last;
		cout<<last*2<<sp;
	}
	// cout<<sum;
}



/*     cd onedrive\desktop\kod
cls


*/

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

using namespace std;
typedef long long ll;


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

	int n;
	cin>>n;

	int d[n+5];

	for(int i=0;i<n;i++)cin>>d[i];

	//sort(d,d+n);
	
	int sum =0 ;

	int val = d[n-1];

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=d[i]*d[j];
		}
	}	

	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 256
n , t = map(int,input().split())
tlist = list(map(int,input().split()))
d = []
for i in range(n-1):
    d.append(tlist[i+1]-tlist[i])
ans = 0
for i in range(n-1):
    if d[i] <= t:
        ans += d[i]
    else:
        ans += t
print(ans + t)

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	int ans = 0;
	rep(i, 1, N + 1) {
		int n = N / i;
		ans += n * (2 * i + (n - 1)*i) / 2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let () = Scanf.scanf "%d\n" @@ fun n ->
  let es = Array.make n [] in
  for i = 1 to n - 1 do
    Scanf.scanf "%d %d\n" @@ fun x y ->
      es.(x - 1) <- y - 1 :: es.(x - 1);
      es.(y - 1) <- x - 1 :: es.(y - 1)
  done;
  let visited = Array.make n false in
  let rec visit v =
    if visited.(v) then (0, 1)
    else begin
      visited.(v) <- true;
      List.fold_left (fun (b, w) u ->
        let (b', w') = visit u in
        (b *^ w', w *^ (b' +^ w'))) (1, 1) es.(v)
    end in
  let (b, w) = visit 0 in
  Printf.printf "%d\n" @@ b +^ w


Measured memory_bytes: 18560
from collections import deque
n,m,k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

f1 = [set() for _ in range(0, n+1)]
b1 = [set() for _ in range(0, n+1)]
fb1 = [set() for _ in range(0, n+1)]
ans = [0]*(n+1)

for x,y in ab:
    f1[x].add(y)
    f1[y].add(x)
    fb1[x].add(y)
    fb1[y].add(x)

for x,y in cd:
    b1[x].add(y)
    b1[y].add(x)
    fb1[x].add(y)
    fb1[y].add(x)

stack = deque()
visited = [0]*(n+1)
links = []

for i in range(1, n+1):
    if visited[i]: continue
    link = {i}
    visited[i] = 1
    stack.append(i)
    while stack:
        n1 = stack.pop()
        for j in f1[n1]:
            if visited[j] == 0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    links.append(link)

for i in links:
    leni = len(i)
    for j in i:
        ans[j] = leni - len(i & fb1[j]) - 1

print(*ans[1:])

Measured memory_bytes: 183172
import sys
input =sys.stdin.readline

N=int(input().rstrip('\n'))
As=[int(x) for x in input().rstrip('\n').split()]
As_s=sorted(As,reverse=True)
res = As_s[0]
num = 2
if N>2:
  for i in As_s[1:]:
    res += i
    num += 1
    if num ==N:
      break
    res += i
    num += 1
    if num==N:
      break
print(res)

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


int main()
{
    ll n,ans=0,x;
    cin>>n;
    for(ll i=1; i<=n; i++){
        cin>>x;
        if(i%2==1&&x%2==1){ans++;}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
island = [[int(_) for _ in input().split()] for _ in range(M)]
set1 = set()
setN = set()
flag = False

for i in island:
    if i[0] == 1:
        set1.add(i[1])
    elif i[1] == N:
        setN.add(i[0])

for i in set1:
    if i in setN:
        flag = True
        break

print("POSSIBLE" if flag else "IMPOSSIBLE")

Measured memory_bytes: 46480
n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

B = [[] for i in range(n+1)]

deta = [-1 for i in range(n+1)]
for i in range(len(A)):
    B[A[i][0]].append(A[i][1])
    B[A[i][1]].append(A[i][0])
    deta[A[i][0]]=0
    deta[A[i][1]]=0

count = 0
start = 1

while start < n+1 :
    while start < n+1 and deta[start]!=0 :
        start += 1

    if start < n+1 :
        count += 1
        #print("c")

        nurulist = [start]
        t = 0
        while t < len(nurulist):
            k = nurulist[t]
            for j in range(len(B[k])):
                if deta[B[k][j]] == 0:
                    deta[B[k][j]] = 1
                    nurulist.append(B[k][j])
            t += 1

print(count+deta.count(-1)-1)


Measured memory_bytes: 37784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC169C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long A = long.Parse(input[0]);
            decimal b = decimal.Parse(input[1]);
            //Console.WriteLine(b);
            b = b * 100;
            //Console.WriteLine(b);
            decimal kirisute = Math.Floor(b);
            //Console.WriteLine(kirisute);
            string bstr = kirisute.ToString();
            long B = long.Parse(bstr);
            //Console.WriteLine(B);
            long prod = A * B;
            string ans = prod.ToString();
            string str = ans.ToString();
            int N = str.Length;
            if (N > 2)
            {
                string str2 = str.Remove(N - 2, 2);
                Console.WriteLine(str2);
            }
            else
            {
                Console.WriteLine("0");
            }
            //Console.WriteLine(str);
            
            //Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27608
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

ll c[10000][10000];
bool v[10000];
ll N, M;
ll cnt = 0;

bool ifallvisited() {
	bool valid = true;
	rep(i, 0, N) valid &= v[i];
	return valid;
}

void dfs(int id) {
	if (ifallvisited()) {
		cnt++;
		return;
	}

	rep(i, 0, N) {
		if (id != i && c[id][i] != 0 && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}
}

int main() {
	//Input
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}

	//Start
	v[0] = true;
	dfs(0);

	//Output
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
typedef long long LL;
const int MAXN = 2e6+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
signed main(){
#ifndef ONLINE_JUDGE
    //freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
#endif // ONLINE_JUDGE
	string ss; cin>>ss;
	if(ss=="SUN") puts("7");
	else if(ss=="MON") puts("6");
	else if(ss=="TUE") puts("5");
	else if(ss=="WED") puts("4");
	else if(ss=="THU") puts("3");
	else if(ss=="FRI") puts("2");
	else if(ss=="SAT") puts("1");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll M;
    vl x(n-1), y(n-1);
    if(a[n-1] <= 0) {  // すべて0以下のとき
        M = a[n-1];
        rep(i, n-1) {
            x[i] = M;
            y[i] = a[i];
            M -= a[i];
        }
    }
    else if(0 <= a[0]) {  // すべて0以上のとき
        M = a[0];
        rep(i, n-2) {
            x[i] = M;
            y[i] = a[i+1];
            M -= a[i+1];
        }
        x[n-2] = a[n-1];
        y[n-2] = M;
        M = a[n-1] - M;
    }
    else {  // 正負の数がともにあるとき
        sort(rall(a));
        ll k;  // 0以上の数はk個ある
        rep(i, n) {
            if(a[i] < 0) {
                k = i;
                break;
            }
        }
        ll t = a[n-1];
        rep(i, k-1) {
            x[i] = t;
            y[i] = a[i+1];
            t -= a[i+1];
        }
        M = a[0];
        x[k-1] = M;
        y[k-1] = t;
        M -= t;
        exrep(i, k, n-2) {
            x[i] = M;
            y[i] = a[i];
            M -= a[i];
        }
    }

    out(M);
    rep(i, n-1) {
        cout << x[i] << " " << y[i] << "\n";
    }

    re0;
}

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

using namespace std;
int main(){
    int X;
    cin >> X;
    if (X >= 400 && X <= 599){
        cout << "8" << endl;
    }else if(X<=799){
        cout << "7" << endl;
    }else if(X<=999){
        cout << "6" << endl;
    }else if(X<=1199){
        cout << "5" << endl;
    }else if(X<=1399){
        cout << "4" << endl;
    }else if(X<=1599){
        cout << "3" << endl;
    }else if(X<=1799){
        cout << "2" << endl;
    }else if(X<=1999){
        cout << "1" << endl;
    }
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;
typedef long long LL;
const int LEN = 1e2 + 10;
int A[LEN];

int main() {
    int N, M, sum = 0, cnt = 0;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    int flag = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] * 4 * M >= sum) {
            cnt += 1;
        }
        if (cnt == M) {
            flag = 1;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;

    for ( long long int i = 0; i < n; i++ ) {

        long long int in;
        cin >> in;
        v.push_back( in );

    }

    long long int ans = 0;

    for ( long long int i = 1; i < n - 1; i++ ) {
        if ( v[i-1] < v[i] && v[i] < v[i+1] ) ans++;
        if ( v[i+1] < v[i] && v[i] < v[i-1] ) ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#B
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
aind = 0
bind = 0
cind = 0
now = "a"
winner = ""
while True:
    if now == "a":
        if aind == len(A):
            winner = "A"
            break
        else:
            now = A[aind]
            aind+=1
    elif now == "b":
        if bind == len(B):
            winner = "B"
            break
        else:
            now = B[bind]
            bind+=1
    elif now == "c":
        if cind == len(C):
            winner = "C"
            break
        else:
            now = C[cind]
            cind+=1

print(winner)

Measured memory_bytes: 3064
N = int(input())
a = [int(i) for i in input().split()]
s = int()
cost = 1000000

for i in range(-100,101):
    for t in range(N):
        s += (a[t] - i)*(a[t] - i)
    if  s < cost:
        cost = s
    s =int(0)

print(cost)

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            ans++;
        }
    }

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


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

int gojoho(int a,int b){
    while(1){
        int r=a%b;
        if(r==0)
            return b;
        else{
            a=b;
            b=r;
        }
    }
}

int main() {
    int l;
    int tmp;
    int sum=0;
    cin >> l;
    for (int i=1;i<=l;i++){
        for(int j=1;j<=l;j++){
            for (int k=1;k<=l;k++){
                tmp = gojoho(i,j);
                tmp = gojoho(tmp,k);
                sum+=tmp;
            }
        }
    }
    cout << sum << endl;
    // int test =gojoho(2,3);
    // cout << test << endl;
    return 0;
}



Measured memory_bytes: 3636
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    a = int(input())
    print(a+a*a+a**3)
    return

if __name__=='__main__':
    main()


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

void solve() {
    string s1, s2;
    cin >> s1 >> s2;
    int num1 = 0, num2 = 0;
    int mul_num = 1, base_num = 1;
    for (int i = 0; i < s1.length(); i++) {
        if (s1[i] - '0' >= 2 && s1[i] - '0' <= 9) {
            mul_num = s1[i] - '0';
        }
        else {
            if (s1[i] == 'm') base_num = 1000;
            else if (s1[i] == 'c') base_num = 100;
            else if (s1[i] == 'x') base_num = 10;
            else base_num = 1;
            num1 += mul_num * base_num;
            mul_num = 1;
        }
    }
    for (int i = 0; i < s2.length(); i++) {
        if (s2[i] - '0' >= 2 && s2[i] - '0' <= 9) {
            mul_num = s2[i] - '0';
        }
        else {
            if (s2[i] == 'm') base_num = 1000;
            else if (s2[i] == 'c') base_num = 100;
            else if (s2[i] == 'x') base_num = 10;
            else base_num = 1;
            num2 += mul_num * base_num;
            mul_num = 1;
        }
    }
    int ans_num = num1 + num2;
    string ans;
    int base = 1;
    while (ans_num > 0) {
        if (ans_num % 10 > 0) {
            if (base == 1) ans += 'i';
            else if (base == 2) ans += 'x';
            else if (base == 3) ans += 'c';
            else ans += 'm';
            if (ans_num % 10 > 1) {
                ans += (char)('0' + ans_num % 10);
            }
        }
        base++;
        ans_num /= 10;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==5&&B==5&&C==7)
    {
        cout<<"YES"<<endl;
    }
    else if(A==5&&B==7&&C==5)
    {
        cout<<"YES"<<endl;
    }
    else if(A==7&&B==5&&C==5)
    {
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int maxn = 6e5 + 111;
     
using namespace std;

int q, n, m, dist[maxn], dp[maxn], ans;
vector <int> g[maxn];
bool was[maxn];

int dfs(int v){
	if (was[v])
		return dp[v];
	was[v] = true;
	dp[v] = 0;
	for (auto to : g[v]){
		dp[v] = max(dp[v], dfs(to) + 1);
	}
	return dp[v];
}

void solve(){    
	cin >> n >> m;
		
	for (int i = 1; i <= m; i++){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
	}

	for (int i = 1; i <= n; i++){
		ans = max(ans, dfs(i));
		/*for (int j = 1; j <= n; j++)
			cout << dist[j] << " ";

		cout << endl;*/
	}

	cout << ans;
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 20608
#include<cstdio>
using namespace std;

int N,i;
long long t[1000],a[1000],x,y,z,xx,yy;

int main(){
	scanf("%d/n",&N);
	for(i=0;i<N;i++)
		scanf("%lld %lld",&t[i],&a[i]);
	x = t[0];
	y = a[0];
	for(i=1;i<N;i++){
		xx = x / t[i];
		yy = y / a[i];
		if(x % t[i] !=0) xx++;
		if(y % a[i] !=0) yy++;
		z = xx < yy ? yy : xx;
		x = z * t[i];
		y = z * a[i];
	}
	printf("%lld",x+y);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <stack>
#include <string>

int main(int argc, char const *argv[])
{
    std::stack<int> S;
    int a,b,x;
    std::string s;

    while(std::cin >> s){
        if(s[0] == '+'){
            a = S.top();
            S.pop();

            b = S.top();
            S.pop();

            S.push(a + b);
        }
        else if(s[0] == '-'){
            a = S.top();
            S.pop();

            b = S.top();
            S.pop();

            S.push(b - a);
        }
        else if(s[0] == '*'){
            a = S.top();
            S.pop();

            b = S.top();
            S.pop();

            S.push(a * b);
        }
        else{
            S.push(atoi(s.c_str()));
        }
    }

    std::cout << S.top() << std::endl;

    return 0;
}



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

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

    if (n < 10)
    {
        cout << r + 100 * (10 - n) << endl;
    }
    else
    {
        cout << r << endl;
    }
    
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a;
lli ans = 0;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  for(lli i = 0;i < n;i++){
    while(a[i]%2 == 0){
      a[i]/=2;
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 764
// This file is in ~/.config/geany/templates/files
#include<bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair
typedef long long tint;
int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}
string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele((a*a), b/2);
	}else{
		return a*ele((a*a), b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}



void solve(){
	tint A, B, C, D, E, F;
	cin>>A>>B>>C>>D>>E>>F;
	tint num=-1, den;
	tint masa=-1, sugar=-1;
	vector<tint> v;
	forsn(a, 0, 31){
		forsn(b, 0, 31){
			forsn(c, 0, 101){
				forsn(d, 0, 101){
					if(c*C+d*D<=E*(A*a+B*b)){
						tint sug=(C*c+D*d);
						tint arr=100*sug;
						tint ab=sug+100*(A*a+B*b);
						if(ab<=F){
							if(num==-1 || num*ab<=den*arr){
								num=arr;
								den=ab;
								masa=ab;
								sugar=sug;
							}
						}
					}
				}
			}
		}
	}
	cout<<masa<<" "<<sugar<<"\n";
}



int main (){
	int T;
	T=1;
	while(T--){
		solve();
	}
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int N;
    long M;
    int[] as;
    long[] ss;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        N = sc.nextInt();
        M = sc.nextLong();
        as = new int[N];
        ss = new long[N + 1];
        for (int i = 0; i < N; i++) {
            as[i] = sc.nextInt();
        }
        Arrays.sort(as);
        for (int i = 0; i < N; i++) {
            ss[i + 1] = ss[i] + as[i];
        }

        out.println(ans());

        out.flush();
    }

    long ans() {
        int l = 0, r = 1000000;

        while (r - l > 1) {
            int X = (r + l) / 2;
            if (ok(X)) {
                l = X;
            } else {
                r = X;
            }
        }

        long sum = 0;
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            int t = l - as[i];
            int x = lowerBound(as, t);
            sum += (long) (N - x) * as[i] + ss[N] - ss[x];
            cnt += N - x;
        }
        return sum - (cnt - M) * l;
    }

    boolean ok(int X) {
        long sum = 0;
        for (int i = 0; i < N; i++) {
            int t = X - as[i];
            int x = lowerBound(as, t);
            sum += N - x;
        }
        return sum >= M;
    }

    public int lowerBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] >= value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 63020
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int fx[4]={1,0,-1,0},fy[4]={0,1,0,-1};
int qx[640005],qy[640005],d[805][805],h,w,k;
char s[805][805];
int f(int x,int y){
	return (min(x-1,min(h-x,min(y-1,w-y)))+k-1)/k;
}
int main(){
	scanf("%d%d%d",&h,&w,&k);
	for (int i=1;i<=h;i++){
		scanf("%s",s[i]+1);
		for (int j=1;j<=w;j++)
			if (s[i][j]=='S') qx[0]=i,qy[0]=j;
	}
	memset(d,-1,sizeof d);
	int head=0,tail=1,ans=f(qx[0],qy[0]);
	for (d[qx[0]][qy[0]]=0;head!=tail && ans;head++){
		int x=qx[head],y=qy[head];
		if (d[x][y]==k) break;
		for (int i=0;i<4;i++){
			int x2=x+fx[i],y2=y+fy[i];
			if (d[x2][y2]==-1 && s[x2][y2]=='.'){
				d[qx[tail]=x2][qy[tail]=y2]=d[x][y]+1;
				tail++;
				ans=min(ans,f(x2,y2));
			}
		}
	}
	printf("%d\n",ans+1);
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {

  int H,W;
  cin >> H >> W;

  vector<string> s(H);
  for(int i = 0;i < H;i++) cin >> s.at(i);

  vector<vector<int>> b(H,vector<int>(W,-1));
  int dx[] = {1,-1,0,0},dy[] = {0,0,1,-1};
  long long sum = 0;

  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      if(s.at(i).at(j) == '.' || b.at(i).at(j) != -1) continue;
      long long h = 0,B = 1;
      b.at(i).at(j) = 1;
      queue<pair<int,int>> Q;
      Q.push(make_pair(i,j));
      while(!Q.empty()) {
        pair<int,int> q = Q.front();
        Q.pop();
        for(int k = 0;k < 4;k++) {
          int y = q.first+dy[k],x = q.second+dx[k];
          if(y < 0 || y >= H) continue;
          if(x < 0 || x >= W) continue;
          if(b.at(y).at(x) != -1) continue;

          if(b.at(q.first).at(q.second) == 1) {
            if(s.at(y).at(x) == '.') {
              h++;
              b.at(y).at(x) = 0;
              Q.push(make_pair(y,x));
            }
          }else {
            if(s.at(y).at(x) == '#') {
              B++;
              b.at(y).at(x) = 1;
              Q.push(make_pair(y,x));
            }
          }
        }
      }
      sum += h*B;
    }
  }

  cout << sum << endl;

}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

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


Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
s = []
for i in range(n):
    si = input()
    s.append(si)

dic = {'A': a, 'B': b, 'C': c}
ans = []
for i in range(n):
    si = s[i]
    s1, s2 = si[0], si[1]
    if dic[s1] != dic[s2]:
        if dic[s1] > dic[s2]:
            dic[s1] -= 1
            dic[s2] += 1
            ans.append(s2)
        else:
            dic[s1] += 1
            dic[s2] -= 1
            ans.append(s1)
    else:
        if i == n-1:
            dic[s1] += 1
            dic[s2] -= 1
            ans.append(s1)
        else:
            if si == s[i+1]:
                dic[s1] += 1
                dic[s2] -= 1
                ans.append(s1)
            else:
                if s1 in s[i+1]:
                    dic[s1] += 1
                    dic[s2] -= 1
                    ans.append(s1)
                else:
                    dic[s1] -= 1
                    dic[s2] += 1
                    ans.append(s2)
    if min(dic.values()) < 0:
        print('No')
        exit()

print('Yes')
for i in ans:
    print(i)

Measured memory_bytes: 87156
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 19260817
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline LL Scan(){
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
int ps4[4][2]={0,1,0,-1,1,0,-1,0};
int ps8[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
inline int min(int a,int b,int c) {return min(a,min(b,c));}
inline int max(int a,int b,int c) {return max(a,max(b,c));}
inline int min(int a,int b,int c,int d){return min(min(a,b,c),d);}
inline int max(int a,int b,int c,int d){return max(max(a,b,c),d);}
//struct Edge{int p, next, w;}edge[maxn];
//inline add_edge(int u, int v, int w){edge[cnt]=Edge{v,head[u],w}; head[u]=cnt++;}
const int N=100005;
///Code begin..................................................................

int main ()
{

    char s[5];
    scanf("%s",s);
    int c=0, ma=0;
    if (s[0]==s[1]&&s[1]==s[2]) puts("Yes");
    else if (s[1]==s[2]&&s[2]==s[3]) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
long long n,k;
cin>>n;
vector<long long> a(n+1,0);

for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
}
vector<vector<long long > > dp(n+1,vector<long long>(n+1,1000000000000000));
for(int i=1;i<=n;i++)
{
    dp[i][i]=0;
}
for(int len=2;len<=n;len++){
    int i=1,j=len;
    while(j<=n){
    for(int k=i;k<j;k++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+a[j]-a[i-1]);
    }
    i++;
    j++;
    }

}

cout<<dp[1][n]<<"\n";

}


Measured memory_bytes: 1536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n+2];
		a[0] = 0;
		a[n+1] = 0;
		for(int i=1; i<n+1; i++){
			a[i] = sc.nextInt();
		}
		int total = 0;	
		for(int i=1;i<=n+1; i++){
			total += Math.abs(a[i] - a[i-1]);
		}
		int sum = 0;
		for(int i=1; i<=n;i++){
			sum = total - Math.abs(a[i]-a[i-1]) - Math.abs(a[i+1]-a[i]) + Math.abs(a[i+1]-a[i-1]);
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 63984
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class B123Triangle {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        string S;
        in>>N>>S;
        vc<int> A(N), par(N);
        REP(i, N) A[i] = S[i] - '1';
        par[0] = 0;
        RREP(i, N-1){
            int v1 = N - i, v2 = i, y = 0, z = 0;
            while(v1%2==0){
                ++y;
                v1 >>= 1;
            }
            while(v2%2==0){
                ++z;
                v2 >>= 1;
            }
            par[i] = par[i-1] + y - z;
        }
        int ans = 0, cnt1 = 0;
        REP(i, N){
            if(A[i]==1){
                ++cnt1;
                if(not par[i]) ans ^= 1;
            }
        }
        if(ans) out<<ans<<'\n';
        else if(cnt1) out<<0<<'\n';
        else{
            REP(i, N){
                if(not par[i] and A[i]==2) ans ^= 1;
            }
            out<<2*ans<<'\n';
        }
    }
};


int main() {
	B123Triangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9116