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

int main() {
	

	int n, k, q,tmp;
	cin >> n >> k >> q;
	vector<int> a(n,0);
	for (int i = 0; i < q; i++) {
		cin >> tmp;
		a.at(tmp - 1)++;
	}
	for (int i:a) {
		if ((k-q+i) <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 3792
main :: IO ()
main = do
  [n, m, x, y] <- getInts
  xs <- getInts
  ys <- getInts
  let
    mx = max x $ maximum xs
    my = min y $ minimum ys
    in
    putStrLn $ if mx < my
               then "No War"
               else "War"

getInts :: IO [Int]
getInts = map read . words <$> getLine


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s, t;
  cin >> s;

  int N = s.size();
  REP(i, N){
    if(i != N-1 && s[i] == 'B' && s[i+1] == 'C') t += "D", i++;
    else t += s[i];
  }

  int M = t.size();
  int cnt = 0, ans = 0;
  REP(i, M){
    if(t[i] == 'A') cnt++;
    else if(t[i] == 'D'){
      ans += cnt;
    }else{
      cnt = 0;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 128).readLine());
		short val = 100;//壱百千円
		for (; 0 < period; period--) {
			val = (short) Math.ceil(val * 1.05);
		}
		System.out.println(val * 1000);
	}
}

Measured memory_bytes: 17028
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  string s;
  cin>>s;
  string t=s;
  reverse(all(s));
  int ans=0;
  rep(i,len(s)){
    if(t[i]!=s[i]) ans++;
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 3636
import std;

const MOD = 10^^9 + 7;

long calc(int n, int k) {
    long ans = 0;
    for (long i = k; i <= n + 1; i++) {
        long lo = (0 + i - 1) * i / 2;
        long hi = (n - i + 1 + n) * i / 2;
        ans = (ans + hi - lo + 1) % MOD;
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3640
N = input()
A = [int(N[i]) for i in range(len(N))]
A.reverse()
A.append(0)

ans = 0

for i in range(len(A)):
    if A[i] > 5 or (A[i] == 5 and A[i+1] >= 5):
        ans = ans + (10 - A[i])
        A[i+1] = A[i+1] + 1
    else:
        ans = ans + A[i]

print(ans)


Measured memory_bytes: 13632
//049
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int H,W;
    string s;
    cin >> H >> W;
    rep(i, H){
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	S := getStdin()
	cnt := 0
	prev := ""
	for i := 0; i < 3; i++ {
		if S[i] == 'R' {
			if prev != "R" {
				cnt = 1
			} else {
				cnt++
			}
		}
		prev = string(S[i])
	}

	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+200;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 0x3f3f3f;
int main(){
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	double sum = 1.0*w*h/2;
	printf("%.6lf ",sum);
	if( w % 2 == 0 && h % 2 == 0){
		if(x == w/2 && y == h/2){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

ll solve(string S){
  ll d=0;
  REP(i,S.size()){
    if(S[i] == '+'){
      REP(j,i){
        d *= 10;
        d += S[j]-'0';
      }
      return d + solve(S.substr(i+1));
    }
  }
  REP(i,S.size()){
    d *= 10;
    d += S[i]-'0';
  }
  return d;
}

int main()
{
  ll N,res=0;
  string S,T;
  
  cin >> S;
  N = S.size();
  for(int i=0;i< (1 << (S.size()-1));i++){
    T = S;
    for(int j=N-2;j>=0;j--){
      if((i >> j) & 1){
        T.insert(T.begin()+1+j,'+');
      }
    }
    res += solve(T);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] != s[i]) res++;
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 512
<?php
list($n, $k) = ints();
$d = ints();
$nums = array_diff([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], $d);
foreach ($nums as $num) if ($num >= $n) exit((string) $num);
$nn = $nums;
$flag_zero = array_search(0, $nums) !== false;
for ($t = 1; true; ++$t) {
    $a = [];
    foreach ($nums as $num) {
        if ($num === 0) continue;
        foreach ($nn as $num2) {
            if (!$flag_zero && $num2 < 10 ** ($t - 1)) continue;
            $tmp = $num * 10 ** $t + $num2;
            $a[] = $tmp;
            if ($tmp >= $n) break 3;
        }
    }
    $nn = array_merge($nn, $a);
}
echo $tmp;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
mod=1000000007
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
pl=[]
mn=[]
zr=[]
a.each do |aa|
  if aa>0
    pl << aa
  elsif aa<0
    mn << aa
  else
    zr << aa
  end
end
pl.sort!.reverse!
mn.sort!
ni=pl.size
nj=mn.size
i=0
j=0
c=1
if nj==n
  if k.odd?
    mn.reverse!
    k.times do |jj|
      c=c*mn[jj]%mod
    end
    puts c
    exit
  else
    k.times do |jj|
      c=c*mn[jj]%mod
    end
    puts c
    exit
  end
end
if n==k
  a.each do |aa|
    c=c*aa%mod
  end
  puts c
  exit
end
while k>0
  if k==1||j>=nj-1
    if i<ni
      c=c*pl[i]%mod
      k-=1
      i+=1
    else
      c=0
      k-=1
    end
  elsif i<ni-1
    if pl[i]*pl[i+1]<mn[j]*mn[j+1]
      c=c*mn[j]*mn[j+1]%mod
      k-=2
      j+=2
    else
      c=c*pl[i]%mod
      k-=1
      i+=1
    end
  else
    c=c*mn[j]*mn[j+1]%mod
    k-=2
    j+=2
  end
end
puts c



Measured memory_bytes: 36200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,x,y,i,j,k,a,b;
	cin>>n>>x>>y;
	long long int arr[n+1][n+1];
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			arr[i][j]=max(i-j,j-i);
		}
	}
	arr[x][y]=1;
	arr[y][x]=1;
	/*for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cout<<arr[i][j]<<" ";
		}
		cout<<endl;
	}*/
	//cout<<endl;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			/*if(arr[i][y]>arr[i][x]+1){
				arr[i][y]=arr[i][x]+1;
				arr[y][i]=arr[i][x]+1;
			}
			else if(arr[i][x]>arr[i][y]+1){
				arr[i][x]=arr[i][y]+1;
				arr[x][i]=arr[i][y]+1;
			}*/
			if(arr[i][j]>arr[i][x]+arr[y][j]+1){
				arr[i][j]=arr[i][x]+arr[y][j]+1;
				arr[j][i]=arr[i][x]+arr[y][j]+1;
			}
		}
	}

		/*}
		*/
	/*for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cout<<arr[i][j]<<" ";
		}
		cout<<endl;
	}*/
	long long int res[n];
	for(i=0;i<n;i++){
		res[i]=0;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			res[arr[i][j]]++;
		}
	}
	for(i=1;i<n;i++){
		cout<<res[i]/2<<endl;
	}
	/*for(i=1;i<n;i++){
		k=0;
		for(a=1;a<=n;a++){
			for(b=a;b<=n;b++){
				if(arr[a][b]==i){
					k++;
				}
			}
		}
		cout<<k<<endl;
	}*/
	return 0;


}

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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int even=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]%2==0) even++;
  }
  
  int sim=pow(3,N);
  int all_odd=pow(2,even);
  
  cout << sim-all_odd <<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$n, $y);
