akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Control.Monad (replicateM)

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

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

main :: IO ()
main = do
  [w,h,n] <- getParms              :: IO [Int]
  xya     <- replicateM n getParms :: IO [[Int]]
  print $ uncurry area $ f w h xya

type Range = (Int,Int)

initialize
  :: Int -> Int -> (Range, Range)
initialize w h = ((0, w), (0, h))

cut :: (Range, Range) -> [Int] -> (Range, Range) 
cut (xx@(xi,xf),yy@(yi,yf)) [x,y,a]
  | a == 1 = ((max x xi, xf), yy)
  | a == 2 = ((xi, min x xf), yy)
  | a == 3 = (xx, (max y yi, yf))
  | a == 4 = (xx, (yi, min y yf))

f :: Int -> Int -> [[Int]] -> (Range, Range)
f w h = foldl cut (initialize w h) 

area :: Range -> Range -> Int
area (xi,xf) (yi,yf) 
  | xi < xf && yi < yf = (xf-xi)*(yf-yi)
  | otherwise          = 0

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;
    printf("%.20lf", 2*n*acos(-1));

    return 0;
}


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

int arr[105];
bool asd[100005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int z,x;
	cin>>z>>x;
	
	for(int q=1;q<=z;q++)
	{
		cin>>arr[q];
	}
	
	for(int q=0;q<=x;q++)
	{
		for(int w=1;w<=z;w++)
		{
			if(q-arr[w]>=0)
			{
				if(!asd[q-arr[w]])
				asd[q]=true;
			}
		}
	}
	if(asd[x])
	cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

ll calc(const ll x) {
    if (x % 2 == 0) {
        ll cnt = x / 2;
        if (cnt % 2 == 0) {
            return x;
        } else {
            return x ^ 1;
        }
    } else {
        ll cnt = (x + 1) / 2;
        return cnt % 2;
    }
}

ll solve(const ll A, const ll B) {
    ll v_a = calc(A - 1);
    ll v_b = calc(B);
    return v_a ^ v_b;
}

int main(void) {
    ll A, B;
    cin >> A >> B;

    cout << solve(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int grid[100][100];
int main(){
  while(true){
    int N;
    int W;
    int H;
    cin >> N;
    if(N == 0){
      break;
    }
    cin >> W >> H;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        grid[i][j] = 0;
      }
    }

    for(int i = 0; i < N; i++){
      int x;
      int y;
      cin >> x >> y;
      grid[y - 1][x - 1] ++;
    }

    int S;
    int T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i <= H - T; i++){
      for(int j = 0; j <= W - S; j++){
        int tmp_ans = 0;
        for(int k = 0; k < T; k++){
          for(int l = 0; l < S; l++){
            tmp_ans += grid[i + k][j + l];
          }
        }
        ans = max(ans, tmp_ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#pragma GCC target("popcnt,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int N = 2005;
int n, m;
vector<int> t[N];
bitset<N> g[N], s[N], now, _p[N * N / 2];

bitset<N> &p(int i, int j) {
	if (i < j) swap(i, j);
	return _p[(i - 1) * (i - 2) / 2 + j];
}

void dfs(int rt, int u, int fa) {
	now[u] = 1;
	s[u].reset();
	s[u][u] = 1;
	for (int v : t[u])
		if (v != fa) {
			dfs(rt, v, u);
			s[u] |= s[v];
		}
	if (rt != u) p(rt, u) |= now | s[u];
	now[u] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 1, x, y; i < n; ++i) {
		cin >> x >> y;
		t[x].push_back(y), t[y].push_back(x);
	}
	for (int i = 1; i <= n; ++i) dfs(i, i, 0);
	queue<pair<int, int>> q;
	for (int i = 1, x, y; i <= m; ++i) {
		cin >> x >> y;
		q.emplace(x, y);
		g[x][y] = g[y][x] = 1;
	}
	while (!q.empty()) {
		auto t = q.front(); q.pop();
		int a = t.first, b = t.second;
		auto tmp = (g[a] ^ g[b]) & p(a, b);
		for (int i = tmp._Find_first(); i != N; i = tmp._Find_next(i)) {
			if (i == a || i == b) continue;
			if (g[a][i]) g[i][b] = g[b][i] = 1, q.emplace(i, b);
			else g[i][a] = g[a][i] = 1, q.emplace(i, a);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) ans += g[i].count();
	printf("%d\n", ans / 2);
}


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

int main(){

  string s, t;

  cin>>s>>t;
  for(int i=0;i<3;i++){
    if(s[i]!=t[2-i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
const int N=2e5+5;
typedef long long ll;
const ll mod=998244353;
int n;
char s[N],t[N];
ll f[N];
bool cmp() {
    for(int i=0;i<n;i++) {
        if(s[i]==t[i]) continue;
        return s[i]>t[i];
    }
    return true;
}
int main() {
    scanf("%d",&n);
    scanf("%s",s);
    ll ans=0;
    for(int i=0;i<n;i++) {
        ans=(ans*2+s[i]-'0')%mod;
    }
    f[n]=(ans+1)%mod;
    for(int i=3;i<=n;i+=2) if(n%i==0) {
        ll tot=0;
        int len=n/i;
        for(int j=0;j<n/i;j++) tot=(tot*2+s[j]-'0')%mod;
        f[len]=tot;
        for(int j=0;j<len;j++) {
            t[j]=s[j];
        }
        for(int j=len;j<n;j++) t[j]=((t[j-len]-'0')^1)+'0';
        if(cmp()) f[len]=(f[len]+1)%mod;
    }ans=0;
    for(int i=1;i<=n;i++) {
        if(n%i==0&&(n/i)&1) {
            for(int k=i+i;k<=n;k+=i) f[k]=(f[k]-f[i]+mod)%mod;
            ans=(ans+2*i*f[i])%mod;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

LL x[1000],y[10000];

int main(){
	LL a,b,c,d,n,sum = 0;
	cin >> a >> b >> c >> d >> n;
	x[1] = a * 4,x[2] = b * 2,x[3] = c;
	sort(x + 1,x + 1 + 3);
	y[1] = x[1] * 2,y[2] = x[2] * 2,y[3] = c * 2,y[4] = d;
	sort(y + 1,y + 1 + 4);
	if(n == 1) cout << x[1];
	else{
		if(n % 2 == 0) cout << n / 2 * y[1];
		else cout << n / 2 * y[1] + x[1];
	}
}

Measured memory_bytes: 256
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  1000005
ll sp[N];
void seive(){
 	for(int i=2;i<N;i++){
 		if(!sp[i]){
 			for(int j=i;j<N;j+=i){
 				if(!sp[j])sp[j]=i;
 			}
 		}
 	}
}
bool check(ll num){
	if(num==1)return false;
	for(ll i=2;i*i<=num;i++){
		if(num%i==0)return false;
	}
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,m,i,j,k;
		cin>>n>>m;
		ll hcf = __gcd(n,m);
		seive();

		int ct=1;
		for(i=2;i<=hcf && i<N;i++){
			if(sp[i]==i && hcf%i==0){
				while(hcf%i==0)hcf/=i;
				ct++;
			}
		}

		if(check(hcf))ct++;
		cout<<ct;


	}
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;


signed main(){
    int a[4], b[2];
    rep(i, 0, 4) cin >> a[i];
    rep(i, 0, 2) cin >> b[i];
    sort(a, a + 4);
    sort(b, b + 2);
    int ans = 0;
    rep(i, 1, 4) ans += a[i];
    ans += b[1];
    cout << ans << endl;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<tuple>

typedef long long int lli;
typedef std::tuple<lli, lli> T;
typedef std::tuple<lli, lli, lli> TT;

lli tbl1[200000];
lli tbl2[200000];

int main(void) {
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    std::vector<TT> A;

    for(int i=0; i<x+y+z; i++) {
        lli a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a=b-a;
        A.push_back(std::tie(a,b,c));
    }

    std::sort(begin(A), end(A));

    {
        std::priority_queue<lli> q;

        int i=0;
        lli r = 0;
        for(; i<x; i++) {
            auto a = std::get<0>(A[i]);
            auto b = std::get<1>(A[i]);
            auto c = std::get<2>(A[i]);
            a = b-a;

            r += a;
            q.push(c-a);
            tbl1[i] = r;
        }

        for(; i<x+y+z; i++) {
            auto a = std::get<0>(A[i]);
            auto b = std::get<1>(A[i]);
            auto c = std::get<2>(A[i]);
            a = b-a;

            r += a;
            q.push(c-a);
            auto t = q.top(); q.pop();
            r += t;
            tbl1[i] = r;
        }
    }

    {
        std::priority_queue<lli> q;

        int i=0;
        lli r = 0;
        for(; i<y; i++) {
            int j = x+y+z-1-i;
            auto a = std::get<0>(A[j]);
            auto b = std::get<1>(A[j]);
            auto c = std::get<2>(A[j]);
            a = b-a;

            r += b;
            q.push(c-b);
            tbl2[j] = r;
        }

        for(; i<x+y+z; i++) {
            int j = x+y+z-1-i;
            auto a = std::get<0>(A[j]);
            auto b = std::get<1>(A[j]);
            auto c = std::get<2>(A[j]);
            a = b-a;

            r += b;
            q.push(c-b);
            auto t = q.top(); q.pop();
            r += t;
            tbl2[j] = r;
        }
    }

    lli ma = 0;
    for(int i=x-1; i<x+z; i++)
        if(ma < tbl1[i] + tbl2[i+1]) ma = tbl1[i] + tbl2[i+1];
    printf("%lld\n", ma);
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    for (int i = 0; i < A; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < C; i++) {
        cin >> r[i];
    }
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    ll P[A + 1]{}, Q[B + 1]{}, R[C + 1]{};
    for (int i = 0; i < A; i++) {
        P[i + 1] = P[i] + p[i];
    }
    for (int i = 0; i < B; i++) {
        Q[i + 1] = Q[i] + q[i];
    }
    for (int i = 0; i < C; i++) {
        R[i + 1] = R[i] + r[i];
    }
    ll ans = P[X] + Q[Y];
    int id_p = X;
    int id_q = Y;
    for (int i = 1; i <= min(C, X + Y); i++) {
        if (id_p == 0 && id_q == 0) {
            ans = max(ans, R[min(X + Y, C)]);
            break;
        }
        if (id_p == 0) {
            id_q--;
        } else if (id_q == 0) {
            id_p--;
        } else if (P[id_p - 1] + Q[id_q] < P[id_p] + Q[id_q - 1]) {
            id_q--;
        } else {
            id_p--;
        }
        ans = max(ans, R[i] + P[id_p] + Q[id_q]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7952
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long[] c = new long[n + 1];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            c[a[i]]++;
        }
        long sum = 0;
        for (int i = 0 ; i <= n ; i++) {
            long d = (long) c[i] * (c[i] - 1) / 2;
            sum += d;
        }

        for (int i = 0 ; i < n ; i++) {
            System.out.println(sum - (c[a[i]] - 1));
        }


    }

}


Measured memory_bytes: 102316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll a, b;
	cin >> a >> b;
	ll k = 1;
	if(a == 1)
		k = 100;
	if(a==2)
		k = 10000;
	ll ans =k * b;
	if(b == 100)
		b ++;
	cout << k*b;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}


Measured memory_bytes: 256
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)
  
  b = [0] * (n - 1)
  (n - 1).times{ |i| b[i] = a[i + 1] <=> a[i] }
  b.delete(0)
  
  i = 0
  c = 1
  d = b[0]
  while i < b.size do
    if b[i] != d then
      c += 1
      i += 1
      d = b[i]
    end
    i += 1
  end

  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 10252
#include <iostream>
#include <set>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) swap(x, y);
    if(y==0) return x;
    
    return GCD(y, x%y);
}

int main() {
    long long int A, B;
    cin >> A >> B;
    set<long long int> st;
    long long int AB=GCD(A, B);
    long long int i;
    for(i=2; i*i<=AB; i++) {
        if(AB%i==0) {
            st.insert(i);
            st.insert(AB/i);
        }
    }
    auto itr=st.begin();
    set<long long int> ans;
    while(AB!=1 && itr!=st.end()) {
        if(AB%*itr==0) {
            ans.insert(*itr);
        }
        while(AB%*itr==0) {
            AB /= *itr;
        }
        itr++;
    }
    ans.insert(1);
    if(AB!=1) ans.insert(AB);
    cout << ans.size() << endl;


    return 0;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int dp[3010][3010];
string s,t;
string ans="";
int fill(int i,int j){
    if (i < 0 || j < 0)
        return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    

    if(s[i]==t[j]) {
        //ans+=s[i];
        //cout<<"hi"<<endl;
        dp[i][j]=1+fill(i-1,j-1);
        return dp[i][j];
    }
    dp[i][j]=max(fill(i-1,j),fill(i,j-1));
    return dp[i][j];

}
int main()
{   
    cin>>s>>t;
    if(s.size()<t.size()) swap(s,t);

    
    memset(dp, -1, sizeof(dp));
    fill(s.size()-1,t.size()-1);
    int i=s.size()-1;
    int j=t.size()-1;
    while(1){
        if(s[i]==t[j]){
            ans+=s[i];
            i--;
            j--;
        }
        else if(fill(i,j)==fill(i-1,j)){
            i--;
            
        }
        else{
            j--;
        }
        if(i<0 || j<0) break;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
}

Measured memory_bytes: 35968
//ackage src;

import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
import java.math.BigInteger;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static int mod = 1000000007;

	public static void main(String args[]) {
		int n=scn.nextInt(),k=scn.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=scn.nextInt();
		}
		
		if(k>=n)
			System.out.println(Math.abs(arr[n-1]-arr[0]));
		else
		{
		long memo[]=new long[n+1];
		Arrays.fill(memo, -1);
		System.out.println(mincost(arr, 0,memo,k));
		}
	}
		public static long mincost(int arr[],int i,long memo[],int k)
		{	int n=arr.length;
			if(i==n-1)
				return 0;
			if(i>=n)
				return Integer.MAX_VALUE;
			if(memo[i]!=-1)
				return memo[i];
			long a=Integer.MAX_VALUE,b=Integer.MAX_VALUE;
			for(int j=1;j<=k;j++)
			{
				b=mincost(arr, i+j, memo,k)+Math.abs(arr[Math.min(n-1, i)]-arr[Math.min(n-1, i+j)]);
				a=Math.min(a, b);
			}
			memo[i]=a;
			return Math.min(a, b);
		}
	public static int decode(String str, int i, int[] memo) {
		if (i == 0) {
			return 1;
		}
		int ind = str.length() - i;
		if (str.charAt(ind) == '0')
			return 0;
		if (memo[i] != -1)
			return memo[i];
		int res = decode(str, i - 1, memo);
		if (i >= 2 && Integer.parseInt(str.substring(ind, ind + 2)) <= 26) {
			res += decode(str, i - 2, memo);
		}
		memo[i] = res;
		return res;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static String factorial(int n) {
		BigInteger fac = new BigInteger("1");
		for (int i = 1; i <= n; i++) {
			fac = fac.multiply(BigInteger.valueOf(i));
		}
		return fac.toString();
	}

}

class pair {
	int a;
	int b;

	pair(int x, int y) {
		this.a = x;
		this.b = y;
	}
}

class sorting implements Comparator<pair> {

	@Override
	public int compare(pair o1, pair o2) {
		// TODO Auto-generated method stub
		int a = o1.a - o2.a;
		if (a < 0)
			return -1;
		else
			return 1;
	}

}


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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if(a + b <= 2 * c) {
        cout << a * x + b * y << endl;
    }
    else {
        if(x >= y) {
            if(a <= 2 * c) {
                cout << 2 * c * y + a * (x - y);
            }
            else cout << 2 * c * x << endl;
        }
        else {
            if(b <= 2 * c) {
                cout << 2 * c * x + b * (y - x);
            }
            else cout << 2 * c * y << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in cnt_a.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14468
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    G = [[] for i in range(N+1)]
    G_color = ['WHITE' for _ in range(N+1)]
    G_distance = [float('inf') for _ in range(N+1)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        G[a].append(b)
        G[b].append(a)

    def bfs(s):
        """
        G_color: BLACK if visited, GRAY if discovered, but will visit, WHITE
                 if not discovered
        G_distance: a distance from s to v when algorithm computed
        """
        G_color[s] = 'GRAY'
        G_distance[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_distance[v] = G_distance[u] + 1
                    Q.append(v)
                    # distance <= 2 が探索し終わったら終わり
                    if G_distance[v] == 3:
                        return None
            G_color[u] = 'BLACK'
    bfs(1)
    if G_color[N] != 'WHITE' and G_distance[N] <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 97740
#include <stdio.h>

int main(){
  int n, u, k, v, c, list[100][100], s[100], d[100], p[100];
  int i, j, min, min_v;

  for (i = 0; i < 100; i++) {
    d[i] = 999999;
    s[i] = -1;
    for (j = 0; j < 100; j++) {
      list[i][j] = 999999;
    }
  }

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d %d", &v, &c);
      list[u][v] = c;
    }
  }

  d[0] = 0;

  for (j = 0; j < n; j++){
    min = 1000000;
    for (i = 0; i < n; i++) {
      if (min > d[i] && s[i] != 1) {
        min = d[i];
        min_v = i;
      }
    }

    s[min_v] = 1;
    for (i = 0; i < n; i++) {
      if (d[min_v]+list[min_v][i]<d[i] && s[i]!=1){
        d[i] = d[min_v] + list[min_v][i];
        p[min_v] = i;
      }
    }
  }

  for (i = 0; i < n; i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}



Measured memory_bytes: 2112
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n,m,r;
	cin >> n >> m >> r;
	const int INF = 1e9;
	vector<vector<int>> d(n,vector<int>(n,INF));
	REP(i,n) d[i][i] = 0;
	vector<int> destination(r);
	REP(i,r){
		cin >> destination[i];
		destination[i]--;
	}
	REP(i,m){
		int a,b,c;
		cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}
	REP(k,n){
 		REP(i,n){
 			REP(j,n){
 				d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
 			}
 		}
 	}
	
	sort(destination.begin(),destination.end());
	int ans = 1e9;
	do{
		int tmp=0;
		REP(i,r-1){
			tmp += d[destination[i]][destination[i+1]];
		}
		chmin(ans,tmp);
	}while(next_permutation(destination.begin(),destination.end()));
	
	cout << ans << endl;
	
		
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  bool ans = true;
  rep(i, h) rep(j, w) {
    if (grid[i][j] == '.') continue;
    bool ok = false;
    srep(dx, -1, 2) srep(dy, -1, 2) {
      if (dx * dx + dy * dy != 1) continue;
      int nx = j + dx, ny = i + dy;
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if (grid[ny][nx] == '#') ok = true;
    }
    if (!ok) ans = false;
  }
  std::cout << (ans ? "Yes" : "No") << "\n";
}


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

void solve(){
    ll n, k = 26;
    cin >> n;
    string s;
    while(n){
        ll x = (n%26 == 0 ? 25: n%26-1);
        s += (char)(x + 'a');
        n= n - (n%26 == 0 ? 26:n%26);
        n/=26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};

int main(){
  string s,t,ss;
  int a,b,i,j,k,l,n,ans=0,m=0;
  vector<string> vs;
  vector<int> v[26];
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq

  cin >> n;

  cin >> b;
  rep(i,0,n-2){
    cin >> a;
    if(b >= a){
      m++;
    }else{
      m = 0;
    }
    b = a;
    if(ans < m)ans = m;
  }

 
  cout << ans << endl;
  return 0;

}

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

int main(){
    int n;
    cin >> n;
    int happy = 0;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 1; i < n; i++)  happy += a[i]>a[i-1];
    cout << happy << endl;
    return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    string s ;
    cin >> s ;
    int res = 0 ;
    rep(i,4){
        rep(j,4){
            if(i == j){
                continue ;
            }
            else {
                if(s[i] == s[j]){
                    res++ ;
                }
            }
        }
    }
    if(res == 4){
        cout << "Yes" << endl ;
    }
    else {
        cout << "No" << endl ;
    }
}

Measured memory_bytes: 3588
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll N;
	cin >> N;


	ll sq = sqrt(N) + 1;

	map<ll, int> MP;
	rep1(i, sq) {
		if (i == 1) continue;
		if (N % i == 0) {
			while (N % i == 0) {
				MP[i]++;
				N /= i;
			}
		}
	}
	if (N != 1) MP[N]++;

	int kotae = 0;
	for (auto p : MP) {
		int n = p.second;
		int k = 1;
		while (n >= k) {
			kotae++;
			n -= k++;
		}
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	string s;
	
	while (cin >> s, s[0] != '0'){
		int sum = 0;
		for (int i = 0; i < s.size(); i++){
			sum += s[i] - '0';

		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,x,t;
	cin>>n>>x>>t;
	int ans=ceil(n/double(x));
	ans=ans*t;
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int h, w;
char s[400][400];
bool visit[400][400];
ll black = 0, white = 0;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

void dfs(int y, int x, int c) {
  (c & 1 ? black : white)++;
  visit[y][x] = true;
  for (int d = 0; d < 4; ++d) {
    int ny = y + dy[d];
    int nx = x + dx[d];
    if (0 <= ny && ny < h && 0 <= nx && nx < w) {
      if (!visit[ny][nx]) {
        if (c == 1 && s[ny][nx] == '.') {
          dfs(ny, nx, 0);
        } else if (c == 0 && s[ny][nx] == '#') {
          dfs(ny, nx, 1);
        }
      }
    }
  }
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }
  ll ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (!visit[i][j] && s[i][j] == '#') {
        black = 0, white = 0;
        dfs(i, j, 1);
        ans += black * white;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;

int a[1002], sum[2];
P calc(int n){
	int res = *max_element(a, a+n);
	int p = max_element(a, a+n)-a;
	return P(res, p);
}

signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld",&a[i]);
	rep(i,n)sum[i%2] += max((int)0, a[i]);
	
	P t3 = calc(n);
	rep(i,n)if(i%2 == (sum[0]>sum[1]))a[i] = -1;
	int f = (sum[0] <= sum[1]);
	int mx = max(sum[0], sum[1]);
	
	vector<int> ans;
	if(mx > 0){
		int k = 0;a[n] = 1;
		while(a[k]<=0){ans.push_back(1);k++;}
		if(f^(k%2)){ans.push_back(1);k++;}
		repi(i,k+2,n+1){
			if(a[i] > 0)ans.push_back(2);
			else ans.push_back(3);
			if(i == n-1 && a[i]<=0)ans.push_back(2);
			i++;
		}
		int m = ans.size();
		printf("%lld\n%lld\n",mx, m);
		rep(i,m)printf("%lld\n", ans[i]);
	}else{
		printf("%lld\n%lld\n", t3.fi, n-1);
		drep(i,n-1,t3.se+1)printf("%lld\n", i+1);
		rep(i,t3.se)printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = arg => {
    const include3 = (num, origin) => {
        let divide = parseInt(num / 10, 10);
        if( divide ){
            if(divide % 10 === 3){
                return origin;
            }
            return include3(divide, origin);
        } else {
            return 0;
        }
    }

    const input = parseInt(arg.trim().split("\n"), 10);
    //3の倍数を取得
    //10の倍数を取得。 10以上かも確認
    const result = [];
    [...Array(input)].forEach((obj, i) => {
        const num = i+1;
        if(num % 3 === 0){
            result.push(num);
        } else if(num % 10 === 3){
            result.push(num);
        } else {
            const cb = include3(num, num);
            if(cb !== 0){
                result.push(cb);
            }
        }
    });

    console.log(" "+result.join(" "));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 17584
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;

ll mpow(ll x, ll n){ //x^n(mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll inv_mod(ll a){return mpow(a,mod-2);}
template<ll mod> class modll {
 private:
  ll _num;
  modll set(ll num){ _num = num % mod; return *this; }
 public:
  modll(){ _num = 0; }
  modll(ll num){ _num = num % mod; }

  modll operator= (ll x){ return set(x % mod); }
  modll operator+ (ll x){ return modll<mod>(_num + (x % mod)); }
  modll operator- (ll x){ return modll<mod>(_num - (x % mod)); }
  modll operator* (ll x){ return modll<mod>(_num * (x % mod)); }
  modll operator+=(ll x){ return set(_num + (x % mod)); }
  modll operator-=(ll x){ return set(_num - (x % mod)); }
  modll operator*=(ll x){ return set(_num * (x % mod)); }

  explicit operator ll() { return _num; }
  friend ostream& operator<<(ostream &os, const modll<mod> &x){ os << x._num; return os; }
};
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

class Factorial{//階乗とその逆元を求めて計算に利用するクラス
 private:
    vector<ll> fac;
 public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};

int main(){
    ll W,H,x,y;
    cin>>W>>H>>x>>y;
    int ans;
    if(x==W/2.0&&y==H/2.0) ans=1;
    else ans=0;
    if(H&W&1) cout<<H*W/2+0.5<<" ";
    else cout<<H*W/2<<" ";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	lint ans = INF64;

	ans = min(ans, A * X + B * Y);
	ans = min(ans, C * max(X, Y) * 2);
	if (X < Y)
		ans = min(ans, C * X * 2 + (Y - X) * B);
	else
		ans = min(ans, C * Y * 2 + (X - Y) * A);

	cout << ans << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
s = input()

acgt_s = "ACGT"
count_s = 0
count_max = 0

for i in s:
    for j in acgt_s:
        if j == i:
            count_s += 1
            count_max = max(count_max, count_s)
            break
    else:
        count_s = 0


print(count_max)


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

int main() {
	int a, b, c, d, e;
  cin>>a>>b>>c>>d>>e;
  vector<int> vect;
  vect.push_back(a);
  vect.push_back(b);
  vect.push_back(c);
  vect.push_back(d);
  vect.push_back(e);
  for (int i = 0; i < vect.size(); i++)
  {
    if (vect[i] == 0)
    {
      cout<<i+1;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

asum = sum(a)
acount = []
for i in range(10**5):
    acount.append(0)
for i in a:
    acount[i-1] += 1

q = int(input())

ans = []
for i in range(q):
    b,c = map(int, input().split())
    if acount[b-1] > 0:
        asum = asum - b * acount[b-1]
        acount[c-1] += acount[b-1]
        asum = asum + c * acount[b-1]
        acount[b-1] = 0
    ans.append(asum)
for i in ans:
    print(i)


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

#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 REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N){
    int memo[N+1];
    REP(i, N+1) memo[i] = 0;

    REP2(i, 2, N+1) {
        int tmp = i;
        for(int j=2; j*j <= i; j++){
            while(tmp % j == 0){
                memo[j]++;
                tmp /= j;
            }
        }
        if(tmp != 1) memo[tmp]++;
    }

    int dp[N+1][2][2][2];
    REP(i, N+1) REP(j, 2) REP(k, 2) REP(l, 2) dp[i][j][k][l] = 0;
    dp[0][0][0][0] = 1;

    REP(idx, N) {
        REP(i, 2) { REP(j, 2) { REP(k, 2) {
            dp[idx+1][i][j][k] += dp[idx][i][j][k];

            if(i == 0 && memo[idx] >= 2) dp[idx+1][1][j][k] += dp[idx][0][j][k];
            if(j == 0 && k == 0 && memo[idx] >= 4) dp[idx+1][i][1][0] += dp[idx][i][0][0];
            if(j == 1 && k == 0 && memo[idx] >= 4) dp[idx+1][i][1][1] += dp[idx][i][1][0];
            if(i == 0 && j == 0 && k == 0 && memo[idx] >= 14) dp[idx+1][1][1][0] += dp[idx][0][0][0];
            if(i == 0 && j == 1 && k == 0 && memo[idx] >= 14) dp[idx+1][1][1][1] += dp[idx][0][1][0];
            if(j == 0 && k == 0 && memo[idx] >= 24) dp[idx+1][i][1][1] += dp[idx][i][0][0];
            if(i == 0 && j == 0 && k == 0 && memo[idx] >= 74) dp[idx+1][1][1][1] += dp[idx][0][0][0];
        }}}
    }

    cout << dp[N][1][1][1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int x;
  cin>>x;
  if(x==25){
  cout<<"Christmas"<<endl;
  }
  else if(x==24){
  cout<<"Christmas Eve"<<endl;
  }
  else if(x==23){
  cout<<"Christmas Eve Eve"<<endl;
  }
  else if(x==22){
  cout<<"Christmas Eve Eve Eve"<<endl;
  }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
if n > 0 then
  ar = gets.chomp.split(" ").map(&:to_i)
  br = gets.chomp.split(" ").map(&:to_i)
  i = 0
  t = 0
  c = 0
  ar.each do |a|
    t += c > a ? a : c
    zan = c > a ? 0 : a - c
    c = 0
    b = br[i].nil? ? 0 : br[i]
    if zan >= b
      t += b
    else
      c = b - zan
      t += zan
    end
    i += 1
  end
  puts "#{t}"
end


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

int main(void){
    int n;
    int s = 0;
    int i;
    
    cin >> n;
    
    int x = n;
    while(x > 0){
        s += x % 10;
        x /= 10;
    }
    
    if(n % s == 0)      cout << "Yes\n";
    else                cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc146/abc146_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

void dfs(int from, int color, int &maxC, vector<vector<int>> &g, map<P, int> &colors) {
  int c = 1;
  for (auto to : g[from]) {
    if (c == color) c++;
    if (colors.find(make_pair(from, to)) == colors.end()) {
      colors.emplace(make_pair(from, to), c);
      colors.emplace(make_pair(to, from), c);
      dfs(to, c, maxC, g, colors);
      c = c + 1 > maxC ? 1 : c + 1;
    }
  }
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<P> c(N-1);
  vector<vector<int>> g(N, vector<int>(0));
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    c[i] = make_pair(a, b);

    g[a].push_back(b);
    g[b].push_back(a);
  }

  int max = 0;
  int start = 0;
  rep(i, N) {
    if (g[i].size() > max) {
      max = g[i].size();
      start = i;
    }
  }

  map<P, int> colors;

  colors.emplace(make_pair(start, g[start][0]), 1);
  colors.emplace(make_pair(g[start][0], start), 1);
  dfs(start, 1, max, g, colors);
  dfs(g[start][0], 1, max, g, colors);

  cout << max << endl;
  rep(i, N-1) { cout << colors.at(c[i]) << endl; }
}

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

using namespace std;

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

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

	
	int ans = a*b - (1 * a + 1 * b - 1 * 1);
	

	cout << ans << endl;
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi 3.1415926535
# define eps 1e-4
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

char s1[N], s2[N];
int num1[N][2], num2[N][2];

int main ()
{
    scanf("%s%s",s1+1,s2+1);
    for (int i=1; s1[i]; ++i) {
        num1[i][0]=num1[i-1][0]; num1[i][1]=num1[i-1][1];
        if (s1[i]=='A') ++num1[i][0];
        else ++num1[i][1];
    }
    for (int i=1; s2[i]; ++i) {
        num2[i][0]=num2[i-1][0]; num2[i][1]=num2[i-1][1];
        if (s2[i]=='A') ++num2[i][0];
        else ++num2[i][1];
    }
    int T, l1, l2, r1, r2;
    scanf("%d",&T);
    while (T--) {
        scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
        int x=((num1[r1][0]-num1[l1-1][0])*2+(num1[r1][1]-num1[l1-1][1]))%3;
        int y=((num2[r2][0]-num2[l2-1][0])*2+(num2[r2][1]-num2[l2-1][1]))%3;
        puts(x==y?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	int time = 0;

	if (pll(H1, M1) > pll(H2, M2)) H2 += 24;

	if (M1 <= M2) time += (H2 - H1) * 60 + (M2 - M1);
	else time += (H2 - H1 - 1) * 60 + (M2 + 60 - M1);

	cout << time - K << '\n';

	return 0;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.min(a, b) + Math.min(c, d));
  }
}

Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int x,y,z,ans=0;
	while(true){
		cin>>x>>y>>z;
		if(x==0 && y==0 && z==0)break;
		ans=0;
		for(int i=1;i<=z-1;i++){
			for(int j=1;j<=z-1;j++){
				if(i*(100+x)/100+j*(100+x)/100==z)
					ans=max(ans,i*(100+y)/100+j*(100+y)/100);
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 3080
N = int(input())
L = list( map(int,input().split()) )

count = 0
ans = 0

for i in range(N-1):
    # もし右隣が高かったら初期化して次に行く
    if L[i] < L[i+1]:
        count = 0
        continue
    count += 1
    ans = max(ans,count)

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
string s;
int k;
vector <string> V;
 
int main()
{
	cin >> s;
	cin >> k;
	for (int i = 0; i < s.length(); i++) {
		string cur;
		for (int j = i; j < s.length() && j < i + k; j++) {
			cur += s[j];
			V.push_back(cur);
		}
	}
	sort(V.begin(), V.end()); V.erase(unique(V.begin(), V.end()), V.end());
	cout << V[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    rep(i,h+1){
        rep(j,w+1){
            if(i*w+j*h-2*i*j==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3644
N = int(input())
#= map(int,input().split())
#a =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
waru = 50
answer = N//10
if N%2 ==0:
    while N >=waru:
        answer += N//waru
        waru *= 5
    print(answer)
else:
    print('0')


Measured memory_bytes: 38384