akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const int  NMAX=1e5+3,MOD=1e9+7;
int n,dp[2][NMAX]; // dp[1][i] si i est peint en noir dp[0][i] si il est peint en blanc
pair<int,int> vertices[NMAX];
vector<int> voisins[NMAX];


int multmod(int x,int y,int mod){
	
	int res=0;
	
	while(y!=0){
		//cout << x << ' ' << y << endl;
		if(y%2==1){
			res=(res+x)%mod;
		}
		x=(x+x)%mod;
		y/=2;
	}
	
	return res;
}
			
void denombrer(int noeud,int pere){
	
	int sz=voisins[noeud].size();
	
	for(int id=0;id<sz;id++){
		int voisin=voisins[noeud][id];
		
		if(voisin!=pere){
			denombrer(voisin,noeud);
		}
	}
	
	dp[0][noeud]=1;
	dp[1][noeud]=1;
	
	for(int id=0;id<sz;id++){ 
		int voisin=voisins[noeud][id];
		
		if(voisin!=pere){
			
			dp[0][noeud]=multmod(dp[0][noeud],(dp[0][voisin]+dp[1][voisin])%MOD,MOD);
			dp[1][noeud]=multmod(dp[1][noeud],dp[0][voisin],MOD);
		}
	}
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> n;
	
	for(int i=0;i<n-1;i++){
		int x,y;
		cin >> x >> y;
		
		voisins[x].push_back(y);
		voisins[y].push_back(x);
		
	}
	//cout << multmod(5,4,MOD) << endl;;
	denombrer(1,-1);
	
	cout << (dp[1][1]+dp[0][1])%MOD << '\n';
    return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>

int main(void) {
  int l, m, n, save, i, month;

  while (1) {
    save = 0;
    month = 0;
    scanf("%d", &l);
    if (l == 0) break;
    
    for (i = 0; i < 12; i++) {
      scanf("%d%d", &m, &n);
      if (month == 0) {
	save += m - n;
	if (save >= l) {
	  month = i + 1;
	}
      }
    }
    
    if (month)
      printf("%d\n", month);
    else
      printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include <unordered_map>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

unordered_map<LL,LL> m1;
priority_queue<LL> q1;

void check(LL x,LL y){
	if(m1.find(x)==m1.end())m1[x]=y,q1.push(x);
	else if(m1[x]>y)m1[x]=y;
}

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c,d;
	LL x,y,z;
	int tes;
	cin>>tes;
	while(tes--){
		m1.clear();
		cin>>n>>a>>b>>c>>d;
		LL s=(LL)1<<60;
		q1.push(n);
		m1[n]=0;
		while(!q1.empty()){
			x=q1.top(),q1.pop();
			y=m1.at(x);
			if(s/x>=d-1)s=min(s,y+x*d);
			if(x==1)break;
			if(x%2==0)check(x/2,y+a);
			else check(x/2,y+a+d),check(x/2+1,y+a+d);

			if(x%3<=1)check(x/3,y+b+(x%3)*d);
			else check(x/3+1,y+b+d);
			
			if(x%5<=2)check(x/5,y+c+(x%5)*d);
			else check(x/5+1,y+c+(5-x%5)*d);
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 4116
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

map<pll,ll> dp;

ll arr1[200010];

ll evaluate(ll items,ll left)
{
    if(dp.find({items,left})!=dp.end())
    {
        return dp[{items,left}];
    }
    if(items <= 0)
    {
        if(left==0)
            return 0;
        else
            return NEGINF;
    }
    ll val1=(items/2)-1;
    ll val2=(items+1)/2;
    if(left<val1 || left>val2)
    {
        return NEGINF;
    }
    ll ans=evaluate(items-1,left);
    ans=max(ans,evaluate(items-2,left-1)+arr1[items]);
    dp[{items,left}] = ans;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>arr1[i];
    }
    ll val= n/2;
    ll ans = evaluate(n,val);
    cout<<ans;
    return 0;
}
    

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


int dp[1001][1001];

signed main(){

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

	char a[1001][1001];
	for (int h = 0; h < H; h++)
		for (int w = 0; w < W; w++) cin >> a[h][w];

	dp[0][0] = 1;
	for (int h = 0; h < H; h++){
		for (int w = 0; w < W; w++){
			if (h == 0 && w == 0) continue;
			if (a[h][w] == '#') {
				dp[h][w] = 0;
				continue;
			}
			if (h - 1 >= 0)
				dp[h][w] += dp[h - 1][w];
			if(w-1>=0)
				dp[h][w] += dp[h][w - 1];
			dp[h][w] %= mod;
		}
	}
	cout << dp[H - 1][W - 1] << endl;
	
	return 0;
}


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

int main() {
    double P1[2], P2[2], x, y;

    cin >> P1[0] >> P1[1];
    cin >> P2[0] >> P2[1];
    x = P1[0]-P2[0];
    y = P1[1]-P2[1];
    cout << fixed;
    cout.precision(5);
    cout << sqrt(x*x + y*y) << endl;

    return 0;
}

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

const int MOD = 1e9 + 7;

vector<vector<int>> g;

vector<bool> visited;

int dfs(int v) {
	int size = 1;
	visited[v] = true;
	for (int u: g[v])
		if (!visited[u])
			size += dfs(u);
	return size;
}

void solve_test() {
	int n, m;
	cin >> n >> m;
	g.resize(n);
	for (int i = 0; i < n; i++) g[i].clear();
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	visited.resize(n);
	for (int i = 0; i < n; i++) visited[i] = false;

	vector<int> component_sizes;
	for (int i = 0; i < n; i++)
		if (!visited[i])
			component_sizes.push_back(dfs(i));

	cout << *max_element(component_sizes.begin(), component_sizes.end()) << '\n';
}

int32_t main() {
	int T; 
	// cin >> T;
	T = 1;
	while (T--)
		solve_test();

	return 0;
}


Measured memory_bytes: 23552
n,c,m[1001],M[1001],R;main(x){for(;scanf("%d\n",&n),n;printf("%d\n",R))for(memset(M,R=0,4004);n--;memcpy(M,m,4004))for(x=1;c=getchar()-10;x++)R=(m[x]=c-32?(c=M[x-(M[x-1]<M[x])],c<m[x-1]?c:m[x-1])+1:0)>R?m[x]:R;exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;

int rec(int line, vector<vector<int>> g, int depth, vector<int> dp){
  dp[line] = 1;
  if(depth == g[0].size()){
    int check = 0;
    for(int i = 0 ; i < g[0].size(); i++){
      check += dp[i];
    }
    if(check == g[0].size()){
      return 1;
    }else{
      return 0;
    }
  }
  int ans = 0;
  for(int i = 0; i < g[0].size(); i++){
    if(g[line][i] == 1){
      vector<vector<int>> gtmp = g;
      for(int j = 0; j < g[0].size(); j++){
        gtmp[j][i] = 2;
      }
      gtmp[i][line] = 2;
      ans += rec(i, gtmp, depth+1, dp);
    }
  }
  return ans;
}

int main(){

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n,vector<int>(n,0));
  vector<int> dp(n,0);
  int a, b;
  for(int i = 0; i < m; i++){
    cin >> a >> b;
//    cout << a << b<<endl;
    g[a-1][b-1] = 1;
    g[b-1][a-1] = 1;
  }
  
//  for(int i = 0; i < n; i++){
//    for(int j = 0; j < n; j++){
//      cout << g[i][j] << " ";
//    }
//    cout << endl;
//  }
//
  cout << rec(0,g,1,dp) << endl;;
  return 0;
} 


Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
    ll n,l;
    cin>>n>>l;
    ll a[n];
    ll sum=0;
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        a[i]=l+i;
        sum+=a[i];
        if(a[i]==0)
        {
            flag=1;
        }
    }
    sort(a,a+n);
    if(flag==0)
    {
        ll j=0;
        while(a[j]<0 && j<n)
        {
            j++;
        }
        if(j>0)
            sum-=a[j-1];
        else
            sum-=a[0];
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

count = 0
nowLetter = "R"
array = []
ans = []
for l in S:
    if l == nowLetter:
        count += 1
    else:
        array.append(count)
        count = 1
        nowLetter = l
        if nowLetter == "R":
            a, b = array[0], array[1]
            part = [0] * (a+b)
            if a % 2 == 0:
                part[a-1] = (a+b) // 2
                part[a] = -(-(a+b) // 2)
                ans += part
                array = []
                part = []
            else:
                part[a-1] = -(-(a+b) // 2)
                part[a] = (a+b) // 2
                ans += part
                array = []
                part = []
            
array.append(count)
a, b = array[0], array[1]
part = [0] * (a+b)
if a % 2 == 0:
    part[a-1] = (a+b) // 2
    part[a] = -(-(a+b) // 2)
    ans += part
    array = []
    part = []
else:
    part[a-1] = -(-(a+b) // 2)
    part[a] = (a+b) // 2
    ans += part
    array = []
    part = []
print(" ".join(map(str,ans)))
        


Measured memory_bytes: 10980
//04
#include<iostream>
#include<cmath>

using namespace std;

#define PI acos(-1)
#define R 6378.1
#define S(X) ((X)*(X))

int main(){
  for(;;){
    double x[2],y[2],z[2];
    for(int i=0;i<2;i++){
      double a,b;
      cin>>a>>b;
      if(a==-1&&b==-1)return 0;
      y[i]=R*sin(a/180*PI);
      x[i]=R*cos(a/180*PI)*cos(b/180*PI);
      z[i]=R*cos(a/180*PI)*sin(b/180*PI);
    }
    cout<<int(2*R*asin(sqrt(S(x[0]-x[1])+S(y[0]-y[1])+S(z[0]-z[1]))/2/R)+.5)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
using namespace std;

int main()
{
    unsigned long n,q,k,all;
    bitset<30> a(0),b(0);
    cin>>n;
    all=1<<n;
    cin>>n;
    while(n--){
        cin>>q;
        b.set(q,1);
    }
    for(int i=0;i<all;i++){
        a=i;
        if((a|b)==b){
            cout<<i<<":";
            for(int i=0;i<30;i++){
                if(a.test(i)){
                    cout<<" "<<i;
                }
            }
            cout<<"\n";
        }
    }

}





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

using namespace std;

typedef long long ll;

int n; ll a, b;
int x[100100];

int main() {
    int i;
    ll res = 0;

    scanf("%d%lld%lld",&n,&a,&b);
    for (i=0;i<n;i++) scanf("%d",&x[i]);
    for (i=1;i<n;i++) res += min(a*(x[i]-x[i-1]),b);
    printf("%lld\n",res);


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

signed main() {
  init();
  ll N, L;
  cin >> N >> L;
  vll A(N);
  cin >> A;

  bool ok = false;
  ll last_index = 0;
  rep(i, N - 1) if (A[i] + A[i + 1] >= L) {
    last_index = i;
    ok = true;
  }

  if (ok) {
    COUT("Possible");
  } else {
    COUT("Impossible");
    return 0;
  }

  vll ans;
  rep2(i, last_index, N - 1) ans.pb(i);
  repr(i, last_index - 1) ans.pb(i);
  REVERSE(ans);
  rep(i, ans.size()) COUT(ans[i] + 1);

  return 0;
}

Measured memory_bytes: 5092
#include<stdio.h>
#include<math.h>
#define N 1000000
      
int main(){
	int i,j,r=2,n,furui[N]={0},count=0;
double k;

while(scanf("%d",&n)!=EOF){

	k=sqrt(n);
	for(i=0;i<=n;i++)furui[i]=i;
	i=0;
	while(i<=k){

	for(i=2;i<=k;i++){

		if(furui[i]!=0){
			r=furui[i];
			count++;
			break;}
	}
	for(j=r;j<=n;j+=r)furui[j]=0;

	}

	for(i=2;i<=n;i++)if(furui[i]!=0)count++;


if(n==2)count=1;
if(n==3)count=2;
if(n==4)count=2;


printf("%d\n",count);
count=0;
}

    return 0;
}

Measured memory_bytes: 4512
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let N = read int
    let AB = Array.zeroCreate N
    for i in 0 .. N - 1 do
        let [| a; b |] = reada int
        AB.[i] <- (a, b)

    let x, y =
        AB
        |> Array.maxBy (fun (a, b) -> a)
        |> fun (a, b) -> a, b

    x + y |> printfn "%d"

    0 // return an integer exit code


Measured memory_bytes: 23220
while str = STDIN.gets
  n = str.split(" ")
  W = n[0].to_i
  H = n[1].to_i
  x = n[2].to_i
  y = n[3].to_i
  r = n[4].to_i

  if W < x+r || H < y+r  || x < r || y < r
    puts "No"
    else
    puts "Yes"
  end
end



Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
#define ENUM_v(vec) for (auto e : vec)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)

using namespace std;
typedef vector<short> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<VVB> VVVB;

int main(void) {
	long N;
	cin >> N;
	bool flg;
	string S;
	VVI arr(2*N,VI(2*N));
	REP(i,N) {
		cin >> S;
		REP(j,N) {
			arr[i][j] = (S[j] - 'a');
			arr[i+N][j] = arr[i][j+N] = arr[i+N][j+N] = arr[i][j];
		}
	}
	long long cnt = 0;
	REP(k,N) {
		flg = true;
		REP(x,N) {
			REP(y,N) {
				if (arr[k+x][y] != arr[k+y][x]) flg = false;
				if (!flg) break;
			}
			if (!flg) break;
		}
		if (flg) cnt += N;
	}
	
	cout << cnt << endl;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int sum = 0;
  for (int i=0; i<m; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  if (sum <= n) cout << n - sum << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3636
import java.io.*;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s[];
			int a[] = new int[3];
			boolean flag = false;
			int n = Integer.parseInt(reader.readLine());
			for(int i = 0;i < n;i++) {
				s = reader.readLine().split(" ");
				for(int j = 0;j < a.length;j++) {
					a[j] = Integer.parseInt(s[j]);
				}
				for(int k = 0;k < 3;k++) {
					if(a[k%3]*a[k%3]+a[(k+1)%3]*a[(k+1)%3] == a[(k+2)%3]*a[(k+2)%3]) {
						flag = true;
						break;
					}
				}
				if(flag) {
					System.out.println("YES");
					flag = false;
				}
				else
					System.out.println("NO");
			}

		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

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

using i64 = int64_t;

int arr[100005]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        arr[a]++;
    }
    int cnt = 0;
    for(int i=1;i<=100000;++i){
        cnt += max(0, arr[i]-1);
    }

    cout << n - (cnt+1)/2 * 2 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s;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;
  }
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        if (a + b <= c*2) {
            System.out.println(a*x+b*y);
            return;
        }
        
        int tmp = Math.min(x,y);
        
        int tmp2 = c * tmp * 2;
        
        int tmp3 = a * (x-tmp);
        int tmp4 = b * (y-tmp);
        
        int tmp5 = Math.max(x,y) * c * 2;
        
        int ans = Math.min(tmp5, tmp2+tmp3+tmp4);
        
        System.out.println(ans);
    }
}

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

int main() {
  long long X,K,D;
  long long s,t;
  
  
  cin >> X >> K >> D;
  if(abs(X) / D > K){
    cout << abs(X) - K*D << endl;
    return 0;
  }else{
    s = abs(X) % D;
    t = abs(s - D);
    if(K%2 == (abs(X) / D) % 2){
      cout << s << endl;
      return 0;
    }else{
      cout << t << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

struct Point{
public:
    int x,y;
    Point(int x,int y){
        this->x=x;
        this->y=y;
    }
};

double square(double x){return x*x;}
double distance(Point p1,Point p2){return sqrt( square(p1.x-p2.x) + square(p1.y-p2.y) );}

int factorial(int n){
    int f=1;
    for(int i=1;i<=n;i++){f*=i;}
    return f;
}
void solve(){
    
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    cout<<( (k%2==0) ? a-b : b-a )<<endl;
}

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

Measured memory_bytes: 3704
using System;
using System.Linq;
using System.Collections.Generic;

class Dice
{
    public int[] number = new int[6];

    private int[] tmp = new int[6];

    public void SetNumber (int[] a)
    {
        for (int i = 0; i < 6; i++)
        {
            number[i] = a[i];
        }
    }

    public void Rotate(char c)
    {

        switch (c)
        {
            case 'N':
                tmp[0] = number[1];
                tmp[1] = number[5];
                tmp[2] = number[2];
                tmp[3] = number[3];
                tmp[4] = number[0];
                tmp[5] = number[4];
                SetNumber(tmp);
                break;
            case 'E':
                tmp[0] = number[3];
                tmp[1] = number[1];
                tmp[2] = number[0];
                tmp[3] = number[5];
                tmp[4] = number[4];
                tmp[5] = number[2];
                SetNumber(tmp);
                break;
            case 'W':
                tmp[0] = number[2];
                tmp[1] = number[1];
                tmp[2] = number[5];
                tmp[3] = number[0];
                tmp[4] = number[4];
                tmp[5] = number[3];
                SetNumber(tmp);
                break;
            case 'S':
                tmp[0] = number[4];
                tmp[1] = number[0];
                tmp[2] = number[2];
                tmp[3] = number[3];
                tmp[4] = number[5];
                tmp[5] = number[1];
                SetNumber(tmp);
                break;
            default:
                break;
        }
    }
}

class MyClass
{
    public static void Main(string[] args)
    {
        var dice = new Dice();
        dice.SetNumber(Console.ReadLine().Split().Select(int.Parse).ToArray());
        var str = Console.ReadLine();
        foreach (var item in str)
        {
            dice.Rotate(item);
        }
        Console.WriteLine(dice.number[0]);
    }
}


Measured memory_bytes: 18396
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    string s;
    cin >> s;
    rep(i, s.length()){
        if(i%2==1 && s[i]=='R'){
            cout << "No" << endl;
            return 0;
        }
        else if(i%2==0 && s[i]=='L'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            int s;
            int m = 0;
            s = int.Parse(Console.ReadLine());
            var array = new List<int>{s};

            for (var i = 0; ;i++)//見つけるまで繰り返す
            {
                if(array[i] % 2 != 0)
                {
                    array.Add(array[i] * 3 + 1);
                }else{
                    array.Add(array[i] / 2);
                }
                for (var j = 0; j < array.Count-1 ;j++)
                {
                    if (array[i+1] ==array[j])
                    {
                        m = i + 2;//問題の数列はindexが1から開始の為
                        break;
                    }
                }
                if(m != 0)
                {
                    break;
                }
            }
            Console.WriteLine(m);
        }

    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int A, B, C, X, Y;
int _min(int x, int y) { return x < y ? x : y; }
int main() {
	int i, j, k;
	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
	int ans = 0;
	int p = X < Y ? X : Y;
	if(A+B > 2*C) ans = p*2*C, X -= p, Y -= p;
	ans += X*_min(A, 2*C)+Y*_min(B, 2*C);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int datamax;
	int datanum;
	int hour,min;
	int kakudo;
	scanf("%d",&datamax);
	for(datanum=0;datanum<datamax;datanum++) {
		scanf("%d:%d",&hour,&min);
		kakudo=hour*360/12*2;
		kakudo+=min;
		kakudo-=min*360/60*2;
		if(kakudo<0)kakudo=-kakudo;
		if(kakudo>180*2)kakudo=360*2-kakudo;
		if(kakudo<30*2)puts("alert");
		else if(kakudo>=90*2)puts("safe");
		else puts("warning");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
long max(long a,long b){
if(a>b)return a;
return b;
}
long min(long a,long b){
if(a<b)return a;
return b;
}

int main(){
  long n,now=0,ans=200007,l,r,R=0,W=0; cin>>n;
  char c[n];
  rep(i,n){
    cin>>c[i];
    if(c[i]=='R')R++;
    else  W++;
  }
  
  
  l=0; r=n-W;
  
  rep(i,n){
    ans=min(ans,max(l,r));
    if(c[i]=='R')r--;
    else l++;
  }
  
  if(R==0||W==0)ans=0;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI

using namespace std;

int main(void){
    int a, b; cin >> a >> b;
    if((a + b) % 2 != 0 ) cout << "IMPOSSIBLE" << endl;
    else cout << (a + b)/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
while True:
    height, width = [int(x) for x in input().split(" ")]
    if height == width == 0:
        break
    print("#" * width)
    column = "#" + "." * (width - 2) + "#"
    for i in range(height - 2):
        print(column)
    print("#" * width + "\n")

Measured memory_bytes: 7640
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = ""
a = 0
ans = 0
for i,e in enumerate(s):
    if e == "A":
        a += 1
    elif s[i:i+2] == "BC":
        ans += a
    elif s[i-1:i+1] == "BC":
        continue
    else:
        a = 0
print(ans)

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

int main()
{
    ll n,t,a,b,c,d,e,p,q;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
    ll ac=0,tle=0,wa=0,re=0;
     cin>>n>>a>>b;
     ll cnt;
     //cout<<n/a<<endl;
     if(n%a==0){
        cnt=(n/a);
        //cout<<"p"<<endl;
     }
     else {
            cnt=(n/a)+1;
     }
    //cout<<cnt<<endl;
     cout<<cnt*b<<endl;


}


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

import numpy as np
MOD = 998244353
n, s = map(int, input().split())
A = list(map(int, input().split()))
F = np.zeros(s+1, dtype=np.int64)
ans = 0
for a in A:
  F[0] += 1
  F[a:] += F[:-a].copy()
  F %= MOD
  ans += F[s]
  ans %= MOD
print(ans)

Measured memory_bytes: 12492
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(sc.next());
        sc.close();

        out.printf("%d\n", N / 3);
        out.flush();
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/


int main() {
	cin >> s;
	n = s.size();
	REP(i, n) {
		if (s[i] == '0') {
			k = 0;
			v.push_back(k);
		}
		else if (s[i] == '1') {
			k = 1;
			v.push_back(k);
		}
		else if (s[i] == 'B' && v.size() != 0) {
			v.pop_back();
		}
	}
	REP(i, v.size()) {
		cout << v[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
const int N= 100005;
int fa[N];
unsigned long long value[N];
int sons[N];
int rsons[N];
vector<int> now;
bool vis[N];
map<unsigned long long,int> times;


int main(int argc, char const *argv[])
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        int start,end;
        scanf("%d%d",&start,&end);
        fa[end] = start;
        sons[start]++;
        rsons[start]++;
    }

    for(int i=1;i<=n;i++){
        if(sons[i] == 0){
            now.push_back(i);
        }
    }

    int now_size = now.size();
    while(now_size>0){
        int new_index = 0;
        for(int i=0;i<now_size ;i++){
            //printf("do %d\n",now[i] );
            int f = fa[now[i]];
            if(rsons[now[i]]==0 ){
                value[now[i]]++;
                times[value[now[i]]]++;
                value[f] += value[now[i]]*13131;
                rsons[f]--;
                //printf("test %d\n",now[i] );
                
                if(rsons[f]==0 && !vis[f]){
                    vis[f] = true;
                    now[new_index++] =f;
                }
                
                
            }
        }
        now_size = new_index;
    }
    long long result = 0;
    for(auto it = times.begin();it!= times.end();it++){
        long long n = (*it).second;
        result+=n*(n-1)/2;
        //printf("id:%lld value:%d\n",(*it).first,(*it).second );
    }
    //printf("v:%lld\n",value[0] );
    printf("%lld\n",result );


    return 0;
}

Measured memory_bytes: 11112
import java.io.*;
import java.util.*;

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int x = 0; 
		char[] s = in.next().toCharArray();
		int max = 0;
		for(int i =0 ; i<s.length; i++){
			if(s[i]=='I'){x++;}
			else x--;
			if(x>max)max = x;
		}
		out.println(max);		
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 23252
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

N, M = mii()
edge = defaultdict(list)
memo = defaultdict(int)
done = defaultdict(bool)


def dp(v):
    if done[v]:
        return memo[v]
    ret = 0
    for to in edge[v]:
        ret = max(ret, dp(to) + 1)
    done[v] = True
    memo[v] = ret
    return ret


for i in range(M):
    x, y = mii()
    edge[x].append(y)
ans = 0
for v in range(1, N+1):
    ans = max(ans, dp(v))

print(ans)


Measured memory_bytes: 202992
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(void) {
  int n,i;
  cin>>n>>i;
  cout<<n-i+1<<endl;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n;
	lint k,a[100000]; scanf("%d%lld",&n,&k);
	rep(i,n) scanf("%lld",a+i);

	lint x=0;
	bool sat=true;
	for(int i=50;i>=0;i--){
		int cnt[2]={};
		rep(j,n) cnt[a[j]>>i&1]++;
		if(cnt[0]<cnt[1]){ // put 0
			if(k>>i&1) sat=false;
		}
		else{
			if(!sat || k>>i&1){ // put 1
				x|=1LL<<i;
			}
		}
	}

	lint ans=0;
	rep(i,n) ans+=x^a[i];
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >

using namespace std;

const int N = 100005;
const int M = 1000000007;
const lb PI = acos(-1);

int n;
string a;
unordered_set < string > s;

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

    cin >> n;

    for(int i = 1 ; i <= n ; i++)
    {
        cin >> a;
        s.insert(a);
    }

    cout << s.size();

    return 0;
}


Measured memory_bytes: 17648
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
int n, ans;
ll **dp, w;
pair<ll, int> *x;
ll nap(int i, int rem)
{
    if(i == n && rem)
        return (ll)1e9 + 1;
    else if(!rem)
        return 0;
    if(~dp[i][rem])
        return dp[i][rem];
    ll first = nap(i + 1, rem), second = (ll)1e9 + 1;
    if(rem >= x[i].second)
        second = x[i].first + nap(i + 1, rem - x[i].second);
    return dp[i][rem] = min(first, second);
}
int main()
{
    //cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #endif
    scanf("%d %lld", &n, &w);
    x = new pair<ll, int>[n];
    int mx = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%lld %d", &x[i].first, &x[i].second);
        mx += x[i].second;
    }
    dp = new ll*[n];
    for(int i = 0; i < n; i++)
    {
        dp[i] = new ll[mx + 1];
        memset(dp[i], -1, (mx + 1) * 8);
    }
    for(int i = 1; i <= mx; i++)
        if(nap(0, i) <= w)
            ans = max(ans, i);
    printf("%d", ans);
}


Measured memory_bytes: 80640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, k, a[200009], b[200009];
long long s[200009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int ans = 0;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		s[i] = b[i];
		if (i) s[i] += s[i - 1];
		if (s[i] <= k) ans = i + 1;
	}
	long long tmp = 0;
	for (int i = 0; i < n; i++) {
		tmp += a[i];
		if (tmp > k) break;
		int res = k - tmp;
		if (s[0] > res) {
			ans = max(ans, i + 1);
		}
		else {
			int l = 0, r = m;
			while (l + 1 < r) {
				int mid = (l + r) / 2;
				if (s[mid] <= res) l = mid;
				else r = mid;
			}
			ans = max(ans, i + 1 + l + 1);
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
std::cin >> x;
repo(i,-1000,1001){
  Repo(j,-1000,1001){
    if(i*i*i*i*i-j*j*j*j*j==x){
      std::cout << i<<" "<< j<< '\n';
      return 0;
    }
  }
}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e2+10;
map<string,int>mp;
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int num=0;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
        num=max(num,mp[s]);
    }
    for(auto it:mp){
        if(it.second==num)cout<<it.first<<endl;
    }
    return 0;
}


Measured memory_bytes: 23808
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dp[114514][19],pos[114514][19];
vector<int> gr[114514];
int v[114514],d[114514],c[114514];
int cal(int x,int y){
	if(dp[x][y]>-2) return dp[x][y];
	int ret=-1;
	REP(i,y,11) ret=max(ret,pos[x][i]);
	if(y<10){
		rep(j,gr[x].size()) ret=max(ret,cal(gr[x][j],y+1));
	}
	return dp[x][y]=ret;
}
int main()
{
	int n,m,q,a,b;
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b;a--;b--;
		gr[a].pb(b);gr[b].pb(a);
	}
	memset(pos,-1,sizeof(pos));
	cin>>q;
	rep(i,q){
		cin>>v[i]>>d[i]>>c[i];v[i]--;
		pos[v[i]][d[i]]=max(pos[v[i]][d[i]],i);
	}
	rep(i,114510) rep(j,17) dp[i][j]=-2;
	rep(i,n){
		int ret=cal(i,0);
		if(ret<0) cout<<0<<endl;else cout<<c[ret]<<endl;
		//cout<<i+1<<' '<<ret<<endl;
	}
}


Measured memory_bytes: 24952
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  cout << fixed <<setprecision(7);
  int N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double>> V;
  for (int i = 0; i < N; i++) {
    double v;
    cin >> v;
    V.push(v);
  }
  while(V.size() > 1) {
    double x, y;
    x = V.top();
    V.pop();
    y = V.top();
    V.pop();
    double z = (x + y)/2;
    V.push(z);
  }
  double ans = V.top();
  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
ans = 0
now = s[0]
for i in range(1, len(s)):
    if now == "B":
        if s[i] == "W":
            ans += 1
            now = "W"
    else:
        if s[i] == "B":
            ans += 1
            now = "B"
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+1;

int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector< vector<int> > a(n,vector<int>(m));
    int ans=1e9;
    rep(i,n)
    {
        cin>>c[i];
        rep(j,m)
        {
            cin>>a[i][j];
        }
    }

    for(int bit=0;bit<(1<<n);bit++)
    {
        vector<int> t(m,0);
        int cost=0;
        rep(i,n)
        {
            if((bit>>i)&1)
            {
                rep(j,m)
                {
                    t[j]+=a[i][j];
                }
                cost+=c[i];
            }
            
        }
        bool flag=true;
        rep(i,m)
        {
            if(t[i]<x)flag=false;
        }
        if(flag)ans=min(ans,cost);
    }
    if(ans!=1e9)
    {
        cout<<ans;
    }
    else
    {
        cout<<-1;
    }
    

}

Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 //     String[] sn=sc.nextLine().split(" ");
//int num=Integer.parseInt(sn[0]);
//int num2=Integer.parseInt(sn[1]);

String[] week={"Sunny", "Cloudy", "Rainy"};


      String sn=sc.nextLine();
//int num=Integer.parseInt(sn);


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

if(sn.equals(week[i])){
System.out.println(week[(i+1)%3]);
}

}

//System.out.println(a/b);


	}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

vector < int> v{4, 6, 9, 12};

bool f(int a) {
    for(int x: v) if(x == a) return true;
    return false;
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 2 or b == 2) return !printf("No");
    if (f(a)) {
        if(f(b)) puts("Yes");
        else puts("No");
        return 0;
    }

     if (f(b)) {
        if(f(a)) puts("Yes");
        else puts("No");
        return 0;
    }

    puts("Yes");

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int X[100001];
	int xmodd[100001]={};
	int xmeven[100001]={};
	int num[100001]={};
	scan(N>>M);
	rep(i,N){
		scan(X[i]);
		num[X[i]]++;
	}
	int ans=0;
	rep1(i,100000){
		xmeven[i%M]+=num[i]/2;
		if(num[i]%2){
			xmodd[i%M]+=1;
		}
	}/*
	rep1(i,10){
		printf("num[%d]:%d\n",i,num[i]);
	}
	rep(i,M){
		printf("xmodd[%d]:%d xmeven[%d]:%d\n",i,xmodd[i],i,xmeven[i]);
	}*/
	ans+=xmeven[0]+xmodd[0]/2;
	rep1(i,M/2){
		int j=M-i;
		if(i==j) ans+=xmeven[i]+xmodd[i]/2;
		else{
			int oi=xmeven[i]*2+xmodd[i];
			int oj=xmeven[j]*2+xmodd[j];
			if(oi>oj){
				ans+=oj;
				if(xmodd[i]>oj) ans+=xmeven[i];
				else ans+=(oi-oj)/2;
			}
			else{
				ans+=oi;
				if(xmodd[j]>oi) ans+=xmeven[j];
				else ans+=(oj-oi)/2;
			}
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b ;
    cin>>a>>b;
    int t=0 , n;
    for (int x=0 ; x<=a ; ++x)
    {
        for (int y=0 ; y<=a ; ++y)
        {
            n=b-x-y;
            if (n>=0&&n<=a)
            {
                t+=1;
            }
        }
    }
    cout<<t<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll K;
  cin >> K;
  cout << 50 << endl;
  ll ans[50];
  ll n = K/50;
  ll m = K%50;
  for (int i = 0; i < 50; i++) {
    ans[i] = n + (49 - m); 
  }
  for (int i = 0; i < m; i++) {
    ans[i] = n + 49 + (51 - m);
  }
  for (int i = 0; i < 50; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    rep(i, N - 1) {
        if (H[i] < H[i + 1]) {
            H[i + 1] -= 1;
        }
        if (H[i] > H[i + 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
a.sort()
count=0
mini=abs(a[0])
for i in range(n):
  if a[i]<0:
    count+=1
  mini=min(mini,abs(a[i]))
tot=0
for i in range(n):
  tot+=abs(a[i])
if count%2==0:
  print(tot)
else:
  print(tot-2*mini)

Measured memory_bytes: 14332
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, Q, X[100010], l, r;
	string S;
	cin >> N >> Q >> S;
	for (int i = 1; i < N; i++) {
		if (S.substr(i - 1, 2) == "AC") X[i + 1] = X[i] + 1;
		else X[i + 1] = X[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << X[r] - X[l] << endl;
	}
}

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

int main(){
    int N, M, C, ans = 0;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, M){
        cin >> B[i];
    }
    rep(i, N){
        rep(j, M){
            cin >> A[i][j];
        }
    }

    rep(i, N){
        int sum = 0;
        rep(j, M){
            sum += A[i][j]*B[j];
        }
        if(sum + C > 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


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

Measured memory_bytes: 256