$_10000=0;
$_5000=0;
$_1000=0;
$exist=0;
for($i=0; $i<=$n; $i++)
{
    $_10000 = $i;
    for($j=0; $i+$j<=$n; $j++)
    {
        $_5000=$j;
        $_1000 = ($y - 10000*$_10000 - 5000*$_5000)/1000;
        if($_1000>=0 && is_int($_1000) && $_10000+$_5000+$_1000 == $n)
        {
            $exist = 1;
            break 2;
        }
    }
}

if($exist == 1)
    echo($_10000." ".$_5000." ".$_1000."\n");
else
    echo("-1 -1 -1\n");

Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VL a(n-1);
    REP(i,n-1) a[i] = lin();
    VVL b(n, VL(m));
    REP(i,n) REP(j,m) b[i][j] = lin();

    VL d(n);
    REP(i,n-1) d[i+1] = d[i] + a[i];

    VVL s(n+1, VL(n+1));
    REP(i,m){
        vector<PL> p(n);
        REP(j,n) p[j] = PL(b[j][i], j);
        sort(ALL(p));
        reverse(ALL(p));
        set<int> st, st2;
        st.insert(1);
        st2.insert(n);
        REP(j,n){
            int x = p[j].second;
            int y = - *st.lower_bound(-x);
            int u = *st2.lower_bound(x);
            ll z = p[j].first;
            s[y+1][x] += z;
            s[x+1][u] += z;
            s[y+1][u] -= z;
            s[x+1][x] -= z;
            st.insert(-x);
            st2.insert(x);
            // cout << x << " " << y << " " << z << endl;
            // REP(ii,n+1){
            //     REP(jj,n+1){
            //         cout << s[ii][jj] << " ";
            //     }
            //     cout << endl;
            // }
        }
    }

    REP(i,n+1) REP(j,n) s[i][j+1] += s[i][j];
    REP(j,n+1) REP(i,n) s[i+1][j] += s[i][j];

    // REP(i,n){
    //     REP(j,n) cout << s[i][j] << " ";
    //     cout << endl;
    // }

    ll ans = 0;
    REP(i,n) FOR(j,i,n-1){
        ans = max(ans, s[i][j] - (d[j] - d[i]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 206184
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll a,b;
   cin>>a>>b;
   
   if(a<10 && b<10)
   {
       cout<<a*b;
       return 0;
   }
   
   cout<<-1;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define PB push_back
#define rep(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	string s, t;
	cin >> s >> t;
	bool f = 1;
	
	if (t.length() - s.length() == 1) {
		for (int i = 0; i < s.length(); i++)
			if (s[i] != t[i]) f = 0;
	} else f = 0;
	if (f) cout << Y;
	else cout << N;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//二項係数の計算
int nCr(ll A, ll B) {
    ll ans = 1;
    for (ll i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (ll i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
   ll N;
   cin>>N;
   vector<ll>A(N+1);
   vector<ll>B(N);
   rep(i,N+1){
       cin>>A[i];
   }
   ll ans=0;
   ll k=0;
   rep(i,N){
       cin>>B[i];
       bool a=true;
       while(a==true){
           if(k-i==2){
               a=false;
           }
           else{
       if(A[k]<=B[i]){
           ans+=A[k];
           B[i]-=A[k];
           k++;
       }
       else{
           A[k]-=B[i];
           ans+=B[i];
         if(k==i){
           k++;
         }
           a=false;
       }
       }
       }
   }
  cout<<ans<<endl;
}


Measured memory_bytes: 4712
//Name: Icicles
//Level: 2
//Category: シミュレーション
//Note:

/*
 * つららがどれか折れるまで，伸びているつららの集合は変化しない．
 * したがって，つららが折れる時刻をイベントとして時間順に処理していく．
 * つららが折れた場合，影響を受けるつららはその両隣のみであることに注意．
 */
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

inline bool check(const vector<int> &icicles, int pos) {
    const int N = (int)icicles.size();
    if(pos < 0 || pos >= N) return false;
    if(icicles[pos] == 0) return false;
    bool left = pos>0 ? icicles[pos-1] < icicles[pos] : true;
    bool right = pos+1<N ? icicles[pos+1] < icicles[pos] : true;
    return left && right;
}

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

    int N, L;
    cin >> N >> L;
    vector<int> icicles(N);
    for(int i = 0; i < N; ++i) {
        cin >> icicles[i];
    }
    int ans = 0;
    priority_queue<pair<int,int> > q;
    for(int i = 0; i < N; ++i) {
        if(check(icicles, i)) {
            int t = L - icicles[i];
            q.push(make_pair(-t, i));
        }
    }
    while(!q.empty()) {
        int t = -q.top().first;
        int pos = q.top().second;
        q.pop();
        ans = t;

        icicles[pos] = 0;
        if(check(icicles, pos-1)) {
            int nt = t + L - icicles[pos-1];
            q.push(make_pair(-nt, pos-1));
        }
        if(check(icicles, pos+1)) {
            int nt = t + L - icicles[pos+1];
            q.push(make_pair(-nt, pos+1));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    int AB = 0;
    int A_end = 0;
    int B_start = 0;

    int same = 0;

    string S = "AB";

    vector<string> s(N);
    for (int i = 0; i < N; ++i) {
        bool same_flg = false;

        cin >> s[i];

        for (int j = 0; j < s[i].size() - S.size() + 1; ++j) {
            if (s[i].substr(j, S.size()) == S) {
                ++AB;
            }
        }

        if (s[i].find_last_of('A') == s[i].size() - 1) {
            ++A_end;
            same_flg = true;
        }

        if (s[i].find_first_of('B') == 0) {
            ++B_start;
            if (same_flg) {
                ++same;
            }
        }
    }

    if (A_end > 0 && A_end == B_start && B_start == same) {
        cout << AB + same - 1 << endl;
    } else {
        cout << AB + min(A_end, B_start) << endl;
    }
}

Measured memory_bytes: 768
n, m = map(int, raw_input().split())

g = [[i] for i in xrange(n)]

for _ in xrange(m):
    u, v = map(lambda x: int(x) - 1, raw_input().split())
    g[u].append(v)
    g[v].append(u)

q = input()
c = [None] * q
dp = [[-1 for j in range(n)] for i in xrange(11)]
for i in xrange(q):
    v, d, c[i] = map(int, raw_input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    dp[i - 1] = [max(dp[i - 1][u], max(dp[i][v] for v in g[u])) for u in range(n)]

for i in xrange(n):
    if dp[0][i] == -1:
        print('0')
    else:
        print(c[dp[0][i]])

Measured memory_bytes: 73244
use std::io;

fn extract(a: &mut Vec<i32>) -> i32 {
    if a.len() < 1 {
        return i32::min_value();
    }

    let maxv;
    maxv = a[1];
    a[1] = *a.last().unwrap();
    a.pop();
    max_heapify(a, 1);
    maxv
}

fn increase_key(key: i32, a: &mut Vec<i32>) {
    let mut i = a.len() - 1;
    if key < a[i] {
        return;
    }
    a[i] = key;
    while i > 1 && a[i / 2] < a[i] {
        a.swap(i, i / 2);
        i = i / 2;
    }
}

fn insert(key: i32, a: &mut Vec<i32>) {
    a.push(i32::min_value());
    increase_key(key, a);
}

fn main() {
    let mut a: Vec<i32> = vec![-1]; // -1: dummy key
    let mut key: i32;

    loop {
        let input = read_line();

        if input == String::from("end") {
            break;
        }
        if input.starts_with("insert") {
            let mut iter = input.split_whitespace();
            iter.next(); // "input"
            key = iter.next().unwrap().parse().unwrap();
            insert(key, &mut a);
        } else {
            println!("{}", extract(&mut a));
        }
    }
}

// Utilities
fn read_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    input.trim().to_string()
}

fn left(i: usize) -> usize {
    2 * i
}

fn right(i: usize) -> usize {
    2 * i + 1
}

fn max_heapify(a: &mut Vec<i32>, i: usize) {
    let h = a.len() - 1;

    let l = left(i);
    let r = right(i);

    let mut largest: usize;

    if l <= h && a[l] > a[i] {
        largest = l;
    } else {
        largest = i;
    }

    if r <= h && a[r] > a[largest] {
        largest = r;
    }

    if largest != i {
        a.swap(i, largest);
        max_heapify(a, largest);
    }
}



Measured memory_bytes: 9960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int L = cin.nextInt();
        int R = cin.nextInt();

        int ans = 0;


        int tmp0 = L % 2019;
        int tmp1 = R % 2019;

        int min = int.MaxValue;

        if (R - L >= 2019 || tmp0 > tmp1)
        {
            ans = 0;
        }
        else
        {
            for (int i = tmp0; i <= tmp1 - 1; ++i)
            {
                for (int j = i + 1; j <= tmp1; ++j)
                {
                    int tmp = (i * j) % 2019;
                    if (min > tmp) min = tmp;
                }
            }

            ans = min;
        }

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  int ans = 1, mx = 0;
  FORIN(i, 1, N + 1) if (mx < __builtin_ctz(i)) {
    mx = __builtin_ctz(i);
    ans = i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[][][] summary = new long[10][45][45];
        for (int i = 0; i < N; i++) {
            String temp = scan.next();
            int digits = 0;
            long x = 0;
            if (temp.indexOf(".") == -1) {
                x = Long.parseLong(temp);
            } else {
                String t = temp.substring(temp.indexOf(".") + 1);
                if (Long.valueOf(t) == 0) {
                    t = "";
                }
                digits = t.length();
                String tt = temp.substring(0, temp.indexOf(".")) + t;
                x = Long.parseLong(tt);
            }
            int two_count = this.count(2, x);
            int five_count = this.count(5, x);
            summary[digits][two_count][five_count] += 1;
        }
        long temp1 = 0;
        long temp2 = 0;
        for (int digit_count = 0; digit_count < 10 ; digit_count++) {
            for (int two_count = 0; two_count < 45; two_count++) {
                for (int five_count = 0; five_count < 45; five_count++) {
                    if (summary[digit_count][two_count][five_count] == 0) {
                        continue;
                    }
                    for (int j = 0; j < 10; j++) {
                        int total_digits = digit_count + j;
                        for (int k = 0; k < 45; k++) {
                            for (int l = 0; l < 45; l++) {
                                if (summary[j][k][l] == 0) {
                                    continue;
                                }
                                int count = Math.min(two_count + k, five_count + l);
                                if (total_digits <= count) {
                                    if (j == digit_count && k == two_count && l == five_count) {
                                        temp1 += summary[j][k][l]*(summary[j][k][l]-1)/2;
                                    } else {
                                        temp2 += summary[digit_count][two_count][five_count] * summary[j][k][l];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        System.out.println(temp1+temp2/2);
    }
    private int count(long base, long x) {
        int count = 0;
        while (x % base == 0) {
            count += 1;
            x /= base;
        }
        return count;
    }
}


Measured memory_bytes: 61424
import java.io.*;

class Main{
    public static void main(String[] args) {
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(x*x*x);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24184
//負数が偶数個：全部正数にできる
//負数が奇数個：全部正数にする（ただしこのときは一つの正数を負数にする必要がある）
//あるいは負数を1つそのままにしとく
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
    long long N,nega=0,negamax=-mod,posimin=mod;
    long long ans=0;
    cin >> N;
    vector<long long>A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A.at(i);
        ans += abs(A.at(i));
        if (A.at(i) >= 0)posimin = min(A.at(i), posimin);
        else {
            negamax = max(negamax, A.at(i));
            nega++;
        }
    }
    if(nega%2)ans -= min(-negamax, posimin) * 2;
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

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

int main(){
	int n;
	cin >> n;
	if(n == 1){
		dump("Hello World");
	}
	else {
		int a,b;
		cin >> a >> b;
		dump(a + b);
	}
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		if (A == B) {
			System.out.println(C);
		} else if (B == C) {
			System.out.println(A);
		} else {
			System.out.println(B);
		}

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27112
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

void solve() {
  n = unique(a, a + n) - a;

  int res = 0;

  int pos = 0;
  while (pos < n) {
    int sgn = (a[pos + 1] > a[pos]);
    ++pos;
    for (; pos < n && (a[pos] > a[pos - 1]) == sgn; ++pos) ;
    ++res;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll h;
    cin >> h;
    ll ans = 0, d = 1;;
    while (h > 0) {
        ans += d;
        h /= 2;
        d *= 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n;
	cin >> n;
	long long int a[100001], b[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	long long int ans = 0;
	long long int tmp = 0;
	for(int i = n - 1; i >= 0; i--){
		long long int tarinai = (b[i] - (a[i] + tmp) % b[i]) % b[i];
		ans += tarinai;
		tmp += tarinai;
		// cout << ans << " " << tmp << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
	vector<int > str[100005];
	int h[100005];
int main()
{
	int N,M;
	cin>>N>>M;
	
	for(int i=1;i<=N;i++)
	 cin>>h[i];

	for(int i=1;i<=M;i++)
	{
		int x,y;
		cin>>x>>y;
		str[x].push_back(y);
		str[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=N;i++)
	{
		int flag=1;
		for(int j=0;j<str[i].size();j++)
		{
			int k=str[i][j];
			if(h[k]>=h[i])
			{
				flag=0;
				break;
			}
		}
		if(flag==1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	ll n,k;
	string s;
	cin>>n>>s>>k;
	k--;
	for(int i=0;i<s.length();i++){
		if(s[i]==s[k])cout<<s[i];
		else cout<<"*";
	}
	cout<<endl;
}


Measured memory_bytes: 256
from bisect import bisect_right

N = int(input())
A = [int(input()) for i in range(0,N,1)]

maxs = []#今まで塗ってきた各色の最大値 の負の値を入れるといろいろ楽なんですよまあ見ててよ

for i in range(0,N,1):
    to_insert = bisect_right(maxs,-A[i])
    if len(maxs)==0:#最初の一回
        maxs.insert(0,-A[i])
    else:
        if to_insert < len(maxs):
            maxs[to_insert]=-A[i]
        else:
            maxs.append(-A[i])

print(len(maxs))

        

Measured memory_bytes: 84132
s = input()
if len(s) % 2 == 0:
    flag = 1
else:
    flag = 0

def search_ss(s, flag):
    for i in range(len(s) - 1 - flag, -1, -2):
        judge = True
        for j in range(i // 2):
            if s[j] != s[i // 2 + j]:
                judge = False
                break
        if judge == True:
            print(i)
            exit()

search_ss(s, flag)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, n, x[100100], y[100100], res[10];
map<pair<int,int>, int> p;
set<pair<int,int> > s;

void cnt(int a, int b) {
	if (s.count({a,b})) return;
	s.insert({a,b});
	int sum = 0;
	reps(i,a,a+3) reps(j,b,b+3) {
		if (ool(i,j,h,w)) return;
		sum += p[{i,j}];
	}
	if (sum) res[sum]++;
}

signed main() {
	cin >> h >> w >> n;
	rep(i,n) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
		p[{x[i],y[i]}]++;
	}
	rep(k,n) rep(i,3) rep(j,3) cnt(x[k]-i,y[k]-j);
	cout << (h-2)*(w-2) - accumulate(res,res+10,0) << endl;
	reps(i,1,10) cout << res[i] << endl;
}

Measured memory_bytes: 214272
a, b, c, x, y = [int(i) for i in input().split(" ")]

#cost for a = min(a, 2*c)
#cost for b = min(b, 2*c)

print(min((x*a + y*b), 2*c*x + b*(max(y-x,0)), (2*c*y + a*(max(x - y,0)))))


Measured memory_bytes: 2940
# coding: utf-8


output = []
# ??????????????????
while (1):
    texts = input().strip()
    if (texts == '-'):
        break

    # ?????£??????????????°
    m = int(input())
    
    # ?????£??????????????°??????????????????
    for i in range(m):
        h = int(input())
        temp_texts = texts[:h]
        new_texts = texts[h:] + temp_texts

        texts = new_texts
    output.append(texts)

for i in output:
    print(i)

Measured memory_bytes: 7604
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll w,h,x,y;
	cin >> w >> h >> x >> y;
	
	cout << (double)(w*h)/2 << " ";
	
	if(w == x*2 && h == y*2)cout << 1 << endl;
	else cout << 0 << endl;
	
    return 0;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[1050][1050];
int main(){
	int n;
	cin>>n;
	while(n--){
		memset(dp, 0, sizeof(dp));
		string str1,str2;
		cin>>str1>>str2;
		//int l =min(str1.length(),str2.length());
		for(int i =0;i <str1.length();i++){
			for(int j =0;j <str2.length();j++){
				if(str1[i]==str2[j]){
					dp[i+1][j+1]=dp[i][j]+1;
				}else{
					dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
				}
			}
		}
		cout <<dp[str1.length()][str2.length()]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5520
n=gets.to_i
a=Array.new(n)
for i in 0 ... n; a[i] = gets.to_i; end
pool = Array.new(n)
for i in 0 ... n; pool[i] = a[i] ^ (a[i] - 1); end
pool.sort!
pool.reverse!
cnt=0
rem=0
for i in 0...n;rem^=a[i];end
for p in pool
  if (rem^p)<rem
    rem^=p
    cnt+=1
  end
end
puts rem==0? cnt:-1

Measured memory_bytes: 4480
from collections import deque
n = int(input())
a = []
for i in range(n):
    tmp = deque()
    for j in input().split():
        j = int(j)-1
        tmp.append((min(i, j), max(i, j)))
    a.append(tmp)
nxt = []
q = set()
flg = True
for i in range(n):
    t = a[i].popleft()
    if t in q:
        nxt.append(a[t[0]].popleft())
        nxt.append(a[t[1]].popleft())
        q.remove(t)
        flg = False
    else:
        q.add(t)
if flg:
    print(-1)
    exit(0)
ans = 1
while nxt:
    now = nxt[:]
    nxt = []
    flg = True
    for t in now:
        if t in q:
            if a[t[0]]:
                nxt.append(a[t[0]].popleft())
            if a[t[1]]:
                nxt.append(a[t[1]].popleft())
            q.remove(t)
            flg = False
        else:
            q.add(t)
    if flg:
        print(-1)
        exit(0)
    ans += 1
print(ans)

Measured memory_bytes: 110348
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
		printf("3C%02d\n", n % 39 ? n % 39 : 39);

	return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;




//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)




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

	s[3] = '8';

	cout << s << endl;


	return 0;
}



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

int main() {
	//ios_base::sync_with_stdio(false);
	cin>>n;
	int a,b;
	cin>>a>>b;
	cout<<min(a,b)<<" "<<max(a+b-n,0);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> pe;
    SORT(A);
    vector<ll> sum(N);
    sum[0]=A[0];
    reps(i,1,N) sum[i]=sum[i-1]+A[i];
    ll ans=0;
    rep(i,N-1){
        if(sum[i]*2<A[i+1]) ans=i+1;
    }
    cout<< N-ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
N = int(input())
L = list(map(int, input().split()))
C = sorted(L)
def X(n,j):
    L1 = j+1
    L2 = N-1
    while L1 != L2:
        a = (L1+L2)//2
        if C[a] == n:
            while C[a] == C[a-1]:
                a = a-1
            return len(C[j+1:a])
        elif L2 - L1 <= 1:
            if C[L2] < n:
                return len(C[j+1:L2+1])
            elif C[L1] < n <= C[L2]:
                return len(C[j+1:L2])
            while C[L1] == C[L1-1]:
                if j+1 <= L1-1:
                    L1 = L1-1
                else:
                    break
            if C[L1] > n:
                return len(C[j+1:L1])
            elif C[L1] == n:
                return len(C[j+1:L1])
        elif C[a] < n:
            L1 = a
        else:
            L2 = a
    if C[L1] < n:
        return 1
    else:
        return 0
ans = 0
# print(C)
for i in range(N-2):
    for j in range(i+1,N-1):
        # print(X((C[i]+C[j]),j))
        ans += X((C[i]+C[j]),j)
print(ans)

Measured memory_bytes: 55644
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    int sum=0;

    vector<int>a(n);
    for (int i=0;i<n;i++) {
        cin>>a[i];
        sum+=a[i];
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int sumalice=0;

    for (int i=0;i<n;i++) {
        if(i%2==0){
            sumalice+=a[i];
        }
    }

    cout<<(sumalice-(sum-sumalice))<<endl;

}


Measured memory_bytes: 256